Skip to content

Commit 9495e79

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[wasm] Don't catch uncatchable exceptions in the JSPI wrapper
... And forward the exception to the parent stack instead. [email protected] Fixed: 361717714 Change-Id: I7c6a75b53bc7732546ec6a7a1425ac50b9b1756b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5817264 Commit-Queue: Thibaud Michaud <[email protected]> Reviewed-by: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/main@{#95847}
1 parent 20a2ad7 commit 9495e79

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

src/execution/isolate.cc

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)