Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fix/shell/src/fixpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub struct w2c_fixpoint(());
#[unsafe(no_mangle)]
pub unsafe extern "C" fn w2c_fixpoint_attach_blob(
fixpoint: *mut w2c_fixpoint,
memory_idx: u32,
handle: wasm_rt_externref_t,
memory_idx: u32,
) {
assert!(memory_idx < 64);
unsafe {
Expand All @@ -19,7 +19,7 @@ pub unsafe extern "C" fn w2c_fixpoint_attach_blob(
return;
}
let addr = (1usize << 32) * memory_idx as usize;
let len = shell::fixpoint_attach_blob(addr as *mut c_void, handle.bytes);
let len = shell::fixpoint_attach_blob(handle.bytes, addr as *mut c_void);
// TODO: this math is wrong
(*memory).pages = (len as u64 / PAGE_SIZE as u64) + 1;
(*memory).max_pages = (1u64 << 32) / PAGE_SIZE as u64;
Expand All @@ -30,8 +30,8 @@ pub unsafe extern "C" fn w2c_fixpoint_attach_blob(
#[unsafe(no_mangle)]
pub unsafe extern "C" fn w2c_fixpoint_attach_tree(
fixpoint: *mut w2c_fixpoint,
table_idx: u32,
handle: wasm_rt_externref_t,
table_idx: u32,
) {
assert!(table_idx < 63);
unsafe {
Expand All @@ -40,7 +40,7 @@ pub unsafe extern "C" fn w2c_fixpoint_attach_tree(
return;
}
let addr = (1usize << 32) * (64 + table_idx as usize);
let len = shell::fixpoint_attach_tree(addr as *mut c_void, handle.bytes);
let len = shell::fixpoint_attach_tree(handle.bytes, addr as *mut c_void);
(*table).size = len as u32;
(*table).max_size = (1 << (32 - 5)) as u32;
}
Expand Down
4 changes: 2 additions & 2 deletions fix/shell/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn fixpoint_create_blob_i64(val: u64) -> [u8; 32] {
///
/// [addr] must refer to an unused region of memory which is large enough to fit the blob; there
/// must be no Rust references pointing to this region.
pub unsafe fn fixpoint_attach_blob(addr: *mut c_void, handle: [u8; 32]) -> usize {
pub unsafe fn fixpoint_attach_blob(handle: [u8; 32], addr: *mut c_void) -> usize {
if (!fixpoint_is_blob(handle)) {
arca_log("attach_blob: handle does not refer to a BlobObject");
panic!()
Expand Down Expand Up @@ -65,7 +65,7 @@ pub unsafe fn fixpoint_attach_blob(addr: *mut c_void, handle: [u8; 32]) -> usize
///
/// [addr] must refer to an unused region of memory which is large enough to fit the tree; there
/// must be no Rust references pointing to this region. Each entry of the tree takes 32 bytes.
pub unsafe fn fixpoint_attach_tree(addr: *mut c_void, handle: [u8; 32]) -> usize {
pub unsafe fn fixpoint_attach_tree(handle: [u8; 32], addr: *mut c_void) -> usize {
if (!fixpoint_is_tree(handle)) {
arca_log("attach_tree: handle does not refer to a TreeObject");
panic!()
Expand Down
16 changes: 8 additions & 8 deletions fix/wasm/addblob.wat
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
(module
(import "fixpoint" "create_blob_i64" (func $create_blob_i64 (param i64) (result externref)))
(import "fixpoint" "attach_blob" (func $attach_blob (param i32) (param externref)))
(import "fixpoint" "attach_tree" (func $attach_tree (param i32) (param externref)))
(import "fixpoint" "attach_blob" (func $attach_blob (param externref) (param i32)))
(import "fixpoint" "attach_tree" (func $attach_tree (param externref) (param i32)))
(memory $mem_0 1)
(memory $mem_1 0)
(memory $mem_2 0)
(table $tab_0 0 externref)
(func (export "_fixpoint_apply") (param $encode externref) (result externref)
;; attach combination tree
(call $attach_tree
(i32.const 0)
(local.get $encode))
(local.get $encode)
(i32.const 0))
;; grow rw-memory
(memory.grow
(memory $mem_0)
(i32.const 0))
drop
(call $attach_blob
(i32.const 1)
(table.get $tab_0 (i32.const 1)))
(table.get $tab_0 (i32.const 1))
(i32.const 1))
(call $attach_blob
(i32.const 2)
(table.get $tab_0 (i32.const 2)))
(table.get $tab_0 (i32.const 2))
(i32.const 2))
;; write to rw-memory
(i64.store (memory $mem_0)
(i32.const 0)
Expand Down
24 changes: 12 additions & 12 deletions fix/wasm/coupon/epilogue.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
(if (result i32)
(then
;; Attach the tag
(call $attach_tree (i32.const 1) (local.get $tag))
(call $attach_tree (local.get $tag) (i32.const 1))
;; Check if the tag was authored by us
(call $is_equal (table.get $encode (i32.const 0)) (table.get $coupon_scratch (i32.const 0)))
(if (result i32)
(then
;; Check if the coupon type matches the input type
(call $attach_blob (i32.const 1) (table.get $coupon_scratch (i32.const 1)))
(call $attach_blob (table.get $coupon_scratch (i32.const 1)) (i32.const 1))
(i32.load (memory $mem_1) (i32.const 0))
(local.get $type)
i32.eq
Expand Down Expand Up @@ -62,34 +62,34 @@
(call $create_coupon (global.get $Think) (local.get $lhs) (local.get $rhs))
)
(func $get_coupon_lhs (param $coupon externref) (result externref)
(call $attach_tree (i32.const 1) (local.get $coupon))
(call $attach_tree (local.get $coupon) (i32.const 1))
(table.get $coupon_scratch (i32.const 2))
)
(func $get_coupon_rhs (param $coupon externref) (result externref)
(call $attach_tree (i32.const 1) (local.get $coupon))
(call $attach_tree (local.get $coupon) (i32.const 1))
(table.get $coupon_scratch (i32.const 3))
)
(func $get_tree_size (param $t externref) (result i32)
(call $attach_tree (i32.const 3) (local.get $t))
(call $attach_tree (local.get $t) (i32.const 3))
table.size $tree_scratch
)
(func $get_tree_data (param $t externref) (param $i i32) (result externref)
(call $attach_tree (i32.const 3) (local.get $t))
(call $attach_tree (local.get $t) (i32.const 3))
(table.get $tree_scratch (local.get $i))
)
(func (export "_fixpoint_apply") (param $combination externref) (result externref)
;; attach combination tree
(call $attach_tree
(i32.const 0)
(local.get $combination))
(local.get $combination)
(i32.const 0))
;; attach coupons
(call $attach_tree
(i32.const 2)
(table.get $encode (i32.const 2)))
(table.get $encode (i32.const 2))
(i32.const 2))
;; attach request field
(call $attach_blob
(i32.const 1)
(table.get $encode (i32.const 1)))
(table.get $encode (i32.const 1))
(i32.const 1))
(call $make_coupon
(i32.load $mem_1 (i32.const 0))
(table.get $encode (i32.const 3))
Expand Down
4 changes: 2 additions & 2 deletions fix/wasm/coupon/prologue.wat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(import "fixpoint" "is_equal" (func $is_equal (param externref) (param externref) (result i32)))
(import "fixpoint" "is_tag" (func $is_tag (param externref) (result i32)))
(import "fixpoint" "attach_blob" (func $attach_blob (param i32) (param externref)))
(import "fixpoint" "attach_tree" (func $attach_tree (param i32) (param externref)))
(import "fixpoint" "attach_blob" (func $attach_blob (param externref) (param i32)))
(import "fixpoint" "attach_tree" (func $attach_tree (param externref) (param i32)))
(import "fixpoint" "create_blob_i32" (func $create_blob_i32 (param i32) (result externref)))
(import "fixpoint" "create_tag" (func $create_tag (param i32) (result externref)))
(import "fixpoint" "create_application_thunk" (func $create_application_thunk (param externref) (result externref)))
Expand Down
16 changes: 8 additions & 8 deletions fix/wasm/slowaddblob.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(import "fixpoint" "create_blob_i64"
(func $create_blob_i64 (param i64) (result externref)))
(import "fixpoint" "attach_blob"
(func $attach_blob (param i32) (param externref)))
(func $attach_blob (param externref) (param i32)))
(import "fixpoint" "attach_tree"
(func $attach_tree (param i32) (param externref)))
(func $attach_tree (param externref) (param i32)))

(memory $mem_0 1)
(memory $mem_1 0)
Expand All @@ -22,8 +22,8 @@

;; Attach the combination tree.
(call $attach_tree
(i32.const 0)
(local.get $encode))
(local.get $encode)
(i32.const 0))

;; Grow rw-memory by zero pages, preserving the original behavior.
(memory.grow
Expand All @@ -33,11 +33,11 @@

;; Attach the two input blobs.
(call $attach_blob
(i32.const 1)
(table.get $tab_0 (i32.const 1)))
(table.get $tab_0 (i32.const 1))
(i32.const 1))
(call $attach_blob
(i32.const 2)
(table.get $tab_0 (i32.const 2)))
(table.get $tab_0 (i32.const 2))
(i32.const 2))

;; Load both operands once.
(local.set $left
Expand Down
Loading