Skip to content

Commit

Permalink
hook for 2o1u
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuoguo committed Oct 2, 2024
1 parent c47501c commit 8626512
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 7 additions & 3 deletions benchmarks/wasm/btree/2o1u.wat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(module
(import "env" "log" (func $log (param i32)))
(memory $0 2)
(func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree
(i32.const 0)
Expand Down Expand Up @@ -519,14 +520,17 @@
)
)
;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert
(func $btreeInsertNonFull (param i32) (param i32) (local i32)
(func $btreeInsertNonFull (param i32) (param i32) (local i32) (local $tmp i32)
(local.get 0) ;; x
(i32.load offset=4) ;; x.n
(i32.const 1)
(i32.sub) ;; x.n -1
(local.set 2) ;; i = x.n -1
(local.get 0) ;; x
(i32.load) ;; get first i32 --> isLeaf
(local.tee $tmp)
(local.get $tmp)
(call $log)
(i32.const 1)
(i32.eq) ;; is leaf?
(if
Expand Down Expand Up @@ -2811,11 +2815,11 @@
)
(export "main" (func $main))
(func $real_main
i32.const 1
i32.const 3
i32.const 2
i32.const 1
call $main
)
(start $real_main)
(start $real_main)
(export "real_main" (func $real_main))
)
19 changes: 19 additions & 0 deletions benchmarks/wasm/btree/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require("fs");

async function main() {
const bytes = fs.readFileSync("2o1u.wasm");
const env = { log: val => console.log(`logged ${val}`), };
const { instance } = await WebAssembly.instantiate(
bytes,
{
env: {
log(val) {
console.log(`log saw ${val}`);
}
}
}
);
instance.exports.real_main();
console.log(`finished`);
}
main();

0 comments on commit 8626512

Please sign in to comment.