Bug 687398: fix debug printing of method GC edge, r=cdleary
authorDavid Mandelin <dmandelin@mozilla.com>
Mon, 10 Oct 2011 13:08:35 -0700
changeset 79006 96b2321ec26cc6612a6e89488f6e2ad51bb627e2
parent 79005 818edd78ffacaf37040b618094f630b575daf05c
child 79007 1defa404424da3836586c48f69193f6da40ffdd3
push idunknown
push userunknown
push dateunknown
reviewerscdleary
bugs687398
milestone10.0a1
Bug 687398: fix debug printing of method GC edge, r=cdleary
js/src/jsgcmark.cpp
--- a/js/src/jsgcmark.cpp
+++ b/js/src/jsgcmark.cpp
@@ -550,47 +550,45 @@ MarkRoot(JSTracer *trc, types::TypeObjec
 
 void
 MarkRoot(JSTracer *trc, JSXML *thing, const char *name)
 {
     MarkXML(trc, thing, name);
 }
 
 static void
+PrintPropertyId(char *buf, size_t bufsize, jsid propid, const char *label)
+{
+    JS_ASSERT(!JSID_IS_VOID(propid));
+    if (JSID_IS_ATOM(propid)) {
+        size_t n = PutEscapedString(buf, bufsize, JSID_TO_ATOM(propid), 0);
+        if (n < bufsize)
+            JS_snprintf(buf + n, bufsize - n, " %s", label);
+    } else if (JSID_IS_INT(propid)) {
+        JS_snprintf(buf, bufsize, "%d %s", JSID_TO_INT(propid), label);
+    } else {
+        JS_snprintf(buf, bufsize, "<object> %s", label);
+    }
+}
+
+static void
 PrintPropertyGetterOrSetter(JSTracer *trc, char *buf, size_t bufsize)
 {
     JS_ASSERT(trc->debugPrinter == PrintPropertyGetterOrSetter);
     Shape *shape = (Shape *)trc->debugPrintArg;
-    jsid propid = shape->propid;
-    JS_ASSERT(!JSID_IS_VOID(propid));
-    const char *name = trc->debugPrintIndex ? js_setter_str : js_getter_str;
-
-    if (JSID_IS_ATOM(propid)) {
-        size_t n = PutEscapedString(buf, bufsize, JSID_TO_ATOM(propid), 0);
-        if (n < bufsize)
-            JS_snprintf(buf + n, bufsize - n, " %s", name);
-    } else if (JSID_IS_INT(shape->propid)) {
-        JS_snprintf(buf, bufsize, "%d %s", JSID_TO_INT(propid), name);
-    } else {
-        JS_snprintf(buf, bufsize, "<object> %s", name);
-    }
+    PrintPropertyId(buf, bufsize, shape->propid,
+                    trc->debugPrintIndex ? js_setter_str : js_getter_str); 
 }
 
 static void
 PrintPropertyMethod(JSTracer *trc, char *buf, size_t bufsize)
 {
     JS_ASSERT(trc->debugPrinter == PrintPropertyMethod);
     Shape *shape = (Shape *)trc->debugPrintArg;
-    jsid propid = shape->propid;
-    JS_ASSERT(!JSID_IS_VOID(propid));
-
-    JS_ASSERT(JSID_IS_ATOM(propid));
-    size_t n = PutEscapedString(buf, bufsize, JSID_TO_ATOM(propid), 0);
-    if (n < bufsize)
-        JS_snprintf(buf + n, bufsize - n, " method");
+    PrintPropertyId(buf, bufsize, shape->propid, " method");
 }
 
 static inline void
 ScanValue(GCMarker *gcmarker, const Value &v)
 {
     if (v.isMarkable()) {
         JSGCTraceKind kind = v.gcKind();
         if (kind == JSTRACE_STRING) {