Bug 1231386 - Change debugger to use RuntimeAllocPolicy for all its hash tables r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 15 Dec 2015 13:36:14 +0000
changeset 276413 83810689970b69d1f5f23f737eb1dd0ea68048b3
parent 276412 184a432d20c5cb63d86d08bd7459a53bb81b2466
child 276414 d447860f455055780dc9e14a9b80dc7a1133a20c
push id69161
push userjcoppeard@mozilla.com
push dateTue, 15 Dec 2015 13:37:47 +0000
treeherdermozilla-inbound@d447860f4550 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1231386
milestone46.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
Bug 1231386 - Change debugger to use RuntimeAllocPolicy for all its hash tables r=terrence
js/src/jit-test/tests/gc/bug-1231386.js
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1231386.js
@@ -0,0 +1,19 @@
+if (!('oomTest' in this))
+    quit();
+
+function f1() {}
+function f2() {}
+r = [function() {}, function() {}, [], function() {}, f1, function() {}, f2];
+l = [0];
+function f3() {
+    return {
+        a: 0
+    };
+}
+var x = f3();
+var h = newGlobal();
+var dbg = new Debugger;
+dbg.addDebuggee(h);
+oomTest(() => getBacktrace({
+    thisprops: gc()
+}));
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -351,21 +351,22 @@ Breakpoint::nextInSite()
     return (link == &site->breakpoints) ? nullptr : fromSiteLinks(link);
 }
 
 
 /*** Debugger hook dispatch **********************************************************************/
 
 Debugger::Debugger(JSContext* cx, NativeObject* dbg)
   : object(dbg),
+    debuggees(cx->runtime()),
     uncaughtExceptionHook(nullptr),
     enabled(true),
     allowUnobservedAsmJS(false),
     collectCoverageInfo(false),
-    observedGCs(cx),
+    observedGCs(cx->runtime()),
     tenurePromotionsLog(cx),
     trackingTenurePromotions(false),
     maxTenurePromotionsLogLength(DEFAULT_MAX_LOG_LENGTH),
     tenurePromotionsLogOverflowed(false),
     allocationsLog(cx),
     trackingAllocationSites(false),
     allocationSamplingProbability(1.0),
     maxAllocationsLogLength(DEFAULT_MAX_LOG_LENGTH),
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -38,17 +38,17 @@ namespace js {
 
 class LSprinter;
 
 class Breakpoint;
 class DebuggerMemory;
 
 typedef HashSet<ReadBarrieredGlobalObject,
                 MovableCellHasher<ReadBarrieredGlobalObject>,
-                SystemAllocPolicy> WeakGlobalObjectSet;
+                RuntimeAllocPolicy> WeakGlobalObjectSet;
 
 /*
  * A weakmap from GC thing keys to JSObject values that supports the keys being
  * in different compartments to the values. All values must be in the same
  * compartment.
  *
  * The purpose of this is to allow the garbage collector to easily find edges
  * from debuggee object compartments to debugger compartments when calculating
@@ -255,16 +255,17 @@ class Debugger : private mozilla::Linked
     };
 
     // Return true if the given compartment is a debuggee of this debugger,
     // false otherwise.
     bool isDebuggeeUnbarriered(const JSCompartment* compartment) const;
 
     // Return true if this Debugger observed a debuggee that participated in the
     // GC identified by the given GC number. Return false otherwise.
+    // May return false negatives if we have hit OOM.
     bool observedGC(uint64_t majorGCNumber) const {
         return observedGCs.has(majorGCNumber);
     }
 
     // Notify this Debugger that one or more of its debuggees is participating
     // in the GC identified by the given GC number.
     bool debuggeeIsBeingCollected(uint64_t majorGCNumber) {
         return observedGCs.put(majorGCNumber);
@@ -335,17 +336,18 @@ class Debugger : private mozilla::Linked
 
     // Wether to enable code coverage on the Debuggee.
     bool collectCoverageInfo;
 
     JSCList breakpoints;                /* Circular list of all js::Breakpoints in this debugger */
 
     // The set of GC numbers for which one or more of this Debugger's observed
     // debuggees participated in.
-    js::HashSet<uint64_t> observedGCs;
+    using GCNumberSet = HashSet<uint64_t, DefaultHasher<uint64_t>, RuntimeAllocPolicy>;
+    GCNumberSet observedGCs;
 
     using TenurePromotionsLog = js::TraceableFifo<TenurePromotionsLogEntry>;
     TenurePromotionsLog tenurePromotionsLog;
     bool trackingTenurePromotions;
     size_t maxTenurePromotionsLogLength;
     bool tenurePromotionsLogOverflowed;
 
     using AllocationsLog = js::TraceableFifo<AllocationsLogEntry>;