Bug 905382, part 1 - Implement a read barrier for GC things. r=jonco
authorAndrew McCreight <continuation@gmail.com>
Mon, 25 Nov 2013 14:58:22 -0800
changeset 166607 3e9fd7620fb68084bf6eba880126056023e2ea5e
parent 166606 7822b78fe5aa788510f4692e0d866f220f4bf190
child 166608 f5a5f724bdc14a43ba3fb4d510990ee2868f7cc4
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs905382
milestone27.0a2
Bug 905382, part 1 - Implement a read barrier for GC things. r=jonco
js/public/GCAPI.h
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -306,11 +306,36 @@ ExposeValueToActiveJS(const Value &v)
 }
 
 static JS_ALWAYS_INLINE void
 ExposeObjectToActiveJS(JSObject *obj)
 {
     ExposeGCThingToActiveJS(obj, JSTRACE_OBJECT);
 }
 
+/*
+ * If a GC is currently marking, mark the object black.
+ */
+static JS_ALWAYS_INLINE void
+MarkGCThingAsLive(JSRuntime *rt_, void *thing, JSGCTraceKind kind)
+{
+    shadow::Runtime *rt = shadow::Runtime::asShadowRuntime(rt_);
+#ifdef JSGC_GENERATIONAL
+    /*
+     * Any object in the nursery will not be freed during any GC running at that time.
+     */
+    if (js::gc::IsInsideNursery(rt, thing))
+        return;
+#endif
+    if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind))
+        IncrementalReferenceBarrier(thing, kind);
+}
+
+static JS_ALWAYS_INLINE void
+MarkStringAsLive(Zone *zone, JSString *string)
+{
+    JSRuntime *rt = JS::shadow::Zone::asShadowZone(zone)->runtimeFromMainThread();
+    MarkGCThingAsLive(rt, string, JSTRACE_STRING);
+}
+
 } /* namespace JS */
 
 #endif /* js_GCAPI_h */