author | Jeff Walden <jwalden@mit.edu> |
Thu, 08 Oct 2015 18:56:11 -0700 | |
changeset 267020 | fa77b9c41225fbd66e3a0305dd97a1fbaa5d3951 |
parent 267019 | f83a07527af8b00b1849d438282bb99b846f3f7f |
child 267021 | 38f4ce29926d6336c00910f7795ee257be4eb704 |
push id | 29504 |
push user | cbook@mozilla.com |
push date | Fri, 09 Oct 2015 09:43:23 +0000 |
treeherder | mozilla-central@d01dd42e654b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | H-bustage |
bugs | 1206594 |
milestone | 44.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/vm/Debugger.cpp | file | annotate | diff | comparison | revisions | |
js/src/vm/Debugger.h | file | annotate | diff | comparison | revisions |
--- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -2314,30 +2314,30 @@ Debugger::isObservedByDebuggerTrackingAl } } } return false; } /* 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)); - - if (Debugger::cannotTrackAllocations(debuggee)) { + MOZ_ASSERT(isObservedByDebuggerTrackingAllocations(*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; } /* static */ void Debugger::removeAllocationsTracking(GlobalObject& global) { // If there are still Debuggers that are observing allocations, we cannot // remove the metadata callback yet. Recompute the sampling probability @@ -2363,31 +2363,33 @@ Debugger::addAllocationsTrackingForAllDe for (WeakGlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront()) { if (Debugger::cannotTrackAllocations(*r.front().get())) { JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET); return false; } } + 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; } 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(); } /*** Debugger JSObjects **************************************************************************/ void @@ -3421,18 +3423,19 @@ Debugger::addDebuggeeGlobal(JSContext* c return false; } auto debuggeeZonesGuard = MakeScopeExit([&] { if (addingZoneRelation) debuggeeZones.remove(zone); }); // (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); }); // (6) debuggeeCompartment->setIsDebuggee(); debuggeeCompartment->updateDebuggerObservesAsmJS();
--- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -391,17 +391,17 @@ class Debugger : private mozilla::Linked */ static bool isObservedByDebuggerTrackingAllocations(const GlobalObject& global); /* * Add allocations tracking for objects allocated within the given * 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 * global's compartment. This is a no-op if there are still Debuggers * observing this global and who are tracking allocations. */ static void removeAllocationsTracking(GlobalObject& global);