Bug 1633625 - Implement a performance.mozMemory.mallocBytes accessor for all-zones malloc memory r=jonco
authorSteve Fink <sfink@mozilla.com>
Tue, 19 May 2020 21:54:42 +0000
changeset 530902 d7e1fb886446b09c104098c478aa5b408bb3653f
parent 530901 b0e7c0beb052ebec77bc7c4d3a38538b8313423a
child 530903 51e3676256c70439959bb90afcba5f2f6ec5eb85
push id37434
push userabutkovits@mozilla.com
push dateWed, 20 May 2020 10:05:10 +0000
treeherdermozilla-central@005ef1c25992 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1633625
milestone78.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 1633625 - Implement a performance.mozMemory.mallocBytes accessor for all-zones malloc memory r=jonco Differential Revision: https://phabricator.services.mozilla.com/D74152
js/src/gc/GC.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -8385,16 +8385,26 @@ namespace gc {
 namespace MemInfo {
 
 static bool GCBytesGetter(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   args.rval().setNumber(double(cx->runtime()->gc.heapSize.bytes()));
   return true;
 }
 
+static bool MallocBytesGetter(JSContext* cx, unsigned argc, Value* vp) {
+  CallArgs args = CallArgsFromVp(argc, vp);
+  double bytes = 0;
+  for (ZonesIter zone(cx->runtime(), WithAtoms); !zone.done(); zone.next()) {
+    bytes += zone->mallocHeapSize.bytes();
+  }
+  args.rval().setNumber(bytes);
+  return true;
+}
+
 static bool GCMaxBytesGetter(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   args.rval().setNumber(double(cx->runtime()->gc.tunables.gcMaxBytes()));
   return true;
 }
 
 static bool GCHighFreqGetter(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
@@ -8484,16 +8494,17 @@ JSObject* NewMemoryInfoObject(JSContext*
   }
 
   using namespace MemInfo;
   struct NamedGetter {
     const char* name;
     JSNative getter;
   } getters[] = {{"gcBytes", GCBytesGetter},
                  {"gcMaxBytes", GCMaxBytesGetter},
+                 {"mallocBytes", MallocBytesGetter},
                  {"gcIsHighFrequencyMode", GCHighFreqGetter},
                  {"gcNumber", GCNumberGetter},
                  {"majorGCCount", MajorGCCountGetter},
                  {"minorGCCount", MinorGCCountGetter},
                  {"sliceCount", GCSliceCountGetter}};
 
   for (auto pair : getters) {
 #ifdef JS_MORE_DETERMINISTIC