Bug 1541404 part 18 - Various minor changes for debugger support. r=tcampbell

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-05-02 08:38:06 +00:00
parent bcc7eeb6bd
commit 5e3db1106f
5 changed files with 48 additions and 19 deletions

View File

@ -166,7 +166,11 @@ static bool CollectJitStackScripts(JSContext* cx,
break;
}
// Baseline Interpreter frames don't need recompilation.
BaselineFrame* baselineFrame = frame.baselineFrame();
if (baselineFrame->runningInInterpreter()) {
break;
}
if (BaselineDebugModeOSRInfo* info =
baselineFrame->getDebugModeOSRInfo()) {
@ -358,6 +362,12 @@ static void PatchBaselineFramesForDebugMode(
break;
}
// Baseline Interpreter frames don't need recompilation.
BaselineFrame* baselineFrame = frame.baselineFrame();
if (baselineFrame->runningInInterpreter()) {
break;
}
DebugModeOSREntry& entry = entries[entryIndex];
if (!entry.recompiled()) {

View File

@ -136,14 +136,15 @@ bool BaselineFrame::initForOsr(InterpreterFrame* fp, uint32_t numStackValues) {
JSContext* cx =
fp->script()->runtimeFromMainThread()->mainContextFromOwnThread();
Activation* interpActivation = cx->activation()->prev();
jsbytecode* pc = interpActivation->asInterpreter()->regs().pc;
MOZ_ASSERT(fp->script()->containsPC(pc));
if (!fp->script()->hasBaselineScript()) {
// If we don't have a BaselineScript, we are doing OSR into the Baseline
// Interpreter. Initialize Baseline Interpreter fields. We can get the pc
// from the C++ interpreter's activation, we just have to skip the
// JitActivation.
Activation* interpActivation = cx->activation()->prev();
jsbytecode* pc = interpActivation->asInterpreter()->regs().pc;
MOZ_ASSERT(fp->script()->containsPC(pc));
flags_ |= BaselineFrame::RUNNING_IN_INTERPRETER;
interpreterScript_ = fp->script();
setInterpreterPC(pc);
@ -162,21 +163,16 @@ bool BaselineFrame::initForOsr(InterpreterFrame* fp, uint32_t numStackValues) {
// For debuggee frames, update any Debugger.Frame objects for the
// InterpreterFrame to point to the BaselineFrame.
// The caller pushed a fake return address. ScriptFrameIter, used by the
// debugger, wants a valid return address, but it's okay to just pick one.
// In debug mode there's always at least one RetAddrEntry (since there are
// always debug prologue/epilogue calls).
JSJitFrameIter frame(cx->activation()->asJit());
MOZ_ASSERT(frame.returnAddress() == nullptr);
BaselineScript* baseline = fp->script()->baselineScript();
uint8_t* retAddr =
baseline->returnAddressForEntry(baseline->retAddrEntry(0));
frame.current()->setReturnAddress(retAddr);
// The caller pushed a fake (nullptr) return address, so ScriptFrameIter
// can't use it to determine the frame's bytecode pc. Set an override pc so
// frame iteration can use that.
setOverridePc(pc);
if (!Debugger::handleBaselineOsr(cx, fp, this)) {
return false;
}
clearOverridePc();
setIsDebuggee();
}

View File

@ -1122,9 +1122,13 @@ bool HandleDebugTrap(JSContext* cx, BaselineFrame* frame, uint8_t* retAddr,
*mustReturn = false;
RootedScript script(cx, frame->script());
jsbytecode* pc =
script->baselineScript()->retAddrEntryFromReturnAddress(retAddr).pc(
script);
jsbytecode* pc;
if (frame->runningInInterpreter()) {
pc = frame->interpreterPC();
} else {
BaselineScript* blScript = script->baselineScript();
pc = blScript->retAddrEntryFromReturnAddress(retAddr).pc(script);
}
if (*pc == JSOP_AFTERYIELD) {
// JSOP_AFTERYIELD will set the frame's debuggee flag and call the
@ -1141,7 +1145,15 @@ bool HandleDebugTrap(JSContext* cx, BaselineFrame* frame, uint8_t* retAddr,
}
MOZ_ASSERT(frame->isDebuggee());
MOZ_ASSERT(script->stepModeEnabled() || script->hasBreakpointsAt(pc));
// The Baseline Interpreter calls HandleDebugTrap for every op when the script
// is in step mode or has breakpoints. The Baseline Compiler can toggle
// breakpoints more granularly for specific bytecode PCs.
if (frame->runningInInterpreter()) {
MOZ_ASSERT(script->hasAnyBreakpointsOrStepMode());
} else {
MOZ_ASSERT(script->stepModeEnabled() || script->hasBreakpointsAt(pc));
}
RootedValue rval(cx);
ResumeMode resumeMode = ResumeMode::Continue;

View File

@ -51,6 +51,7 @@
#include "wasm/WasmInstance.h"
#include "gc/GC-inl.h"
#include "jit/JSJitFrameIter-inl.h"
#include "vm/BytecodeUtil-inl.h"
#include "vm/Compartment-inl.h"
#include "vm/GeckoProfiler-inl.h"
@ -2924,7 +2925,15 @@ static bool UpdateExecutionObservabilityOfScriptsInZone(
const JSJitFrameIter& frame = iter.frame();
switch (frame.type()) {
case FrameType::BaselineJS:
MarkTypeScriptActiveIfObservable(frame.script(), obs);
// BaselineScripts that are active on the stack get recompiled and
// other (affected) BaselineScripts are discarded. If we're running in
// the Baseline Interpreter don't mark the script as active here to
// prevent BaselineScripts from falling through the cracks: when we
// don't dicard them here (because active) and also don't recompile
// them (because recompilation skips interpreter frames).
if (!frame.baselineFrame()->runningInInterpreter()) {
MarkTypeScriptActiveIfObservable(frame.script(), obs);
}
break;
case FrameType::IonJS:
MarkTypeScriptActiveIfObservable(frame.script(), obs);

View File

@ -1970,8 +1970,10 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
script->incWarmUpCounter();
using Tier = jit::BaselineTier;
bool tryBaselineInterpreter = (jit::JitOptions.baselineInterpreter &&
!script->hasBaselineScript());
jit::MethodStatus status =
jit::JitOptions.baselineInterpreter
tryBaselineInterpreter
? jit::CanEnterBaselineAtBranch<Tier::Interpreter>(cx,
REGS.fp())
: jit::CanEnterBaselineAtBranch<Tier::Compiler>(cx, REGS.fp());