Bug 1586165 - Null check ionCounts_ before calling sizeOfIncludingThis on it. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 04 Oct 2019 12:46:20 +0000
changeset 496319 1cf96914dd193a3a596e6b35a12fdaeb816e095a
parent 496318 fc32527395e2f6c83fe7c84708f08abe8ef04fae
child 496320 d477fb519881ddd1836c7c84938d553b070e4d1a
push id36651
push userncsoregi@mozilla.com
push dateFri, 04 Oct 2019 21:38:11 +0000
treeherdermozilla-central@74c62117e3e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1586165
milestone71.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 1586165 - Null check ionCounts_ before calling sizeOfIncludingThis on it. r=nbp Differential Revision: https://phabricator.services.mozilla.com/D48163
js/src/jit/IonCode.h
js/src/vm/JSScript.cpp
--- a/js/src/jit/IonCode.h
+++ b/js/src/jit/IonCode.h
@@ -593,21 +593,20 @@ struct IonScriptCounts {
 
   void setPrevious(IonScriptCounts* previous) { previous_ = previous; }
 
   IonScriptCounts* previous() const { return previous_; }
 
   size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
     size_t size = 0;
     auto currCounts = this;
-    while (currCounts) {
-      const IonScriptCounts* currCount = currCounts;
-      currCounts = currCount->previous_;
-      size += currCount->sizeOfOneIncludingThis(mallocSizeOf);
-    }
+    do {
+      size += currCounts->sizeOfOneIncludingThis(mallocSizeOf);
+      currCounts = currCounts->previous_;
+    } while (currCounts);
     return size;
   }
 
   size_t sizeOfOneIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
     size_t size = mallocSizeOf(this) + mallocSizeOf(blocks_);
     for (size_t i = 0; i < numBlocks_; i++) {
       blocks_[i].sizeOfExcludingThis(mallocSizeOf);
     }
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -1494,19 +1494,23 @@ js::PCCounts* ScriptCounts::getThrowCoun
       std::lower_bound(throwCounts_.begin(), throwCounts_.end(), searched);
   if (elem == throwCounts_.end() || elem->pcOffset() != offset) {
     elem = throwCounts_.insert(elem, searched);
   }
   return elem;
 }
 
 size_t ScriptCounts::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) {
-  return mallocSizeOf(this) + pcCounts_.sizeOfExcludingThis(mallocSizeOf) +
-         throwCounts_.sizeOfExcludingThis(mallocSizeOf) +
-         ionCounts_->sizeOfIncludingThis(mallocSizeOf);
+  size_t size = mallocSizeOf(this);
+  size += pcCounts_.sizeOfExcludingThis(mallocSizeOf);
+  size += throwCounts_.sizeOfExcludingThis(mallocSizeOf);
+  if (ionCounts_) {
+    size += ionCounts_->sizeOfIncludingThis(mallocSizeOf);
+  }
+  return size;
 }
 
 js::PCCounts* JSScript::maybeGetPCCounts(jsbytecode* pc) {
   MOZ_ASSERT(containsPC(pc));
   return getScriptCounts().maybeGetPCCounts(pcToOffset(pc));
 }
 
 const js::PCCounts* JSScript::maybeGetThrowCounts(jsbytecode* pc) {