Bug 652985 - Use off-the-books malloc in DumpHeap (r=pbiggar)
authorBill McCloskey <wmccloskey@mozilla.com>
Wed, 01 Jun 2011 17:48:02 -0700
changeset 70642 596dca744a3768eba04cab3e3dbe186d39f10117
parent 70641 f8c79845996f59017c26a77bfbac255858ae172b
child 70643 b36861bd7a01dabcf875f11e1e2ae50a0b370f31
push id20369
push usercleary@mozilla.com
push dateMon, 06 Jun 2011 20:24:54 +0000
treeherdermozilla-central@3589f8cefd83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbiggar
bugs652985
milestone6.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 652985 - Use off-the-books malloc in DumpHeap (r=pbiggar)
js/src/Makefile.in
js/src/jsapi.cpp
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -631,33 +631,33 @@ ifeq ($(MOZ_DEBUG),1)
 #check:: check-ooms
 endif
 
 ## Prevent regressing in our deprecation of non-preferred memory management functions.
 # We use all the files in the distribution so that different configurations
 # don't give different results. We skip the contents of objdirs using |find|
 # (it can't be done with %-expansion, because the files we want to skip aren't
 # in the vpath).
-ALL_FILES=$(shell find $(srcdir) \( -name "*.cpp" -o -name "*.h" \) -not -path "*/dist/*")
+ALL_FILES=$(shell find $(srcdir) \( -name "*.cpp" -o -name "*.h" \) -not -path "*/dist/*" -not -path "*/config/*")
 check-malloc-function-usage: $(filter-out %jsalloc.h %jscntxt.h %jsutil.h, $(ALL_FILES))
 
 	# js_malloc and friends are only used by other memory managers, and should
 	# never be used elsewhere directly.
 	$(srcdir)/config/check_source_count.py "\bjs_malloc\b" 0 \
 		"in Makefile.in" "cx->malloc_ or rt->malloc_" $^
 	$(srcdir)/config/check_source_count.py "\bjs_calloc\b" 0 \
 		"in Makefile.in" "cx->calloc_ or rt->calloc_" $^
 	$(srcdir)/config/check_source_count.py "\bjs_realloc\b" 0 \
 		"in Makefile.in" "cx->realloc_ or rt->realloc_" $^
 	$(srcdir)/config/check_source_count.py "\bjs_free\b" 0 \
 		"in Makefile.in" "cx->free_" $^
 
 	# We desire these numbers to go down, not up. See "User guide to memory
 	# management within SpiderMonkey" in jsutil.h.
-	$(srcdir)/config/check_source_count.py OffTheBooks:: 54 \
+	$(srcdir)/config/check_source_count.py OffTheBooks:: 55 \
 		"in Makefile.in" "{cx,rt}->{new_,new_array,malloc_,calloc_,realloc_}" $^
 	# This should go to zero, if possible.
 	$(srcdir)/config/check_source_count.py UnwantedForeground:: 34 \
 		"in Makefile.in" "{cx,rt}->{free_,delete_,array_delete}" $^
 
 ifneq ($(OS_ARCH),WINNT) # FIXME: this should be made work on Windows too.
 check:: check-malloc-function-usage
 endif
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2406,17 +2406,18 @@ DumpNotify(JSTracer *trc, void *thing, u
                     (const char *)dtrc->base.debugPrintArg,
                     dtrc->base.debugPrintIndex);
         edgeName = dtrc->buffer;
     } else {
         edgeName = (const char*)dtrc->base.debugPrintArg;
     }
 
     edgeNameSize = strlen(edgeName) + 1;
-    node = (JSHeapDumpNode *) cx->malloc_(offsetof(JSHeapDumpNode, edgeName) + edgeNameSize);
+    size_t bytes = offsetof(JSHeapDumpNode, edgeName) + edgeNameSize;
+    node = (JSHeapDumpNode *) OffTheBooks::malloc_(bytes);
     if (!node) {
         dtrc->ok = JS_FALSE;
         return;
     }
 
     node->thing = thing;
     node->kind = kind;
     node->next = NULL;
@@ -2558,17 +2559,17 @@ JS_DumpHeap(JSContext *cx, FILE *fp, voi
                 }
             }
         }
 
         /* Move to next or parents next and free the node. */
         for (;;) {
             next = node->next;
             parent = node->parent;
-            cx->free_(node);
+            Foreground::free_(node);
             node = next;
             if (node)
                 break;
             if (!parent)
                 goto dump_out;
             JS_ASSERT(depth > 1);
             --depth;
             node = parent;