mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 19:09:49 +00:00
Bug 1551176: Clean up js::DebugScript and step mode count. r=jorendorff
The present JSScript::setNewStepMode method deals with both increments and decrements. This provides a single site from which to call BaselineScript::toggleDebugTraps. But it also checks whether it should free the DebugScript, which is only needed when we're decrementing, and requires incrementStepModeCount to furnish a FreeOp which is never needed. On the balance, removing setNewStepMode altogether and letting JSScript::incrementStepModeCount and decrementStepModeCount each specialize in building things up or tearing things down seems cleaner, even if both need to call toggleDebugTraps. Differential Revision: https://phabricator.services.mozilla.com/D32268 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0bdeae4db0
commit
2206c1191d
@ -4733,22 +4733,6 @@ DebugScript* JSScript::getOrCreateDebugScript(JSContext* cx) {
|
||||
return borrowed;
|
||||
}
|
||||
|
||||
void JSScript::setNewStepMode(FreeOp* fop, uint32_t newValue) {
|
||||
DebugScript* debug = debugScript();
|
||||
uint32_t prior = debug->stepMode;
|
||||
debug->stepMode = newValue;
|
||||
|
||||
if (!prior != !newValue) {
|
||||
if (hasBaselineScript()) {
|
||||
baseline->toggleDebugTraps(this, nullptr);
|
||||
}
|
||||
|
||||
if (!debug->needed()) {
|
||||
fop->free_(releaseDebugScript());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool JSScript::incrementStepModeCount(JSContext* cx) {
|
||||
cx->check(this);
|
||||
MOZ_ASSERT(cx->realm()->isDebuggee());
|
||||
@ -4760,16 +4744,33 @@ bool JSScript::incrementStepModeCount(JSContext* cx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t count = debug->stepMode;
|
||||
setNewStepMode(cx->runtime()->defaultFreeOp(), count + 1);
|
||||
debug->stepMode++;
|
||||
|
||||
if (debug->stepMode == 1) {
|
||||
if (hasBaselineScript()) {
|
||||
baseline->toggleDebugTraps(this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSScript::decrementStepModeCount(FreeOp* fop) {
|
||||
DebugScript* debug = debugScript();
|
||||
uint32_t count = debug->stepMode;
|
||||
MOZ_ASSERT(count > 0);
|
||||
setNewStepMode(fop, count - 1);
|
||||
MOZ_ASSERT(debug);
|
||||
MOZ_ASSERT(debug->stepMode > 0);
|
||||
|
||||
debug->stepMode--;
|
||||
|
||||
if (debug->stepMode == 0) {
|
||||
if (hasBaselineScript()) {
|
||||
baseline->toggleDebugTraps(this, nullptr);
|
||||
}
|
||||
|
||||
if (!debug->needed()) {
|
||||
fop->free_(releaseDebugScript());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BreakpointSite* JSScript::getOrCreateBreakpointSite(JSContext* cx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user