Bug 758034 - Add new JS APIs for GC (r=terrence)

This commit is contained in:
Bill McCloskey 2012-06-30 14:18:04 -07:00
parent 96e4284f11
commit 8906d657f9
4 changed files with 33 additions and 5 deletions

View File

@ -114,6 +114,18 @@ js::PrepareForFullGC(JSRuntime *rt)
c->scheduleGC();
}
JS_FRIEND_API(void)
js::PrepareForIncrementalGC(JSRuntime *rt)
{
if (rt->gcIncrementalState == gc::NO_INCREMENTAL)
return;
for (CompartmentsIter c(rt); !c.done(); c.next()) {
if (c->needsBarrier())
PrepareCompartmentForGC(c);
}
}
JS_FRIEND_API(bool)
js::IsGCScheduled(JSRuntime *rt)
{
@ -149,6 +161,12 @@ js::IncrementalGC(JSRuntime *rt, gcreason::Reason reason)
GCSlice(rt, GC_NORMAL, reason);
}
JS_FRIEND_API(void)
js::FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason)
{
GCFinalSlice(rt, GC_NORMAL, reason);
}
JS_FRIEND_API(void)
JS_ShrinkGCBuffers(JSRuntime *rt)
{
@ -758,10 +776,7 @@ NotifyDidPaint(JSRuntime *rt)
}
if (rt->gcIncrementalState != gc::NO_INCREMENTAL && !rt->gcInterFrameGC) {
for (CompartmentsIter c(rt); !c.done(); c.next()) {
if (c->needsBarrier())
PrepareCompartmentForGC(c);
}
PrepareForIncrementalGC(rt);
GCSlice(rt, GC_NORMAL, gcreason::REFRESH_FRAME);
}

View File

@ -632,6 +632,9 @@ PrepareCompartmentForGC(JSCompartment *comp);
extern JS_FRIEND_API(void)
PrepareForFullGC(JSRuntime *rt);
extern JS_FRIEND_API(void)
PrepareForIncrementalGC(JSRuntime *rt);
extern JS_FRIEND_API(bool)
IsGCScheduled(JSRuntime *rt);
@ -655,7 +658,7 @@ extern JS_FRIEND_API(void)
IncrementalGC(JSRuntime *rt, gcreason::Reason reason);
extern JS_FRIEND_API(void)
SetGCSliceTimeBudget(JSContext *cx, int64_t millis);
FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason);
enum GCProgress {
/*

View File

@ -3914,6 +3914,13 @@ GCSlice(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason)
Collect(rt, true, rt->gcSliceBudget, gckind, reason);
}
void
GCFinalSlice(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason)
{
Collect(rt, true, SliceBudget::Unlimited, gckind, reason);
}
void
GCDebugSlice(JSRuntime *rt, bool limit, int64_t objCount)
{

View File

@ -477,6 +477,9 @@ GC(JSRuntime *rt, JSGCInvocationKind gckind, js::gcreason::Reason reason);
extern void
GCSlice(JSRuntime *rt, JSGCInvocationKind gckind, js::gcreason::Reason reason);
extern void
GCFinalSlice(JSRuntime *rt, JSGCInvocationKind gckind, js::gcreason::Reason reason);
extern void
GCDebugSlice(JSRuntime *rt, bool limit, int64_t objCount);