Skip to content

Commit

Permalink
use rust compiled tribonacci.wat(a data section involved)
Browse files Browse the repository at this point in the history
  • Loading branch information
butterunderflow committed Oct 10, 2024
1 parent a7b1749 commit e0c967d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 36 deletions.
95 changes: 60 additions & 35 deletions benchmarks/wasm/tribonacci.wat
Original file line number Diff line number Diff line change
@@ -1,43 +1,68 @@
(module
(module $tribonacci.wat.temp
(type (;0;) (func (param i32) (result i32)))
(type (;1;) (func (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
(func $tribonacci (type 0) (param i32) (result i32)
(local i32 i32)
local.get 0
if (result i32) ;; label = @1
local.get 0
i32.const 1
i32.eq
if (result i32) ;; label = @2
i32.const 1
else
i32.const 2
i32.shl
i32.const 1048576
i32.add
local.set 1
i32.const 0
local.set 2
local.get 0
local.set 0
loop (result i32) ;; label = @1
local.get 2
local.set 2
local.get 1
local.set 1
block ;; label = @2
local.get 0
local.tee 0
i32.const 2
i32.eq
if (result i32) ;; label = @3
i32.const 1
else
local.get 0
i32.const 1
i32.sub
call 0
local.get 0
i32.const 2
i32.sub
call 0
i32.add
local.get 0
i32.const 3
i32.sub
call 0
i32.add
end
i32.gt_u
br_if 0 (;@2;)
local.get 1
i32.load
local.get 2
i32.add
return
end
else
i32.const 0
local.get 1
i32.const -12
i32.add
local.set 1
local.get 0
i32.const -1
i32.add
call $tribonacci
local.get 0
i32.const -2
i32.add
call $tribonacci
i32.add
local.get 2
i32.add
local.set 2
local.get 0
i32.const -3
i32.add
local.set 0
br 0 (;@1;)
end)
(func (;1;) (type 1) (result i32)
(func $real_main (type 1) (result i32)
i32.const 12
call 0)
(start 1)
(memory (;0;) 0)
(export "memory" (memory 0)))
call $tribonacci)
(table (;0;) 1 1 funcref)
(memory (;0;) 17)
(global $__stack_pointer (mut i32) (i32.const 1048576))
(global (;1;) i32 (i32.const 1048588))
(global (;2;) i32 (i32.const 1048592))
(export "memory" (memory 0))
(export "tribonacci" (func $tribonacci))
(export "real_main" (func $real_main))
(export "__data_end" (global 1))
(export "__heap_base" (global 2))
(data $.rodata (i32.const 1048576) "\00\00\00\00\01\00\00\00\01\00\00\00"))
2 changes: 1 addition & 1 deletion src/test/scala/genwasym/TestEval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TestEval extends FunSuite {
test("load") { testFile("./benchmarks/wasm/load.wat", None, Some(1)) }
test("btree") { testFile("./benchmarks/wasm/btree/2o1u-unlabeled.wat") }
test("fib") { testFile("./benchmarks/wasm/fib.wat", None, Some(144)) }
test("tribonacci") { testFile("./benchmarks/wasm/tribonacci.wat", None, Some(504)) }
test("tribonacci") { testFile("./benchmarks/wasm/tribonacci.wat", Some("$real_main"), Some(504)) }

test("return") {
intercept[gensym.wasm.miniwasm.Trap] {
Expand Down

0 comments on commit e0c967d

Please sign in to comment.