Bug 933313: Per-worker generational GC for PJS. r=jandem r=terrence r=shu r=jonco
This commit is contained in:
@@ -2824,16 +2824,26 @@ JSObject::setSlotSpan(ThreadSafeContext *cx, HandleObject obj, uint32_t span)
|
||||
return true;
|
||||
}
|
||||
|
||||
// This will not run the garbage collector. If a nursery cannot accomodate the slot array
|
||||
// an attempt will be made to place the array in the tenured area.
|
||||
static HeapSlot *
|
||||
AllocateSlots(ThreadSafeContext *cx, JSObject *obj, uint32_t nslots)
|
||||
{
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
if (cx->isJSContext())
|
||||
return cx->asJSContext()->runtime()->gc.nursery.allocateSlots(cx->asJSContext(), obj, nslots);
|
||||
#endif
|
||||
#ifdef JSGC_FJGENERATIONAL
|
||||
if (cx->isForkJoinContext())
|
||||
return cx->asForkJoinContext()->fjNursery().allocateSlots(obj, nslots);
|
||||
#endif
|
||||
return cx->pod_malloc<HeapSlot>(nslots);
|
||||
}
|
||||
|
||||
// This will not run the garbage collector. If a nursery cannot accomodate the slot array
|
||||
// an attempt will be made to place the array in the tenured area.
|
||||
//
|
||||
// If this returns null then the old slots will be left alone.
|
||||
static HeapSlot *
|
||||
ReallocateSlots(ThreadSafeContext *cx, JSObject *obj, HeapSlot *oldSlots,
|
||||
uint32_t oldCount, uint32_t newCount)
|
||||
@@ -2841,8 +2851,14 @@ ReallocateSlots(ThreadSafeContext *cx, JSObject *obj, HeapSlot *oldSlots,
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
if (cx->isJSContext()) {
|
||||
return cx->asJSContext()->runtime()->gc.nursery.reallocateSlots(cx->asJSContext(),
|
||||
obj, oldSlots,
|
||||
oldCount, newCount);
|
||||
obj, oldSlots,
|
||||
oldCount, newCount);
|
||||
}
|
||||
#endif
|
||||
#ifdef JSGC_FJGENERATIONAL
|
||||
if (cx->isForkJoinContext()) {
|
||||
return cx->asForkJoinContext()->fjNursery().reallocateSlots(obj, oldSlots,
|
||||
oldCount, newCount);
|
||||
}
|
||||
#endif
|
||||
return (HeapSlot *)cx->realloc_(oldSlots, oldCount * sizeof(HeapSlot),
|
||||
@@ -2914,10 +2930,14 @@ JSObject::growSlots(ThreadSafeContext *cx, HandleObject obj, uint32_t oldCount,
|
||||
static void
|
||||
FreeSlots(ThreadSafeContext *cx, HeapSlot *slots)
|
||||
{
|
||||
// Note: threads without a JSContext do not have access to nursery allocated things.
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
// Note: threads without a JSContext do not have access to GGC nursery allocated things.
|
||||
if (cx->isJSContext())
|
||||
return cx->asJSContext()->runtime()->gc.nursery.freeSlots(cx->asJSContext(), slots);
|
||||
#endif
|
||||
#ifdef JSGC_FJGENERATIONAL
|
||||
if (cx->isForkJoinContext())
|
||||
return cx->asForkJoinContext()->fjNursery().freeSlots(slots);
|
||||
#endif
|
||||
js_free(slots);
|
||||
}
|
||||
@@ -3134,6 +3154,8 @@ JSObject::maybeDensifySparseElements(js::ExclusiveContext *cx, HandleObject obj)
|
||||
return ED_OK;
|
||||
}
|
||||
|
||||
// This will not run the garbage collector. If a nursery cannot accomodate the element array
|
||||
// an attempt will be made to place the array in the tenured area.
|
||||
static ObjectElements *
|
||||
AllocateElements(ThreadSafeContext *cx, JSObject *obj, uint32_t nelems)
|
||||
{
|
||||
@@ -3141,10 +3163,16 @@ AllocateElements(ThreadSafeContext *cx, JSObject *obj, uint32_t nelems)
|
||||
if (cx->isJSContext())
|
||||
return cx->asJSContext()->runtime()->gc.nursery.allocateElements(cx->asJSContext(), obj, nelems);
|
||||
#endif
|
||||
#ifdef JSGC_FJGENERATIONAL
|
||||
if (cx->isForkJoinContext())
|
||||
return cx->asForkJoinContext()->fjNursery().allocateElements(obj, nelems);
|
||||
#endif
|
||||
|
||||
return static_cast<js::ObjectElements *>(cx->malloc_(nelems * sizeof(HeapValue)));
|
||||
}
|
||||
|
||||
// This will not run the garbage collector. If a nursery cannot accomodate the element array
|
||||
// an attempt will be made to place the array in the tenured area.
|
||||
static ObjectElements *
|
||||
ReallocateElements(ThreadSafeContext *cx, JSObject *obj, ObjectElements *oldHeader,
|
||||
uint32_t oldCount, uint32_t newCount)
|
||||
@@ -3152,8 +3180,14 @@ ReallocateElements(ThreadSafeContext *cx, JSObject *obj, ObjectElements *oldHead
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
if (cx->isJSContext()) {
|
||||
return cx->asJSContext()->runtime()->gc.nursery.reallocateElements(cx->asJSContext(), obj,
|
||||
oldHeader, oldCount,
|
||||
newCount);
|
||||
oldHeader, oldCount,
|
||||
newCount);
|
||||
}
|
||||
#endif
|
||||
#ifdef JSGC_FJGENERATIONAL
|
||||
if (cx->isForkJoinContext()) {
|
||||
return cx->asForkJoinContext()->fjNursery().reallocateElements(obj, oldHeader,
|
||||
oldCount, newCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user