Bug 678126 - Add "tjit-data/trace-monitor" memory reporter. r=dmandelin.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 14 Aug 2011 19:45:38 -0700
changeset 75290 e366da1a4f47992d1a727306d9f38ba8f0578501
parent 75289 3ab9371af845f93d5f6fef08ed6176bbea035fc7
child 75291 e32b302039ca255f051f163629f234098c94f84b
child 75295 884efa9dcbf9895c228e46bff9881dc428e124aa
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersdmandelin
bugs678126
milestone8.0a1
Bug 678126 - Add "tjit-data/trace-monitor" memory reporter. r=dmandelin.
js/src/jscompartment.h
js/src/jstracer.cpp
js/src/xpconnect/src/xpcjsruntime.cpp
js/src/xpconnect/src/xpcpublic.h
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -282,16 +282,17 @@ struct TraceMonitor {
     /* Mark any tracer stacks that are active. */
     void mark(JSTracer *trc);
 
     bool outOfMemory() const;
 
     JS_FRIEND_API(void) getCodeAllocStats(size_t &total, size_t &frag_size, size_t &free_size) const;
     JS_FRIEND_API(size_t) getVMAllocatorsMainSize() const;
     JS_FRIEND_API(size_t) getVMAllocatorsReserveSize() const;
+    JS_FRIEND_API(size_t) getTraceMonitorSize() const;
 };
 
 namespace mjit {
 class JaegerCompartment;
 }
 }
 
 /* Defined in jsapi.cpp */
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -2512,16 +2512,25 @@ TraceMonitor::getVMAllocatorsMainSize() 
 size_t
 TraceMonitor::getVMAllocatorsReserveSize() const
 {
     return dataAlloc->mReserveSize +
            traceAlloc->mReserveSize +
            tempAlloc->mReserveSize;
 }
 
+size_t
+TraceMonitor::getTraceMonitorSize() const
+{
+    return sizeof(TraceMonitor) +           // TraceMonitor
+           sizeof(*storage) +               // TraceNativeStorage
+           recordAttempts->tableSize() +    // RecordAttemptMap
+           loopProfiles->tableSize();       // LoopProfileMap
+}
+
 /*
  * This function destroys the recorder after a successful recording, possibly
  * starting a suspended outer recorder.
  */
 AbortableRecordingStatus
 TraceRecorder::finishSuccessfully()
 {
     JS_ASSERT(!traceMonitor->profile);
--- a/js/src/xpconnect/src/xpcjsruntime.cpp
+++ b/js/src/xpconnect/src/xpcjsruntime.cpp
@@ -1310,16 +1310,24 @@ GetCompartmentTjitDataAllocatorsMainSize
 PRInt64
 GetCompartmentTjitDataAllocatorsReserveSize(JSCompartment *c)
 {
     return c->hasTraceMonitor()
          ? c->traceMonitor()->getVMAllocatorsReserveSize()
          : 0;
 }
 
+PRInt64
+GetCompartmentTjitDataTraceMonitorSize(JSCompartment *c)
+{
+    return c->hasTraceMonitor()
+         ? c->traceMonitor()->getTraceMonitorSize()
+         : 0;
+}
+
 #endif  // JS_TRACER
 
 void
 CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment)
 {
     // Append a new CompartmentStats to the vector.
     IterateData *data = static_cast<IterateData *>(vdata);
     CompartmentStats compartmentStats(cx, compartment);
@@ -1332,16 +1340,17 @@ CompartmentCallback(JSContext *cx, void 
 #ifdef JS_METHODJIT
     curr->mjitCode = GetCompartmentMjitCodeSize(compartment);
     curr->mjitData = GetCompartmentMjitDataSize(compartment);
 #endif
 #ifdef JS_TRACER
     curr->tjitCode = GetCompartmentTjitCodeSize(compartment);
     curr->tjitDataAllocatorsMain = GetCompartmentTjitDataAllocatorsMainSize(compartment);
     curr->tjitDataAllocatorsReserve = GetCompartmentTjitDataAllocatorsReserveSize(compartment);
+    curr->tjitDataNonAllocators = GetCompartmentTjitDataTraceMonitorSize(compartment);
 #endif
 }
 
 void
 ArenaCallback(JSContext *cx, void *vdata, js::gc::Arena *arena,
               size_t traceKind, size_t thingSize)
 {
     IterateData *data = static_cast<IterateData *>(vdata);
@@ -1798,16 +1807,25 @@ ReportCompartmentStats(const Compartment
 
     ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name,
                                               "tjit-data/allocators-reserve"),
                        nsIMemoryReporter::KIND_HEAP,
                        stats.tjitDataAllocatorsReserve,
     "Memory used by the trace JIT and held in reserve for the compartment's "
     "VMAllocators in case of OOM.",
                        callback, closure);
+
+    ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name,
+                                              "tjit-data/trace-monitor"),
+                       nsIMemoryReporter::KIND_HEAP,
+                       stats.tjitDataNonAllocators,
+    "Memory used by the trace JIT that is stored in the TraceMonitor.  This "
+    "includes the TraceMonitor object itself, plus its TraceNativeStorage, "
+    "RecordAttemptMap, and LoopProfileMap.",
+                       callback, closure);
 #endif
 }
 
 void
 ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
                      nsIMemoryMultiReporterCallback *callback,
                      nsISupports *closure)
 {
--- a/js/src/xpconnect/src/xpcpublic.h
+++ b/js/src/xpconnect/src/xpcpublic.h
@@ -214,16 +214,17 @@ struct CompartmentStats
 #ifdef JS_METHODJIT
     PRInt64 mjitCode;
     PRInt64 mjitData;
 #endif
 #ifdef JS_TRACER
     PRInt64 tjitCode;
     PRInt64 tjitDataAllocatorsMain;
     PRInt64 tjitDataAllocatorsReserve;
+    PRInt64 tjitDataNonAllocators;
 #endif
 };
 
 struct IterateData
 {
     IterateData()
       : atomsTableSize(0),
         stackSize(0),