Bug 841549 - Fix sizeOfIncludingThis() during compression. r=njn
authorBenjamin Peterson <benjamin@python.org>
Thu, 14 Feb 2013 23:25:17 -0500
changeset 128086 e4987b9b24bc77bc139ae5e8166312c8449b1b9f
parent 128085 8db40a38aeb1ebf73bbc42f6ebceb02c5349a89e
child 128087 e7b029c64d2ae749518578fd4bb64dafdbfcd753
push id3384
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:42:39 +0000
treeherdermozilla-aurora@d8c97bae8521 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs841549
milestone21.0a1
Bug 841549 - Fix sizeOfIncludingThis() during compression. r=njn
js/src/jsscript.cpp
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1315,21 +1315,23 @@ ScriptSource::destroy()
     js_free(sourceMap_);
     ready_ = false;
     js_free(this);
 }
 
 size_t
 ScriptSource::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
 {
-    JS_ASSERT(ready());
-
     // |data| is a union, but both members are pointers to allocated memory,
     // |emptySource|, or NULL, so just using |data.compressed| will work.
-    return mallocSizeOf(this) + ((data.compressed != emptySource) ? mallocSizeOf(data.compressed) : 0);
+    size_t n = mallocSizeOf(this);
+    n += (ready() && data.compressed != emptySource)
+       ? mallocSizeOf(data.compressed)
+       : 0;
+    return n;
 }
 
 template<XDRMode mode>
 bool
 ScriptSource::performXDR(XDRState<mode> *xdr)
 {
     uint8_t hasSource = hasSourceData();
     if (!xdr->codeUint8(&hasSource))