Bug 1046945 - Move ExposeGCThingToActiveJS to js::gc:: and use the typed wrappers instead; r=jonco
authorTerrence Cole <terrence@mozilla.com>
Thu, 31 Jul 2014 12:14:17 -0700
changeset 198216 6cd505eece11eb1c9a6f88cf2d047adb66ae24b6
parent 198215 5b871cc94344bb4fe7a164e1cdd1303c541433d7
child 198217 5abc37293afb7e65a2be633aaec63699a7550359
push id27264
push usernigelbabu@gmail.com
push dateThu, 07 Aug 2014 03:31:37 +0000
treeherdermozilla-central@afcb3af79d09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1046945
milestone34.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 1046945 - Move ExposeGCThingToActiveJS to js::gc:: and use the typed wrappers instead; r=jonco
js/public/GCAPI.h
js/public/Value.h
js/src/jswatchpoint.cpp
js/src/vm/Debugger.cpp
js/xpconnect/src/xpcpublic.h
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -432,47 +432,63 @@ class JS_PUBLIC_API(AutoCheckCannotGC) :
 
 /*
  * Unsets the gray bit for anything reachable from |thing|. |kind| should not be
  * JSTRACE_SHAPE. |thing| should be non-null.
  */
 extern JS_FRIEND_API(bool)
 UnmarkGrayGCThingRecursively(void *thing, JSGCTraceKind kind);
 
+} /* namespace JS */
+
+namespace js {
+namespace gc {
+
+static MOZ_ALWAYS_INLINE void
+ExposeGCThingToActiveJS(void *thing, JSGCTraceKind kind)
+{
+    MOZ_ASSERT(kind != JSTRACE_SHAPE);
+
+    JS::shadow::Runtime *rt = GetGCThingRuntime(thing);
+#ifdef JSGC_GENERATIONAL
+    /*
+     * GC things residing in the nursery cannot be gray: they have no mark bits.
+     * All live objects in the nursery are moved to tenured at the beginning of
+     * each GC slice, so the gray marker never sees nursery things.
+     */
+    if (IsInsideNursery((Cell *)thing))
+        return;
+#endif
+    if (JS::IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing, kind))
+        JS::IncrementalReferenceBarrier(thing, kind);
+    else if (JS::GCThingIsMarkedGray(thing))
+        JS::UnmarkGrayGCThingRecursively(thing, kind);
+}
+
+} /* namespace gc */
+} /* namespace js */
+
+namespace JS {
+
 /*
  * This should be called when an object that is marked gray is exposed to the JS
  * engine (by handing it to running JS code or writing it into live JS
  * data). During incremental GC, since the gray bits haven't been computed yet,
  * we conservatively mark the object black.
  */
 static MOZ_ALWAYS_INLINE void
-ExposeGCThingToActiveJS(void *thing, JSGCTraceKind kind)
+ExposeObjectToActiveJS(JSObject *obj)
 {
-    MOZ_ASSERT(kind != JSTRACE_SHAPE);
-
-    shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing);
-#ifdef JSGC_GENERATIONAL
-    /*
-     * GC things residing in the nursery cannot be gray: they have no mark bits.
-     * All live objects in the nursery are moved to tenured at the beginning of
-     * each GC slice, so the gray marker never sees nursery things.
-     */
-    if (js::gc::IsInsideNursery((js::gc::Cell *)thing))
-        return;
-#endif
-    if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing, kind))
-        IncrementalReferenceBarrier(thing, kind);
-    else if (GCThingIsMarkedGray(thing))
-        UnmarkGrayGCThingRecursively(thing, kind);
+    js::gc::ExposeGCThingToActiveJS(obj, JSTRACE_OBJECT);
 }
 
 static MOZ_ALWAYS_INLINE void
