Bug 1131326 - Part 0: Implement the Debugger.Memory.prototype.allocationsLogOverflowed getter. r=shu
authorNick Fitzgerald <fitzgen@gmail.com>
Tue, 10 Feb 2015 12:06:00 -0500
changeset 255953 bb18a5bf3a1cbf1ac003b89e260d85120ee54764
parent 255952 187c64254f7b727a67c766eda9ded1a7497da188
child 255954 67532392e5c213d580951d2e0550b062c729ad9e
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1131326
milestone38.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 1131326 - Part 0: Implement the Debugger.Memory.prototype.allocationsLogOverflowed getter. r=shu
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
js/src/vm/DebuggerMemory.cpp
js/src/vm/DebuggerMemory.h
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -356,16 +356,17 @@ Breakpoint::nextInSite()
 Debugger::Debugger(JSContext *cx, NativeObject *dbg)
   : object(dbg),
     uncaughtExceptionHook(nullptr),
     enabled(true),
     trackingAllocationSites(false),
     allocationSamplingProbability(1.0),
     allocationsLogLength(0),
     maxAllocationsLogLength(DEFAULT_MAX_ALLOCATIONS_LOG_LENGTH),
+    allocationsLogOverflowed(false),
     frames(cx->runtime()),
     scripts(cx),
     sources(cx),
     objects(cx),
     environments(cx),
 #ifdef NIGHTLY_BUILD
     traceLoggerLastDrainedId(0),
     traceLoggerLastDrainedIteration(0),
@@ -1618,16 +1619,17 @@ Debugger::appendAllocationSite(JSContext
     AllocationSite *allocSite = cx->new_<AllocationSite>(wrapped, when);
     if (!allocSite)
         return false;
 
     allocationsLog.insertBack(allocSite);
 
     if (allocationsLogLength >= maxAllocationsLogLength) {
         js_delete(allocationsLog.getFirst());
+        allocationsLogOverflowed = true;
     } else {
         allocationsLogLength++;
     }
 
     return true;
 }
 
 void
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -253,17 +253,20 @@ class Debugger : private mozilla::Linked
     };
     typedef mozilla::LinkedList<AllocationSite> AllocationSiteList;
 
     bool trackingAllocationSites;
     double allocationSamplingProbability;
     AllocationSiteList allocationsLog;
     size_t allocationsLogLength;
     size_t maxAllocationsLogLength;
+    bool allocationsLogOverflowed;
+
     static const size_t DEFAULT_MAX_ALLOCATIONS_LOG_LENGTH = 5000;
+
     bool appendAllocationSite(JSContext *cx, HandleSavedFrame frame, int64_t when);
     void emptyAllocationsLog();
 
     /*
      * If this Debugger is enabled, and has a onNewGlobalObject handler, then
      * this link is inserted into the circular list headed by
      * JSRuntime::onNewGlobalObjectWatchers. Otherwise, this is set to a
      * singleton cycle.
--- a/js/src/vm/DebuggerMemory.cpp
+++ b/js/src/vm/DebuggerMemory.cpp
@@ -215,16 +215,17 @@ DebuggerMemory::drainAllocationsLog(JSCo
 
         // Pop the front queue entry, and delete it immediately, so that
         // the GC sees the AllocationSite's RelocatablePtr barriers run
         // atomically with the change to the graph (the queue link).
         MOZ_ALWAYS_TRUE(dbg->allocationsLog.popFirst() == allocSite);
         js_delete(allocSite);
     }
 
+    dbg->allocationsLogOverflowed = false;
     dbg->allocationsLogLength = 0;
     args.rval().setObject(*result);
     return true;
 }
 
 /* static */ bool
 DebuggerMemory::getMaxAllocationsLogLength(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -289,16 +290,24 @@ DebuggerMemory::setAllocationSamplingPro
         return false;
     }
 
     memory->getDebugger()->allocationSamplingProbability = probability;
     args.rval().setUndefined();
     return true;
 }
 
+/* static */ bool
+DebuggerMemory::getAllocationsLogOverflowed(JSContext *cx, unsigned argc, Value *vp)
+{
+    THIS_DEBUGGER_MEMORY(cx, argc, vp, "(get allocationsLogOverflowed)", args, memory);
+    args.rval().setBoolean(memory->getDebugger()->allocationsLogOverflowed);
+    return true;
+}
+
 
 /* Debugger.Memory.prototype.takeCensus */
 
 void
 JS::dbg::SetDebuggerMallocSizeOf(JSRuntime *rt, mozilla::MallocSizeOf mallocSizeOf) {
     rt->debuggerMallocSizeOf = mallocSizeOf;
 }
 
@@ -800,16 +809,17 @@ DebuggerMemory::takeCensus(JSContext *cx
 
 /* Debugger.Memory property and method tables. */
 
 
 /* static */ const JSPropertySpec DebuggerMemory::properties[] = {
     JS_PSGS("trackingAllocationSites", getTrackingAllocationSites, setTrackingAllocationSites, 0),
     JS_PSGS("maxAllocationsLogLength", getMaxAllocationsLogLength, setMaxAllocationsLogLength, 0),
     JS_PSGS("allocationSamplingProbability", getAllocationSamplingProbability, setAllocationSamplingProbability, 0),
+    JS_PSG("allocationsLogOverflowed", getAllocationsLogOverflowed, 0),
     JS_PS_END
 };
 
 /* static */ const JSFunctionSpec DebuggerMemory::methods[] = {
     JS_FN("drainAllocationsLog", DebuggerMemory::drainAllocationsLog, 0, 0),
     JS_FN("takeCensus", takeCensus, 0, 0),
     JS_FS_END
 };
--- a/js/src/vm/DebuggerMemory.h
+++ b/js/src/vm/DebuggerMemory.h
@@ -33,20 +33,21 @@ class DebuggerMemory : public NativeObje
     static bool construct(JSContext *cx, unsigned argc, Value *vp);
     static const Class          class_;
     static const JSPropertySpec properties[];
     static const JSFunctionSpec methods[];
 
     // Accessor properties of Debugger.Memory.prototype.
     static bool setTrackingAllocationSites(JSContext *cx, unsigned argc, Value *vp);
     static bool getTrackingAllocationSites(JSContext *cx, unsigned argc, Value *vp);
-    static bool setMaxAllocationsLogLength(JSContext*cx, unsigned argc, Value *vp);
-    static bool getMaxAllocationsLogLength(JSContext*cx, unsigned argc, Value *vp);
-    static bool setAllocationSamplingProbability(JSContext*cx, unsigned argc, Value *vp);
-    static bool getAllocationSamplingProbability(JSContext*cx, unsigned argc, Value *vp);
+    static bool setMaxAllocationsLogLength(JSContext *cx, unsigned argc, Value *vp);
+    static bool getMaxAllocationsLogLength(JSContext *cx, unsigned argc, Value *vp);
+    static bool setAllocationSamplingProbability(JSContext *cx, unsigned argc, Value *vp);
+    static bool getAllocationSamplingProbability(JSContext *cx, unsigned argc, Value *vp);
+    static bool getAllocationsLogOverflowed(JSContext *cx, unsigned argc, Value *vp);
 
     // Function properties of Debugger.Memory.prototype.
     static bool takeCensus(JSContext *cx, unsigned argc, Value *vp);
     static bool drainAllocationsLog(JSContext *cx, unsigned argc, Value *vp);
 };
 
 } /* namespace js */