diff --git a/benchmarks/wasm/return_call.wat b/benchmarks/wasm/return_call.wat new file mode 100644 index 000000000..a78a885c0 --- /dev/null +++ b/benchmarks/wasm/return_call.wat @@ -0,0 +1,33 @@ +(module + (type (;0;) (func (param i64) (result i32))) + (type (;1;) (func)) + (func (;0;) (type 0) (param i64) (result i32) + local.get 0 + i64.eqz + if (result i32) ;; label = @1 + i32.const 44 + else + local.get 0 + i64.const 1 + i64.sub + return_call 1 + end + ) + (func (;1;) (type 0) (param i64) (result i32) + local.get 0 + i64.eqz + if (result i32) ;; label = @1 + i32.const 99 + else + local.get 0 + i64.const 1 + i64.sub + return_call 0 + end + ) + (func (;2;) (type 1) + i64.const 100000 + call 0 + ) + (start 2) +) \ No newline at end of file diff --git a/src/main/scala/wasm/MiniWasmScript.scala b/src/main/scala/wasm/MiniWasmScript.scala index 8d27c7327..42dd63bb5 100644 --- a/src/main/scala/wasm/MiniWasmScript.scala +++ b/src/main/scala/wasm/MiniWasmScript.scala @@ -46,6 +46,7 @@ sealed class ScriptRunner { cmd match { case CmdModule(module) => instances += ModuleInstance(module) case AssertReturn(action, expect) => assertReturn(action, expect) + case AssertInvalid() => () case CMdInstnace() => () case AssertTrap(action, message) => ??? } diff --git a/src/main/scala/wasm/Parser.scala b/src/main/scala/wasm/Parser.scala index ac277abd1..70486408e 100644 --- a/src/main/scala/wasm/Parser.scala +++ b/src/main/scala/wasm/Parser.scala @@ -804,7 +804,7 @@ class GSWasmVisitor extends WatParserBaseVisitor[WIR] { } AssertReturn(action, expect.toList) } else if (ctx.ASSERT_INVALID != null ) { - // we simply ignore assert_invalid for now + // TODO: we simply ignore assert_invalid for now AssertInvalid() } else { throw new RuntimeException("Unsupported") diff --git a/src/test/scala/genwasym/TestTFP.scala b/src/test/scala/genwasym/TestTFP.scala index 011700c79..2646dae87 100644 --- a/src/test/scala/genwasym/TestTFP.scala +++ b/src/test/scala/genwasym/TestTFP.scala @@ -168,9 +168,12 @@ class TestTFP extends FunSuite { testWastFile("./benchmarks/wasm/spectest/return_call.bin.wast") } - // one of the failing test cases + // some of the failing test cases test("count") { testFile("./benchmarks/wasm/count.wat", None, ExpInt(0)) } + test("even_odd") { + testFile("./benchmarks/wasm/return_call.wat", None, ExpInt(44)) + } }