Bug 1206594 - Followup hazard-fix. r=H-bustage in a CLOSED TREE

This commit is contained in:
Jeff Walden 2015-10-08 18:56:11 -07:00
parent af3322fb26
commit 123059bb0c
2 changed files with 14 additions and 11 deletions

View File

@ -2319,20 +2319,20 @@ Debugger::isObservedByDebuggerTrackingAllocations(const GlobalObject& debuggee)
}
/* static */ bool
Debugger::addAllocationsTracking(JSContext* cx, GlobalObject& debuggee)
Debugger::addAllocationsTracking(JSContext* cx, Handle<GlobalObject*> debuggee)
{
// Precondition: the given global object is being observed by at least one
// Debugger that is tracking allocations.
MOZ_ASSERT(isObservedByDebuggerTrackingAllocations(debuggee));
MOZ_ASSERT(isObservedByDebuggerTrackingAllocations(*debuggee));
if (Debugger::cannotTrackAllocations(debuggee)) {
if (Debugger::cannotTrackAllocations(*debuggee)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET);
return false;
}
debuggee.compartment()->setObjectMetadataCallback(SavedStacksMetadataCallback);
debuggee.compartment()->chooseAllocationSamplingProbability();
debuggee->compartment()->setObjectMetadataCallback(SavedStacksMetadataCallback);
debuggee->compartment()->chooseAllocationSamplingProbability();
return true;
}
@ -2368,10 +2368,12 @@ Debugger::addAllocationsTrackingForAllDebuggees(JSContext* cx)
}
}
Rooted<GlobalObject*> g(cx);
for (WeakGlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront()) {
// This should always succeed, since we already checked for the
// error case above.
MOZ_ALWAYS_TRUE(Debugger::addAllocationsTracking(cx, *r.front().get()));
g = r.front().get();
MOZ_ALWAYS_TRUE(Debugger::addAllocationsTracking(cx, g));
}
return true;
@ -2380,9 +2382,9 @@ Debugger::addAllocationsTrackingForAllDebuggees(JSContext* cx)
void
Debugger::removeAllocationsTrackingForAllDebuggees()
{
for (WeakGlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront()) {
for (WeakGlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront())
Debugger::removeAllocationsTracking(*r.front().get());
}
allocationsLog.clear();
}
@ -3426,8 +3428,9 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global)
});
// (5)
if (trackingAllocationSites && enabled && !Debugger::addAllocationsTracking(cx, *global))
return false;
if (trackingAllocationSites && enabled && !Debugger::addAllocationsTracking(cx, global))
return false;
auto allocationsTrackingGuard = MakeScopeExit([&] {
if (trackingAllocationSites && enabled)
Debugger::removeAllocationsTracking(*global);

View File

@ -396,7 +396,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
* debuggee's compartment. The given debuggee global must be observed by at
* least one Debugger that is enabled and tracking allocations.
*/
static bool addAllocationsTracking(JSContext* cx, GlobalObject& debuggee);
static bool addAllocationsTracking(JSContext* cx, Handle<GlobalObject*> debuggee);
/*
* Remove allocations tracking for objects allocated within the given