mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 742570 - Change API for compartment GCs (r=igor)
This commit is contained in:
parent
2f8a8308b9
commit
6149e805bc
@ -3891,6 +3891,7 @@ WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking,
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
js::PrepareForFullGC(JS_GetRuntime(aCx));
|
||||
if (aShrinking) {
|
||||
js::ShrinkingGC(aCx, js::gcreason::DOM_WORKER);
|
||||
}
|
||||
|
@ -32,7 +32,11 @@ GC(JSContext *cx, unsigned argc, jsval *vp)
|
||||
size_t preBytes = cx->runtime->gcBytes;
|
||||
#endif
|
||||
|
||||
JS_CompartmentGC(cx, comp);
|
||||
if (comp)
|
||||
PrepareCompartmentForGC(comp);
|
||||
else
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GCForReason(cx, gcreason::API);
|
||||
|
||||
char buf[256] = { '\0' };
|
||||
#ifndef JS_MORE_DETERMINISTIC
|
||||
|
@ -2859,27 +2859,12 @@ JS_IsGCMarkingTracer(JSTracer *trc)
|
||||
return IS_GC_MARKING_TRACER(trc);
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_CompartmentGC(JSContext *cx, JSCompartment *comp)
|
||||
{
|
||||
AssertNoGC(cx);
|
||||
|
||||
/* We cannot GC the atoms compartment alone; use a full GC instead. */
|
||||
JS_ASSERT(comp != cx->runtime->atomsCompartment);
|
||||
|
||||
if (comp) {
|
||||
PrepareCompartmentForGC(comp);
|
||||
GC(cx, GC_NORMAL, gcreason::API);
|
||||
} else {
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GC(cx, GC_NORMAL, gcreason::API);
|
||||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_GC(JSContext *cx)
|
||||
{
|
||||
JS_CompartmentGC(cx, NULL);
|
||||
AssertNoGC(cx);
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GC(cx, GC_NORMAL, gcreason::API);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
@ -132,33 +132,33 @@ JS_NewObjectWithUniqueType(JSContext *cx, JSClass *clasp, JSObject *proto, JSObj
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::GCForReason(JSContext *cx, gcreason::Reason reason)
|
||||
js::PrepareCompartmentForGC(JSCompartment *comp)
|
||||
{
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GC(cx, GC_NORMAL, reason);
|
||||
comp->scheduleGC();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::CompartmentGCForReason(JSContext *cx, JSCompartment *comp, gcreason::Reason reason)
|
||||
js::PrepareForFullGC(JSRuntime *rt)
|
||||
{
|
||||
/* We cannot GC the atoms compartment alone; use a full GC instead. */
|
||||
JS_ASSERT(comp != cx->runtime->atomsCompartment);
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
c->scheduleGC();
|
||||
}
|
||||
|
||||
PrepareCompartmentForGC(comp);
|
||||
JS_FRIEND_API(void)
|
||||
js::GCForReason(JSContext *cx, gcreason::Reason reason)
|
||||
{
|
||||
GC(cx, GC_NORMAL, reason);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::ShrinkingGC(JSContext *cx, gcreason::Reason reason)
|
||||
{
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GC(cx, GC_SHRINK, reason);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::IncrementalGC(JSContext *cx, gcreason::Reason reason)
|
||||
{
|
||||
PrepareForFullGC(cx->runtime);
|
||||
GCSlice(cx, GC_NORMAL, reason);
|
||||
}
|
||||
|
||||
|
@ -667,10 +667,20 @@ enum Reason {
|
||||
} /* namespace gcreason */
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
GCForReason(JSContext *cx, gcreason::Reason reason);
|
||||
PrepareCompartmentForGC(JSCompartment *comp);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
CompartmentGCForReason(JSContext *cx, JSCompartment *comp, gcreason::Reason reason);
|
||||
PrepareForFullGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* When triggering a GC using one of the functions below, it is first necessary
|
||||
* to select the compartments to be collected. To do this, you can call
|
||||
* PrepareCompartmentForGC on each compartment, or you can call PrepareForFullGC
|
||||
* to select all compartments. Failing to select any compartment is an error.
|
||||
*/
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
GCForReason(JSContext *cx, gcreason::Reason reason);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
ShrinkingGC(JSContext *cx, gcreason::Reason reason);
|
||||
|
@ -2824,19 +2824,6 @@ GCHelperThread::doSweep()
|
||||
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
void
|
||||
PrepareForFullGC(JSRuntime *rt)
|
||||
{
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
c->scheduleGC();
|
||||
}
|
||||
|
||||
void
|
||||
PrepareCompartmentForGC(JSCompartment *comp)
|
||||
{
|
||||
comp->scheduleGC();
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
static bool
|
||||
|
@ -1386,9 +1386,6 @@ ShrinkGCBuffers(JSRuntime *rt);
|
||||
extern void
|
||||
PrepareForFullGC(JSRuntime *rt);
|
||||
|
||||
extern void
|
||||
PrepareCompartmentForGC(JSCompartment *comp);
|
||||
|
||||
/*
|
||||
* Kinds of js_GC invocation.
|
||||
*/
|
||||
|
@ -3620,6 +3620,7 @@ nsXPCComponents_Utils::GetWeakReference(const JS::Value &object, JSContext *cx,
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::ForceGC(JSContext *cx)
|
||||
{
|
||||
js::PrepareForFullGC(JS_GetRuntime(cx));
|
||||
js::GCForReason(cx, js::gcreason::COMPONENT_UTILS);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3628,6 +3629,7 @@ nsXPCComponents_Utils::ForceGC(JSContext *cx)
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::ForceShrinkingGC(JSContext *cx)
|
||||
{
|
||||
js::PrepareForFullGC(JS_GetRuntime(cx));
|
||||
js::ShrinkingGC(cx, js::gcreason::COMPONENT_UTILS);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3655,6 +3657,7 @@ class PreciseGCRunnable : public nsRunnable
|
||||
}
|
||||
}
|
||||
|
||||
js::PrepareForFullGC(JS_GetRuntime(mCx));
|
||||
if (mShrinking)
|
||||
js::ShrinkingGC(mCx, js::gcreason::COMPONENT_UTILS);
|
||||
else
|
||||
|
@ -414,6 +414,7 @@ nsXPConnect::Collect(PRUint32 reason, PRUint32 kind)
|
||||
return;
|
||||
|
||||
JSContext *cx = ccx.GetJSContext();
|
||||
JSRuntime *rt = GetRuntime()->GetJSRuntime();
|
||||
|
||||
// We want to scan the current thread for GC roots only if it was in a
|
||||
// request prior to the Collect call to avoid false positives during the
|
||||
@ -423,6 +424,7 @@ nsXPConnect::Collect(PRUint32 reason, PRUint32 kind)
|
||||
js::AutoSkipConservativeScan ascs(cx);
|
||||
MOZ_ASSERT(reason < js::gcreason::NUM_REASONS);
|
||||
js::gcreason::Reason gcreason = (js::gcreason::Reason)reason;
|
||||
js::PrepareForFullGC(rt);
|
||||
if (kind == nsGCShrinking) {
|
||||
js::ShrinkingGC(cx, gcreason);
|
||||
} else if (kind == nsGCIncremental) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user