tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9383bc69f7497336f6cdb4739ff80d3aa4b2d1e3
parent a48c7813a3ef97b25731205732d77e20d269f8b3
Author: Ryan Hunt <rhunt@eqrion.net>
Date:   Thu, 18 Dec 2025 16:45:29 +0000

Bug 2002625 - wasm: Dynamically switch to main stack in debug stub. r=yury

Use the infrastructure added for builtin thunks.

Differential Revision: https://phabricator.services.mozilla.com/D274195

Diffstat:
Mjs/src/wasm/WasmBuiltins.cpp | 15++++++++-------
Mjs/src/wasm/WasmStubs.cpp | 4++--
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/js/src/wasm/WasmBuiltins.cpp b/js/src/wasm/WasmBuiltins.cpp @@ -553,6 +553,9 @@ static bool WasmHandleDebugTrap() { Instance* instance = GetNearestEffectiveInstance(fp); const Code& code = instance->code(); MOZ_ASSERT(code.debugEnabled()); +#ifdef ENABLE_WASM_JSPI + MOZ_ASSERT(!cx->wasm().onSuspendableStack()); +#endif // The debug trap stub is the innermost frame. It's return address is the // actual trap site. @@ -569,8 +572,7 @@ static bool WasmHandleDebugTrap() { } debugFrame->setIsDebuggee(); debugFrame->observe(cx); - if (!ForwardToMainStack(DebugAPI::onEnterFrame, cx, - js::AbstractFramePtr(debugFrame))) { + if (!DebugAPI::onEnterFrame(cx, js::AbstractFramePtr(debugFrame))) { if (cx->isPropagatingForcedReturn()) { cx->clearPropagatingForcedReturn(); // Ignoring forced return because changing code execution order is @@ -592,9 +594,8 @@ static bool WasmHandleDebugTrap() { if (site.kind() == CallSiteKind::CollapseFrame) { debugFrame->discardReturnJSValue(); } - bool ok = ForwardToMainStack(DebugAPI::onLeaveFrame, cx, - js::AbstractFramePtr(debugFrame), - (const jsbytecode*)nullptr, true); + bool ok = DebugAPI::onLeaveFrame(cx, js::AbstractFramePtr(debugFrame), + (const jsbytecode*)nullptr, true); debugFrame->leave(cx); return ok; } @@ -602,7 +603,7 @@ static bool WasmHandleDebugTrap() { DebugState& debug = instance->debug(); MOZ_ASSERT(debug.hasBreakpointTrapAtOffset(site.lineOrBytecode())); if (debug.stepModeEnabled(debugFrame->funcIndex())) { - if (!ForwardToMainStack(DebugAPI::onSingleStep, cx)) { + if (!DebugAPI::onSingleStep(cx)) { if (cx->isPropagatingForcedReturn()) { cx->clearPropagatingForcedReturn(); // TODO properly handle forced return. @@ -613,7 +614,7 @@ static bool WasmHandleDebugTrap() { } } if (debug.hasBreakpointSite(site.lineOrBytecode())) { - if (!ForwardToMainStack(DebugAPI::onTrap, cx)) { + if (!DebugAPI::onTrap(cx)) { if (cx->isPropagatingForcedReturn()) { cx->clearPropagatingForcedReturn(); // TODO properly handle forced return. diff --git a/js/src/wasm/WasmStubs.cpp b/js/src/wasm/WasmStubs.cpp @@ -2878,7 +2878,7 @@ static bool GenerateDebugStub(MacroAssembler& masm, Label* throwLabel, masm.setFramePushed(0); GenerateExitPrologue(masm, ExitReason::Fixed::DebugStub, - /*switchToMainStack*/ false, 0, 0, offsets); + /*switchToMainStack*/ true, 0, 0, offsets); uint32_t framePushed = masm.framePushed(); @@ -2914,7 +2914,7 @@ static bool GenerateDebugStub(MacroAssembler& masm, Label* throwLabel, masm.setFramePushed(framePushed); GenerateExitEpilogue(masm, ExitReason::Fixed::DebugStub, - /*switchToMainStack*/ false, offsets); + /*switchToMainStack*/ true, offsets); return FinishOffsets(masm, offsets); }