@@ -2192,6 +2192,12 @@ Tagged<Object> Isolate::UnwindAndFindHandler() {
21922192 }
21932193 }
21942194 };
2195+
2196+ Tagged<Object> maybe_continuation = root (RootIndex::kActiveContinuation );
2197+ Tagged<WasmContinuationObject> continuation;
2198+ if (!IsUndefined (maybe_continuation)) {
2199+ continuation = Cast<WasmContinuationObject>(maybe_continuation);
2200+ }
21952201#endif
21962202
21972203 // Special handling of termination exceptions, uncatchable by JavaScript and
@@ -2212,15 +2218,25 @@ Tagged<Object> Isolate::UnwindAndFindHandler() {
22122218 for (StackFrameIterator iter (this );; iter.Advance (), visited_frames++) {
22132219#if V8_ENABLE_WEBASSEMBLY
22142220 if (iter.frame ()->type () == StackFrame::STACK_SWITCH) {
2215- Tagged<Code> code =
2216- builtins ()->code (Builtin::kWasmReturnPromiseOnSuspendAsm );
2217- HandlerTable table (code);
2218- Address instruction_start =
2219- code->InstructionStart (this , iter.frame ()->pc ());
2220- int handler_offset = table.LookupReturn (0 );
2221- return FoundHandler (Context (), instruction_start, handler_offset,
2222- kNullAddress , iter.frame ()->sp (), iter.frame ()->fp (),
2223- visited_frames);
2221+ if (catchable_by_js) {
2222+ Tagged<Code> code =
2223+ builtins ()->code (Builtin::kWasmReturnPromiseOnSuspendAsm );
2224+ HandlerTable table (code);
2225+ Address instruction_start =
2226+ code->InstructionStart (this , iter.frame ()->pc ());
2227+ int handler_offset = table.LookupReturn (0 );
2228+ return FoundHandler (Context (), instruction_start, handler_offset,
2229+ kNullAddress , iter.frame ()->sp (),
2230+ iter.frame ()->fp (), visited_frames);
2231+ } else {
2232+ // We reached the base of the wasm stack. Follow the chain of
2233+ // continuations to find the parent stack and reset the iterator.
2234+ DCHECK (!continuation.is_null ());
2235+ continuation = Cast<WasmContinuationObject>(continuation->parent ());
2236+ wasm::StackMemory* stack =
2237+ reinterpret_cast <wasm::StackMemory*>(continuation->stack ());
2238+ iter.Reset (thread_local_top (), stack);
2239+ }
22242240 }
22252241#endif
22262242 // Handler must exist.
0 commit comments