Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a failed test case(tribonacci) #52

Closed
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
13 changes: 13 additions & 0 deletions benchmarks/wasm/tribonacci.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[no_mangle]
#[inline(never)]
fn tribonacci(n: i32) -> i32 {
if n == 0 { 0 }
else if n == 1 { 1 }
else if n == 2 { 1 }
else { tribonacci(n - 1) + tribonacci(n - 2) + tribonacci(n - 3) }
}

#[no_mangle]
fn real_main() -> i32 {
tribonacci(12)
}
68 changes: 68 additions & 0 deletions benchmarks/wasm/tribonacci.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(module
(type (;0;) (func (param i32) (result i32)))
(type (;1;) (func (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
(local i32 i32)
local.get 0
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.gt_u
br_if 0 (;@2;)
local.get 1
i32.load
local.get 2
i32.add
return
end
local.get 1
i32.const -12
i32.add
local.set 1
local.get 0
i32.const -1
i32.add
call 0
local.get 0
i32.const -2
i32.add
call 0
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)
i32.const 12
call 0)
(start 1)
(table (;0;) 1 1 funcref)
(memory (;0;) 17)
(global (;0;) (mut i32) (i32.const 1048576))
(global (;1;) i32 (i32.const 1048588))
(global (;2;) i32 (i32.const 1048592))
(export "memory" (memory 0))
(export "tribonacci" (func 0))
(export "real_main" (func 1))
(export "__data_end" (global 1))
(export "__heap_base" (global 2)))
1 change: 1 addition & 0 deletions src/test/scala/genwasym/TestEval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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)) }

// TODO: add wasm spec tests? How to utilize wast files?
}
Loading