Bug 905382, part 1 - Implement a read barrier for GC things. r=jonco

This commit is contained in:
Andrew McCreight 2013-11-04 15:01:38 -08:00
parent 634fb697f0
commit 748cd6b364

View File

@ -311,6 +311,31 @@ 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 */