Index: test/cctest/wasm/test-wasm-stack.cc |
diff --git a/test/cctest/wasm/test-wasm-stack.cc b/test/cctest/wasm/test-wasm-stack.cc |
index fdd969b354c751b00a0ea8f3bb3252e2723b6beb..a0c2e73f9d1e1d72ccb5b8a51185ebe6e89ca02f 100644 |
--- a/test/cctest/wasm/test-wasm-stack.cc |
+++ b/test/cctest/wasm/test-wasm-stack.cc |
@@ -76,22 +76,25 @@ |
// Call from JS to WASM to JS and throw an Error from JS. |
TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { |
- WasmRunner<void> r(kExecuteCompiled); |
TestSignatures sigs; |
+ TestingModule module; |
- uint32_t js_throwing_index = r.module().AddJsFunction( |
+ // Initialize WasmFunctionCompiler first, since it sets up the HandleScope. |
+ WasmFunctionCompiler comp1(sigs.v_v(), &module); |
+ |
+ uint32_t js_throwing_index = module.AddJsFunction( |
sigs.v_v(), |
"(function js() {\n function a() {\n throw new Error(); };\n a(); })"); |
// Add a nop such that we don't always get position 1. |
- BUILD(r, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index)); |
- uint32_t wasm_index_1 = r.function()->func_index; |
+ BUILD(comp1, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index)); |
+ uint32_t wasm_index = comp1.CompileAndAdd(); |
- WasmFunctionCompiler& f2 = r.NewFunction<void>(); |
- BUILD(f2, WASM_CALL_FUNCTION0(wasm_index_1)); |
- uint32_t wasm_index_2 = f2.function_index(); |
+ WasmFunctionCompiler comp2(sigs.v_v(), &module); |
+ BUILD(comp2, WASM_CALL_FUNCTION0(wasm_index)); |
+ uint32_t wasm_index_2 = comp2.CompileAndAdd(); |
- Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index_2); |
+ Handle<JSFunction> js_wasm_wrapper = module.WrapCode(wasm_index_2); |
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( |
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
@@ -111,7 +114,7 @@ |
ExceptionInfo expected_exceptions[] = { |
{"a", 3, 8}, // - |
{"js", 4, 2}, // - |
- {"<WASM UNNAMED>", static_cast<int>(wasm_index_1) + 1, 3}, // - |
+ {"<WASM UNNAMED>", static_cast<int>(wasm_index) + 1, 3}, // - |
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2) + 1, 2}, // - |
{"callFn", 1, 24} // - |
}; |
@@ -121,18 +124,21 @@ |
// Trigger a trap in WASM, stack should be JS -> WASM -> WASM. |
TEST(CollectDetailedWasmStack_WasmError) { |
TestSignatures sigs; |
- WasmRunner<int> r(kExecuteCompiled); |
+ TestingModule module; |
+ |
+ WasmFunctionCompiler comp1(sigs.i_v(), &module, |
+ ArrayVector("exec_unreachable")); |
// Set the execution context, such that a runtime error can be thrown. |
- r.SetModuleContext(); |
+ comp1.SetModuleContext(); |
+ BUILD(comp1, WASM_UNREACHABLE); |
+ uint32_t wasm_index = comp1.CompileAndAdd(); |
- BUILD(r, WASM_UNREACHABLE); |
- uint32_t wasm_index_1 = r.function()->func_index; |
+ WasmFunctionCompiler comp2(sigs.i_v(), &module, |
+ ArrayVector("call_exec_unreachable")); |
+ BUILD(comp2, WASM_CALL_FUNCTION0(wasm_index)); |
+ uint32_t wasm_index_2 = comp2.CompileAndAdd(); |
- WasmFunctionCompiler& f2 = r.NewFunction<int>(); |
- BUILD(f2, WASM_CALL_FUNCTION0(0)); |
- uint32_t wasm_index_2 = f2.function_index(); |
- |
- Handle<JSFunction> js_wasm_wrapper = r.module().WrapCode(wasm_index_2); |
+ Handle<JSFunction> js_wasm_wrapper = module.WrapCode(wasm_index_2); |
Handle<JSFunction> js_trampoline = Handle<JSFunction>::cast( |
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
@@ -150,7 +156,7 @@ |
// Line and column are 1-based, so add 1 for the expected wasm output. |
ExceptionInfo expected_exceptions[] = { |
- {"<WASM UNNAMED>", static_cast<int>(wasm_index_1) + 1, 2}, // - |
+ {"<WASM UNNAMED>", static_cast<int>(wasm_index) + 1, 2}, // - |
{"<WASM UNNAMED>", static_cast<int>(wasm_index_2) + 1, 2}, // - |
{"callFn", 1, 24} //- |
}; |