-ExposeObjectToActiveJS(JSObject *obj)
+ExposeScriptToActiveJS(JSScript *script)
 {
-    ExposeGCThingToActiveJS(obj, JSTRACE_OBJECT);
+    js::gc::ExposeGCThingToActiveJS(script, JSTRACE_SCRIPT);
 }
 
 /*
  * If a GC is currently marking, mark the object black.
  */
 static MOZ_ALWAYS_INLINE void
 MarkGCThingAsLive(JSRuntime *rt_, void *thing, JSGCTraceKind kind)
 {
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1348,17 +1348,17 @@ IsOptimizedPlaceholderMagicValue(const V
     }
     return false;
 }
 
 static MOZ_ALWAYS_INLINE void
 ExposeValueToActiveJS(const Value &v)
 {
     if (v.isMarkable())
-        ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind());
+        js::gc::ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind());
 }
 
 /************************************************************************/
 
 static inline Value
 NullValue()
 {
     Value v;
--- a/js/src/jswatchpoint.cpp
+++ b/js/src/jswatchpoint.cpp
@@ -84,17 +84,17 @@ WatchpointMap::unwatch(JSObject *obj, js
                        JSWatchPointHandler *handlerp, JSObject **closurep)
 {
     if (Map::Ptr p = map.lookup(WatchKey(obj, id))) {
         if (handlerp)
             *handlerp = p->value().handler;
         if (closurep) {
             // Read barrier to prevent an incorrectly gray closure from escaping the
             // watchpoint. See the comment before UnmarkGrayChildren in gc/Marking.cpp
-            JS::ExposeGCThingToActiveJS(p->value().closure, JSTRACE_OBJECT);
+            JS::ExposeObjectToActiveJS(p->value().closure);
             *closurep = p->value().closure;
         }
         map.remove(p);
     }
 }
 
 void
 WatchpointMap::unwatchObject(JSObject *obj)
@@ -132,17 +132,17 @@ WatchpointMap::triggerWatchpoint(JSConte
         if (Shape *shape = obj->nativeLookup(cx, id)) {
             if (shape->hasSlot())
                 old = obj->nativeGetSlot(shape->slot());
         }
     }
 
     // Read barrier to prevent an incorrectly gray closure from escaping the
     // watchpoint. See the comment before UnmarkGrayChildren in gc/Marking.cpp
-    JS::ExposeGCThingToActiveJS(closure, JSTRACE_OBJECT);
+    JS::ExposeObjectToActiveJS(closure);
 
     /* Call the handler. */
     return handler(cx, obj, id, old, vp.address(), closure);
 }
 
 bool
 WatchpointMap::markCompartmentIteratively(JSCompartment *c, JSTracer *trc)
 {
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2869,17 +2869,17 @@ Debugger::findAllGlobals(JSContext *cx, 
             continue;
 
         if (global) {
             /*
              * We pulled |global| out of nowhere, so it's possible that it was
              * marked gray by XPConnect. Since we're now exposing it to JS code,
              * we need to mark it black.
              */
-            JS::ExposeGCThingToActiveJS(global, JSTRACE_OBJECT);
+            JS::ExposeObjectToActiveJS(global);
 
             RootedValue globalValue(cx, ObjectValue(*global));
             if (!dbg->wrapDebuggeeValue(cx, &globalValue))
                 return false;
             if (!NewbornArrayPush(cx, result, globalValue))
                 return false;
         }
     }
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -188,17 +188,17 @@ xpc_IsGrayGCThing(void *thing)
 // reachable from an XPConnect root. Implemented in nsXPConnect.cpp.
 extern bool
 xpc_GCThingIsGrayCCThing(void *thing);
 
 inline JSScript *
 xpc_UnmarkGrayScript(JSScript *script)
 {
     if (script)
-        JS::ExposeGCThingToActiveJS(script, JSTRACE_SCRIPT);
+        JS::ExposeScriptToActiveJS(script);
 
     return script;
 }
 
 // If aVariant is an XPCVariant, this marks the object to be in aGeneration.
 // This also unmarks the gray JSObject.
 extern void
 xpc_MarkInCCGeneration(nsISupports* aVariant, uint32_t aGeneration);