Chromium Code Reviews| Index: test/cctest/wasm/test-run-wasm.cc |
| diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc |
| index d9d9db80e15e54a9cbe947d96ee9187b9ea82fea..021a4a7033d5a0fea19620c3fa340ed20ca91fd4 100644 |
| --- a/test/cctest/wasm/test-run-wasm.cc |
| +++ b/test/cctest/wasm/test-run-wasm.cc |
| @@ -2632,6 +2632,45 @@ WASM_EXEC_TEST(CallIndirect_NoTable) { |
| CHECK_TRAP(r.Call(2)); |
| } |
| +WASM_EXEC_TEST(CallIndirect_canonical) { |
| + TestSignatures sigs; |
| + TestingModule module(execution_mode); |
| + |
| + WasmFunctionCompiler t1(sigs.i_ii(), &module); |
| + BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| + t1.CompileAndAdd(/*sig_index*/ 0); |
| + |
| + WasmFunctionCompiler t2(sigs.i_ii(), &module); |
| + BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| + t2.CompileAndAdd(/*sig_index*/ 1); |
| + |
| + WasmFunctionCompiler t3(sigs.f_ff(), &module); |
| + BUILD(t3, WASM_F32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| + t3.CompileAndAdd(/*sig_index*/ 2); |
| + |
| + // Signature table. |
| + module.AddSignature(sigs.i_ii()); |
| + module.AddSignature(sigs.i_ii()); |
| + module.AddSignature(sigs.f_ff()); |
| + |
| + // Function table. |
| + uint16_t indirect_function_table[] = {0, 1, 2, 0, 1}; |
| + module.AddIndirectFunctionTable(indirect_function_table, |
| + arraysize(indirect_function_table)); |
| + module.PopulateIndirectFunctionTable(); |
| + |
| + // Builder the caller function. |
| + WasmRunner<int32_t> r(&module, MachineType::Int32()); |
| + BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(77), WASM_I8(11))); |
| + |
| + CHECK_EQ(88, r.Call(0)); |
|
ahaas
2016/10/11 09:20:09
Also here, could you use t*.function_index()?
titzer
2016/10/11 11:58:31
Done.
|
| + CHECK_EQ(66, r.Call(1)); |
| + CHECK_TRAP(r.Call(2)); |
| + CHECK_EQ(88, r.Call(3)); |
| + CHECK_EQ(66, r.Call(4)); |
| + CHECK_TRAP(r.Call(5)); |
| +} |
| + |
| WASM_EXEC_TEST(F32Floor) { |
| WasmRunner<float> r(execution_mode, MachineType::Float32()); |
| BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0))); |