| 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 e34c69703fd24f186237a7c4b4ffe0721a9326f1..1b0acb43192fc8ae3e5a3476149fbf552dc76d67 100644
|
| --- a/test/cctest/wasm/test-wasm-stack.cc
|
| +++ b/test/cctest/wasm/test-wasm-stack.cc
|
| @@ -76,6 +76,7 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
|
| TestSignatures sigs;
|
| TestingModule module;
|
|
|
| + // initialize WasmFunctionCompiler first, since it sets up the HandleScope
|
| WasmFunctionCompiler comp1(sigs.v_v(), &module);
|
|
|
| uint32_t jsThrowingIndex = module.AddJsFunction(
|
| @@ -114,3 +115,42 @@ TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) {
|
| {"callFn", 1}};
|
| CheckExceptionInfos(isolate, excMaybe.ToHandleChecked(), expectedExceptions);
|
| }
|
| +
|
| +// Trigger a trap in WASM, stack should be JS -> WASM -> WASM
|
| +TEST(CollectDetailedWasmStack_WasmError) {
|
| + TestSignatures sigs;
|
| + TestingModule module;
|
| +
|
| + WasmFunctionCompiler comp1(sigs.i_v(), &module, "exec_unreachable");
|
| + // set the execution context, such that a runtime error can be thrown
|
| + comp1.SetModuleContext();
|
| + BUILD(comp1, WASM_UNREACHABLE);
|
| + uint32_t wasmIndex = comp1.CompileAndAdd();
|
| +
|
| + WasmFunctionCompiler comp2(sigs.i_v(), &module, "call_exec_unreachable");
|
| + BUILD(comp2, WASM_CALL_FUNCTION0(wasmIndex));
|
| + uint32_t wasmIndex2 = comp2.CompileAndAdd();
|
| +
|
| + Handle<JSFunction> jsWasmWrapper = module.WrapCode(wasmIndex2);
|
| +
|
| + Handle<JSFunction> jsTrampoline = Handle<JSFunction>::cast(
|
| + v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
|
| + CompileRun("(function callFn(fn) { fn(); })"))));
|
| +
|
| + Isolate* isolate = jsWasmWrapper->GetIsolate();
|
| + isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10,
|
| + v8::StackTrace::kOverview);
|
| + Handle<Object> global(isolate->context()->global_object(), isolate);
|
| + MaybeHandle<Object> excMaybe;
|
| + Handle<Object> args[] = {jsWasmWrapper};
|
| + MaybeHandle<Object> returnObjMaybe =
|
| + Execution::TryCall(isolate, jsTrampoline, global, 1, args, &excMaybe);
|
| + CHECK(returnObjMaybe.is_null());
|
| +
|
| + // line number is 1-based, with 0 == kNoLineNumberInfo
|
| + ExceptionInfo expectedExceptions[] = {
|
| + {"<WASM>", 0}, // comment to prevent clang-format complaints
|
| + {"<WASM>", 0}, // -
|
| + {"callFn", 1}};
|
| + CheckExceptionInfos(isolate, excMaybe.ToHandleChecked(), expectedExceptions);
|
| +}
|
|
|