Bug 848608 - Make eagerlyTraceWeakMaps an enum; r=billm
authorTerrence Cole <terrence@mozilla.com>
Thu, 07 Mar 2013 10:49:30 -0800
changeset 124147 1ccebe00cd2c243cbc67e3011d0e0c724d7ef39e
parent 124146 7da6d3d93cccfd896e7a6f45d5af86895387f15d
child 124148 b57e338dd933ca47c3ac9608e78e4fdbe275f541
push id24408
push userryanvm@gmail.com
push dateFri, 08 Mar 2013 04:58:11 +0000
treeherdermozilla-central@cb432984d5ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs848608
milestone22.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 848608 - Make eagerlyTraceWeakMaps an enum; r=billm
js/src/gc/Marking.cpp
js/src/jsapi.h
js/src/jsgc.cpp
js/xpconnect/src/nsXPConnect.cpp
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -1503,24 +1503,24 @@ struct UnmarkGrayTracer : public JSTrace
     /*
      * We set eagerlyTraceWeakMaps to false because the cycle collector will fix
      * up any color mismatches involving weakmaps when it runs.
      */
     UnmarkGrayTracer(JSRuntime *rt)
       : tracingShape(false), previousShape(NULL)
     {
         JS_TracerInit(this, rt, UnmarkGrayChildren);
-        eagerlyTraceWeakMaps = false;
+        eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
     }
 
     UnmarkGrayTracer(JSTracer *trc, bool tracingShape)
       : tracingShape(tracingShape), previousShape(NULL)
     {
         JS_TracerInit(this, trc->runtime, UnmarkGrayChildren);
-        eagerlyTraceWeakMaps = false;
+        eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
     }
 
     /* True iff we are tracing the immediate children of a shape. */
     bool tracingShape;
 
     /* If tracingShape, shape child or NULL. Otherwise, NULL. */
     void *previousShape;
 };
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2652,23 +2652,28 @@ JSVAL_TRACE_KIND(jsval v)
  *
  * If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all
  * of its mappings.  This should be used in cases where the tracer
  * wants to use the existing liveness of entries.
  */
 typedef void
 (* JSTraceCallback)(JSTracer *trc, void **thingp, JSGCTraceKind kind);
 
+enum WeakMapTraceKind {
+    DoNotTraceWeakMaps = 0,
+    TraceWeakMapValues = 1
+};
+
 struct JSTracer {
     JSRuntime           *runtime;
     JSTraceCallback     callback;
     JSTraceNamePrinter  debugPrinter;
     const void          *debugPrintArg;
     size_t              debugPrintIndex;
-    JSBool              eagerlyTraceWeakMaps;
+    WeakMapTraceKind    eagerlyTraceWeakMaps;
 #ifdef JS_GC_ZEAL
     void                *realLocation;
 #endif
 };
 
 /*
  * The method to call on each reference to a traceable thing stored in a
  * particular JSObject or other runtime structure. With DEBUG defined the
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1619,17 +1619,17 @@ js_UnlockThing(JSRuntime *rt, void *thin
 void
 js::InitTracer(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback)
 {
     trc->runtime = rt;
     trc->callback = callback;
     trc->debugPrinter = NULL;
     trc->debugPrintArg = NULL;
     trc->debugPrintIndex = size_t(-1);
-    trc->eagerlyTraceWeakMaps = true;
+    trc->eagerlyTraceWeakMaps = TraceWeakMapValues;
 #ifdef JS_GC_ZEAL
     trc->realLocation = NULL;
 #endif
 }
 
 /* static */ int64_t
 SliceBudget::TimeBudget(int64_t millis)
 {
@@ -1698,17 +1698,17 @@ GCMarker::start()
 
     JS_ASSERT(!unmarkedArenaStackTop);
     JS_ASSERT(markLaterArenas == 0);
 
     /*
      * The GC is recomputing the liveness of WeakMap entries, so we delay
      * visting entries.
      */
-    eagerlyTraceWeakMaps = JS_FALSE;
+    eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
 }
 
 void
 GCMarker::stop()
 {
     JS_ASSERT(isDrained());
 
     JS_ASSERT(started);
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -768,17 +768,17 @@ NoteJSChildTracerShim(JSTracer *trc, voi
 
 static inline void
 NoteGCThingJSChildren(JSRuntime *rt, void *p, JSGCTraceKind traceKind,
                       nsCycleCollectionTraversalCallback &cb)
 {
     MOZ_ASSERT(rt);
     TraversalTracer trc(cb);
     JS_TracerInit(&trc, rt, NoteJSChildTracerShim);
-    trc.eagerlyTraceWeakMaps = false;
+    trc.eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
     JS_TraceChildren(&trc, p, traceKind);
 }
 
 static inline void
 NoteGCThingXPCOMChildren(js::Class *clasp, JSObject *obj,
                          nsCycleCollectionTraversalCallback &cb)
 {
     MOZ_ASSERT(clasp);
@@ -2390,17 +2390,17 @@ public:
          * or is a cross-compartment wrapper. In the former case, we don't need to
          * represent these edges in the CC graph because JS objects are not ref counted.
          * In the latter case, the JS engine keeps a map of these wrappers, which we
          * iterate over.
          */
         TraversalTracer trc(cb);
         JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
         JS_TracerInit(&trc, rt, NoteJSChildTracerShim);
-        trc.eagerlyTraceWeakMaps = false;
+        trc.eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
         js::VisitGrayWrapperTargets(c, NoteJSChildGrayWrapperShim, &trc);
 
         /*
          * To find C++ children of things in the compartment, we scan every JS Object in
          * the compartment. Only JS Objects can have C++ children.
          */
         js::IterateGrayObjects(c, TraverseObjectShim, &cb);