Bug 1647342 - Part 4: Convert forEachDebuggerFrame helper to expose Debugger*. r=arai

This is just a tiny refactor to avoid needing to then get the Debugger* from
the frame when we already know it.

Differential Revision: https://phabricator.services.mozilla.com/D80737
This commit is contained in:
Logan Smyth 2020-06-30 17:44:11 +00:00
Родитель 0633ec4299
Коммит 4427fef93d
2 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -1175,25 +1175,26 @@ bool DebugAPI::slowPathOnNewGenerator(JSContext* cx, AbstractFramePtr frame,
// AbstractGeneratorObject for this generator call, though, has just been
// created. It must be associated with any existing Debugger.Frames.
bool ok = true;
Debugger::forEachDebuggerFrame(frame, [&](DebuggerFrame* frameObjPtr) {
if (!ok) {
return;
}
Debugger::forEachDebuggerFrame(
frame, [&](Debugger*, DebuggerFrame* frameObjPtr) {
if (!ok) {
return;
}
RootedDebuggerFrame frameObj(cx, frameObjPtr);
{
AutoRealm ar(cx, frameObj);
RootedDebuggerFrame frameObj(cx, frameObjPtr);
{
AutoRealm ar(cx, frameObj);
if (!frameObj->setGeneratorInfo(cx, genObj)) {
ReportOutOfMemory(cx);
if (!frameObj->setGeneratorInfo(cx, genObj)) {
ReportOutOfMemory(cx);
// This leaves `genObj` and `frameObj` unassociated. It's OK
// because we won't pause again with this generator on the stack:
// the caller will immediately discard `genObj` and unwind `frame`.
ok = false;
}
}
});
// This leaves `genObj` and `frameObj` unassociated. It's OK
// because we won't pause again with this generator on the stack:
// the caller will immediately discard `genObj` and unwind `frame`.
ok = false;
}
}
});
return ok;
}
@ -3215,7 +3216,7 @@ void Debugger::forEachDebuggerFrame(AbstractFramePtr frame, FrameFn fn) {
for (Realm::DebuggerVectorEntry& entry : frame.global()->getDebuggers()) {
Debugger* dbg = entry.dbg;
if (FrameMap::Ptr frameEntry = dbg->frames.lookup(frame)) {
fn(frameEntry->value());
fn(dbg, frameEntry->value());
}
}
}
@ -3224,7 +3225,7 @@ void Debugger::forEachDebuggerFrame(AbstractFramePtr frame, FrameFn fn) {
bool Debugger::getDebuggerFrames(AbstractFramePtr frame,
MutableHandle<DebuggerFrameVector> frames) {
bool hadOOM = false;
forEachDebuggerFrame(frame, [&](DebuggerFrame* frameobj) {
forEachDebuggerFrame(frame, [&](Debugger*, DebuggerFrame* frameobj) {
if (!hadOOM && !frames.append(frameobj)) {
hadOOM = true;
}
@ -6292,7 +6293,7 @@ bool Debugger::replaceFrameGuts(JSContext* cx, AbstractFramePtr from,
bool DebugAPI::inFrameMaps(AbstractFramePtr frame) {
bool foundAny = false;
Debugger::forEachDebuggerFrame(
frame, [&](DebuggerFrame* frameobj) { foundAny = true; });
frame, [&](Debugger*, DebuggerFrame* frameobj) { foundAny = true; });
return foundAny;
}
@ -6300,11 +6301,10 @@ bool DebugAPI::inFrameMaps(AbstractFramePtr frame) {
void Debugger::removeFromFrameMapsAndClearBreakpointsIn(JSContext* cx,
AbstractFramePtr frame,
bool suspending) {
forEachDebuggerFrame(frame, [&](DebuggerFrame* frameobj) {
forEachDebuggerFrame(frame, [&](Debugger* dbg, DebuggerFrame* frameobj) {
JSFreeOp* fop = cx->runtime()->defaultFreeOp();
frameobj->freeFrameIterData(fop);
Debugger* dbg = Debugger::fromChildJSObject(frameobj);
dbg->frames.remove(frame);
if (frameobj->hasGeneratorInfo()) {

Просмотреть файл

@ -908,7 +908,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
JSContext* cx, DebugAPI::ExecutionObservableSet& obs,
IsObserving observing);
template <typename FrameFn /* void (DebuggerFrame*) */>
template <typename FrameFn /* void (Debugger*, DebuggerFrame*) */>
static void forEachDebuggerFrame(AbstractFramePtr frame, FrameFn fn);
/*