Bug 1724693 part 2 - Include MatchPairs vector in RegExpStatics memory reporting. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 14 Aug 2021 13:02:47 +0000
changeset 588975 49601cf5c6b644c8b21337169aabeb8be48f3b74
parent 588974 aafaf1ef97051b748d5b27045337d0bf770d1b50
child 588976 aa6483129f44a2f2157bea796f0aa82435502958
push id38707
push userimoraru@mozilla.com
push dateSat, 14 Aug 2021 21:11:32 +0000
treeherdermozilla-central@18fc1360f9ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1724693
milestone93.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 1724693 part 2 - Include MatchPairs vector in RegExpStatics memory reporting. r=jonco Differential Revision: https://phabricator.services.mozilla.com/D122107
js/src/vm/GlobalObject.cpp
js/src/vm/MatchPairs.h
js/src/vm/RegExpStatics.h
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -1178,14 +1178,12 @@ void GlobalObjectData::trace(JSTracer* t
     regExpStatics->trace(trc);
   }
 }
 
 size_t GlobalObjectData::sizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   size_t size = mallocSizeOf(this);
   if (regExpStatics) {
-    // XXX: should really call RegExpStatics::sizeOfIncludingThis() here
-    // instead, but the extra memory it would measure is insignificant.
-    size += mallocSizeOf(regExpStatics.get());
+    size += regExpStatics->sizeOfIncludingThis(mallocSizeOf);
   }
   return size;
 }
--- a/js/src/vm/MatchPairs.h
+++ b/js/src/vm/MatchPairs.h
@@ -111,13 +111,17 @@ class VectorMatchPairs : public MatchPai
  protected:
   friend class RegExpShared;
   friend class RegExpStatics;
 
   /* MatchPair buffer allocator: set pairs_ and pairCount_. */
   bool allocOrExpandArray(size_t pairCount);
 
   bool initArrayFrom(VectorMatchPairs& copyFrom);
+
+  size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
+    return vec_.sizeOfExcludingThis(mallocSizeOf);
+  }
 };
 
 } /* namespace js */
 
 #endif /* vm_MatchPairs_h */
--- a/js/src/vm/RegExpStatics.h
+++ b/js/src/vm/RegExpStatics.h
@@ -79,16 +79,20 @@ class RegExpStatics {
      * Changes to this function must also be reflected in
      * RegExpStatics::AutoRooter::trace().
      */
     TraceNullableEdge(trc, &matchesInput, "res->matchesInput");
     TraceNullableEdge(trc, &lazySource, "res->lazySource");
     TraceNullableEdge(trc, &pendingInput, "res->pendingInput");
   }
 
+  size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
+    return mallocSizeOf(this) + matches.sizeOfExcludingThis(mallocSizeOf);
+  }
+
   /* Value creators. */
 
   bool createPendingInput(JSContext* cx, MutableHandleValue out);
   bool createLastMatch(JSContext* cx, MutableHandleValue out);
   bool createLastParen(JSContext* cx, MutableHandleValue out);
   bool createParen(JSContext* cx, size_t pairNum, MutableHandleValue out);
   bool createLeftContext(JSContext* cx, MutableHandleValue out);
   bool createRightContext(JSContext* cx, MutableHandleValue out);