зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1117098 - Move definition of external GC API methods out of jsfriendapi.cpp r=terrence
This commit is contained in:
Родитель
f1d487e594
Коммит
8dbec73ae1
|
@ -141,13 +141,13 @@ enum Reason {
|
|||
/*
|
||||
* Schedule the given zone to be collected as part of the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareZoneForGC(Zone *zone);
|
||||
|
||||
/*
|
||||
* Schedule all zones to be collected in the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareForFullGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -155,21 +155,21 @@ PrepareForFullGC(JSRuntime *rt);
|
|||
* previous incremental slice must be selected in subsequent slices as well.
|
||||
* This function selects those slices automatically.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
PrepareForIncrementalGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* Returns true if any zone in the system has been scheduled for GC with one of
|
||||
* the functions above or by the JS engine.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsGCScheduled(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* Undoes the effect of the Prepare methods above. The given zone will not be
|
||||
* collected in the next GC.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
SkipZoneForGC(Zone *zone);
|
||||
|
||||
/*
|
||||
|
@ -187,7 +187,7 @@ SkipZoneForGC(Zone *zone);
|
|||
* to objects will be cleared and all unreferenced objects will be removed from
|
||||
* the system.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
GCForReason(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason);
|
||||
|
||||
/*
|
||||
|
@ -222,7 +222,7 @@ GCForReason(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason);
|
|||
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
|
||||
* shorter than the requested interval.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
StartIncrementalGC(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason,
|
||||
int64_t millis = 0);
|
||||
|
||||
|
@ -234,7 +234,7 @@ StartIncrementalGC(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason re
|
|||
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
|
||||
* shorter than the requested interval.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
|
||||
|
||||
/*
|
||||
|
@ -243,7 +243,7 @@ IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
|
|||
* this is equivalent to GCForReason. When this function returns,
|
||||
* IsIncrementalGCInProgress(rt) will always be false.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason);
|
||||
|
||||
enum GCProgress {
|
||||
|
@ -263,7 +263,7 @@ enum GCProgress {
|
|||
GC_CYCLE_END
|
||||
};
|
||||
|
||||
struct JS_FRIEND_API(GCDescription) {
|
||||
struct JS_PUBLIC_API(GCDescription) {
|
||||
bool isCompartment_;
|
||||
|
||||
explicit GCDescription(bool isCompartment)
|
||||
|
@ -281,7 +281,7 @@ typedef void
|
|||
* callback may be used for GC notifications as well as to perform additional
|
||||
* marking.
|
||||
*/
|
||||
extern JS_FRIEND_API(GCSliceCallback)
|
||||
extern JS_PUBLIC_API(GCSliceCallback)
|
||||
SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback);
|
||||
|
||||
/*
|
||||
|
@ -290,7 +290,7 @@ SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback);
|
|||
* There is not currently a way to re-enable incremental GC once it has been
|
||||
* disabled on the runtime.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
DisableIncrementalGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -301,7 +301,7 @@ DisableIncrementalGC(JSRuntime *rt);
|
|||
* GCDescription returned by GCSliceCallback may help narrow down the cause if
|
||||
* collections are not happening incrementally when expected.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalGCEnabled(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -310,20 +310,20 @@ IsIncrementalGCEnabled(JSRuntime *rt);
|
|||
* pointer callbacks. There is not currently a way to re-enable compacting GC
|
||||
* once it has been disabled on the runtime.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
DisableCompactingGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* Returns true if compacting GC is enabled.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsCompactingGCEnabled(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
* Returns true while an incremental GC is ongoing, both when actively
|
||||
* collecting and between slices.
|
||||
*/
|
||||
JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalGCInProgress(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -331,29 +331,29 @@ IsIncrementalGCInProgress(JSRuntime *rt);
|
|||
* This is generally only true when running mutator code in-between GC slices.
|
||||
* At other times, the barrier may be elided for performance.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalBarrierNeeded(JSRuntime *rt);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsIncrementalBarrierNeeded(JSContext *cx);
|
||||
|
||||
/*
|
||||
* Notify the GC that a reference to a GC thing is about to be overwritten.
|
||||
* These methods must be called if IsIncrementalBarrierNeeded.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalReferenceBarrier(GCCellPtr thing);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalValueBarrier(const Value &v);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
IncrementalObjectBarrier(JSObject *obj);
|
||||
|
||||
/*
|
||||
* Returns true if the most recent GC ran incrementally.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
WasIncrementalGC(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -365,7 +365,7 @@ WasIncrementalGC(JSRuntime *rt);
|
|||
*/
|
||||
|
||||
/* Ensure that generational GC is disabled within some scope. */
|
||||
class JS_FRIEND_API(AutoDisableGenerationalGC)
|
||||
class JS_PUBLIC_API(AutoDisableGenerationalGC)
|
||||
{
|
||||
js::gc::GCRuntime *gc;
|
||||
#ifdef JS_GC_ZEAL
|
||||
|
@ -381,7 +381,7 @@ class JS_FRIEND_API(AutoDisableGenerationalGC)
|
|||
* Returns true if generational allocation and collection is currently enabled
|
||||
* on the given runtime.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsGenerationalGCEnabled(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
@ -389,7 +389,7 @@ IsGenerationalGCEnabled(JSRuntime *rt);
|
|||
* of GCs that have been run, but is guaranteed to be monotonically increasing
|
||||
* with GC activity.
|
||||
*/
|
||||
extern JS_FRIEND_API(size_t)
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
GetGCNumber();
|
||||
|
||||
/*
|
||||
|
@ -397,7 +397,7 @@ GetGCNumber();
|
|||
* back to the system incase it is needed soon afterwards. This call forces the
|
||||
* GC to return this memory immediately.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
ShrinkGCBuffers(JSRuntime *rt);
|
||||
|
||||
/*
|
||||
|
|
|
@ -153,74 +153,6 @@ JS_NewObjectWithUniqueType(JSContext *cx, const JSClass *clasp, HandleObject pro
|
|||
return obj;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::PrepareZoneForGC(Zone *zone)
|
||||
{
|
||||
zone->scheduleGC();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::PrepareForFullGC(JSRuntime *rt)
|
||||
{
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next())
|
||||
zone->scheduleGC();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::PrepareForIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
if (!JS::IsIncrementalGCInProgress(rt))
|
||||
return;
|
||||
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->wasGCStarted())
|
||||
PrepareZoneForGC(zone);
|
||||
}
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsGCScheduled(JSRuntime *rt)
|
||||
{
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->isGCScheduled())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::SkipZoneForGC(Zone *zone)
|
||||
{
|
||||
zone->unscheduleGC();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::GCForReason(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason)
|
||||
{
|
||||
MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
|
||||
rt->gc.gc(gckind, reason);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::StartIncrementalGC(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason, int64_t millis)
|
||||
{
|
||||
MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
|
||||
rt->gc.startGC(gckind, reason, millis);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis)
|
||||
{
|
||||
rt->gc.gcSlice(reason, millis);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason)
|
||||
{
|
||||
rt->gc.finishGC(reason);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSPrincipals *)
|
||||
JS_GetCompartmentPrincipals(JSCompartment *compartment)
|
||||
{
|
||||
|
@ -1065,12 +997,6 @@ js::IsContextRunningJS(JSContext *cx)
|
|||
return cx->currentlyRunning();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JS::GCSliceCallback)
|
||||
JS::SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback)
|
||||
{
|
||||
return rt->gc.setSliceCallback(callback);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(int64_t)
|
||||
GetMaxGCPauseSinceClear(JSRuntime *rt)
|
||||
{
|
||||
|
@ -1083,160 +1009,12 @@ ClearMaxGCPauseAccumulator(JSRuntime *rt)
|
|||
return rt->gc.stats.clearMaxGCPauseAccumulator();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::WasIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGc();
|
||||
}
|
||||
|
||||
char16_t *
|
||||
JS::GCDescription::formatMessage(JSRuntime *rt) const
|
||||
{
|
||||
return rt->gc.stats.formatMessage();
|
||||
}
|
||||
|
||||
char16_t *
|
||||
JS::GCDescription::formatJSON(JSRuntime *rt, uint64_t timestamp) const
|
||||
{
|
||||
return rt->gc.stats.formatJSON(timestamp);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::NotifyDidPaint(JSRuntime *rt)
|
||||
{
|
||||
rt->gc.notifyDidPaint();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsIncrementalGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGCEnabled();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsIncrementalGCInProgress(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGCInProgress() && !rt->gc.isVerifyPreBarriersEnabled();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::DisableIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
rt->gc.disallowIncrementalGC();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::DisableCompactingGC(JSRuntime *rt)
|
||||
{
|
||||
#ifdef JSGC_COMPACTING
|
||||
rt->gc.disableCompactingGC();
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsCompactingGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
#ifdef JSGC_COMPACTING
|
||||
return rt->gc.isCompactingGCEnabled();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
JS::AutoDisableGenerationalGC::AutoDisableGenerationalGC(JSRuntime *rt)
|
||||
: gc(&rt->gc)
|
||||
#ifdef JS_GC_ZEAL
|
||||
, restartVerifier(false)
|
||||
#endif
|
||||
{
|
||||
#ifdef JS_GC_ZEAL
|
||||
restartVerifier = gc->endVerifyPostBarriers();
|
||||
#endif
|
||||
gc->disableGenerationalGC();
|
||||
}
|
||||
|
||||
JS::AutoDisableGenerationalGC::~AutoDisableGenerationalGC()
|
||||
{
|
||||
gc->enableGenerationalGC();
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (restartVerifier) {
|
||||
MOZ_ASSERT(gc->isGenerationalGCEnabled());
|
||||
gc->startVerifyPostBarriers();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS::IsGenerationalGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isGenerationalGCEnabled();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsIncrementalBarrierNeeded(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.state() == gc::MARK && !rt->isHeapBusy();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS::IsIncrementalBarrierNeeded(JSContext *cx)
|
||||
{
|
||||
return IsIncrementalBarrierNeeded(cx->runtime());
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::IncrementalObjectBarrier(JSObject *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(!obj->zone()->runtimeFromMainThread()->isHeapMajorCollecting());
|
||||
|
||||
JSObject::writeBarrierPre(obj);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::IncrementalReferenceBarrier(GCCellPtr thing)
|
||||
{
|
||||
if (!thing)
|
||||
return;
|
||||
|
||||
if (thing.isString() && StringIsPermanentAtom(thing.toString()))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
Zone *zone = thing.isObject()
|
||||
? thing.toObject()->zone()
|
||||
: thing.asCell()->asTenured().zone();
|
||||
MOZ_ASSERT(!zone->runtimeFromMainThread()->isHeapMajorCollecting());
|
||||
#endif
|
||||
|
||||
switch(thing.kind()) {
|
||||
case JSTRACE_OBJECT: return JSObject::writeBarrierPre(thing.toObject());
|
||||
case JSTRACE_STRING: return JSString::writeBarrierPre(thing.toString());
|
||||
case JSTRACE_SCRIPT: return JSScript::writeBarrierPre(thing.toScript());
|
||||
case JSTRACE_SYMBOL: return JS::Symbol::writeBarrierPre(thing.toSymbol());
|
||||
case JSTRACE_LAZY_SCRIPT:
|
||||
return LazyScript::writeBarrierPre(static_cast<LazyScript*>(thing.asCell()));
|
||||
case JSTRACE_JITCODE:
|
||||
return jit::JitCode::writeBarrierPre(static_cast<jit::JitCode*>(thing.asCell()));
|
||||
case JSTRACE_SHAPE:
|
||||
return Shape::writeBarrierPre(static_cast<Shape*>(thing.asCell()));
|
||||
case JSTRACE_BASE_SHAPE:
|
||||
return BaseShape::writeBarrierPre(static_cast<BaseShape*>(thing.asCell()));
|
||||
case JSTRACE_TYPE_OBJECT:
|
||||
return types::TypeObject::writeBarrierPre(static_cast<types::TypeObject *>(thing.asCell()));
|
||||
default:
|
||||
MOZ_CRASH("Invalid trace kind in IncrementalReferenceBarrier.");
|
||||
}
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::IncrementalValueBarrier(const Value &v)
|
||||
{
|
||||
js::HeapValue::writeBarrierPre(v);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS::PokeGC(JSRuntime *rt)
|
||||
{
|
||||
|
|
226
js/src/jsgc.cpp
226
js/src/jsgc.cpp
|
@ -6455,7 +6455,7 @@ js::PrepareForDebugGC(JSRuntime *rt)
|
|||
JS::PrepareForFullGC(rt);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS_PUBLIC_API(void)
|
||||
JS::ShrinkGCBuffers(JSRuntime *rt)
|
||||
{
|
||||
rt->gc.shrinkBuffers();
|
||||
|
@ -6978,7 +6978,7 @@ js::gc::AssertGCThingHasType(js::gc::Cell *cell, JSGCTraceKind kind)
|
|||
MOZ_ASSERT(MapAllocToTraceKind(cell->asTenured().getAllocKind()) == kind);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(size_t)
|
||||
JS_PUBLIC_API(size_t)
|
||||
JS::GetGCNumber()
|
||||
{
|
||||
JSRuntime *rt = js::TlsPerThreadData.get()->runtimeFromMainThread();
|
||||
|
@ -7116,3 +7116,225 @@ js::gc::CheckHashTablesAfterMovingGC(JSRuntime *rt)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::PrepareZoneForGC(Zone *zone)
|
||||
{
|
||||
zone->scheduleGC();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::PrepareForFullGC(JSRuntime *rt)
|
||||
{
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next())
|
||||
zone->scheduleGC();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::PrepareForIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
if (!JS::IsIncrementalGCInProgress(rt))
|
||||
return;
|
||||
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->wasGCStarted())
|
||||
PrepareZoneForGC(zone);
|
||||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsGCScheduled(JSRuntime *rt)
|
||||
{
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->isGCScheduled())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SkipZoneForGC(Zone *zone)
|
||||
{
|
||||
zone->unscheduleGC();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::GCForReason(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason)
|
||||
{
|
||||
MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
|
||||
rt->gc.gc(gckind, reason);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::StartIncrementalGC(JSRuntime *rt, JSGCInvocationKind gckind, gcreason::Reason reason, int64_t millis)
|
||||
{
|
||||
MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
|
||||
rt->gc.startGC(gckind, reason, millis);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis)
|
||||
{
|
||||
rt->gc.gcSlice(reason, millis);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason)
|
||||
{
|
||||
rt->gc.finishGC(reason);
|
||||
}
|
||||
|
||||
char16_t *
|
||||
JS::GCDescription::formatMessage(JSRuntime *rt) const
|
||||
{
|
||||
return rt->gc.stats.formatMessage();
|
||||
}
|
||||
|
||||
char16_t *
|
||||
JS::GCDescription::formatJSON(JSRuntime *rt, uint64_t timestamp) const
|
||||
{
|
||||
return rt->gc.stats.formatJSON(timestamp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::GCSliceCallback)
|
||||
JS::SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback)
|
||||
{
|
||||
return rt->gc.setSliceCallback(callback);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::DisableIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
rt->gc.disallowIncrementalGC();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsIncrementalGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGCEnabled();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::DisableCompactingGC(JSRuntime *rt)
|
||||
{
|
||||
#ifdef JSGC_COMPACTING
|
||||
rt->gc.disableCompactingGC();
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsCompactingGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
#ifdef JSGC_COMPACTING
|
||||
return rt->gc.isCompactingGCEnabled();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsIncrementalGCInProgress(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGCInProgress() && !rt->gc.isVerifyPreBarriersEnabled();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsIncrementalBarrierNeeded(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.state() == gc::MARK && !rt->isHeapBusy();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsIncrementalBarrierNeeded(JSContext *cx)
|
||||
{
|
||||
return IsIncrementalBarrierNeeded(cx->runtime());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::IncrementalReferenceBarrier(GCCellPtr thing)
|
||||
{
|
||||
if (!thing)
|
||||
return;
|
||||
|
||||
if (thing.isString() && StringIsPermanentAtom(thing.toString()))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
Zone *zone = thing.isObject()
|
||||
? thing.toObject()->zone()
|
||||
: thing.asCell()->asTenured().zone();
|
||||
MOZ_ASSERT(!zone->runtimeFromMainThread()->isHeapMajorCollecting());
|
||||
#endif
|
||||
|
||||
switch(thing.kind()) {
|
||||
case JSTRACE_OBJECT: return JSObject::writeBarrierPre(thing.toObject());
|
||||
case JSTRACE_STRING: return JSString::writeBarrierPre(thing.toString());
|
||||
case JSTRACE_SCRIPT: return JSScript::writeBarrierPre(thing.toScript());
|
||||
case JSTRACE_SYMBOL: return JS::Symbol::writeBarrierPre(thing.toSymbol());
|
||||
case JSTRACE_LAZY_SCRIPT:
|
||||
return LazyScript::writeBarrierPre(static_cast<LazyScript*>(thing.asCell()));
|
||||
case JSTRACE_JITCODE:
|
||||
return jit::JitCode::writeBarrierPre(static_cast<jit::JitCode*>(thing.asCell()));
|
||||
case JSTRACE_SHAPE:
|
||||
return Shape::writeBarrierPre(static_cast<Shape*>(thing.asCell()));
|
||||
case JSTRACE_BASE_SHAPE:
|
||||
return BaseShape::writeBarrierPre(static_cast<BaseShape*>(thing.asCell()));
|
||||
case JSTRACE_TYPE_OBJECT:
|
||||
return types::TypeObject::writeBarrierPre(static_cast<types::TypeObject *>(thing.asCell()));
|
||||
default:
|
||||
MOZ_CRASH("Invalid trace kind in IncrementalReferenceBarrier.");
|
||||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::IncrementalValueBarrier(const Value &v)
|
||||
{
|
||||
js::HeapValue::writeBarrierPre(v);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::IncrementalObjectBarrier(JSObject *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(!obj->zone()->runtimeFromMainThread()->isHeapMajorCollecting());
|
||||
|
||||
JSObject::writeBarrierPre(obj);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::WasIncrementalGC(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isIncrementalGc();
|
||||
}
|
||||
|
||||
JS::AutoDisableGenerationalGC::AutoDisableGenerationalGC(JSRuntime *rt)
|
||||
: gc(&rt->gc)
|
||||
#ifdef JS_GC_ZEAL
|
||||
, restartVerifier(false)
|
||||
#endif
|
||||
{
|
||||
#ifdef JS_GC_ZEAL
|
||||
restartVerifier = gc->endVerifyPostBarriers();
|
||||
#endif
|
||||
gc->disableGenerationalGC();
|
||||
}
|
||||
|
||||
JS::AutoDisableGenerationalGC::~AutoDisableGenerationalGC()
|
||||
{
|
||||
gc->enableGenerationalGC();
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (restartVerifier) {
|
||||
MOZ_ASSERT(gc->isGenerationalGCEnabled());
|
||||
gc->startVerifyPostBarriers();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::IsGenerationalGCEnabled(JSRuntime *rt)
|
||||
{
|
||||
return rt->gc.isGenerationalGCEnabled();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче