Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptContext.cpp
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | #endif | ||||
if (gcBytes > m_ContextSize / 2) | if (gcBytes > m_ContextSize / 2) | ||||
{ | { | ||||
if (JS::IsIncrementalGCInProgress(m_cx)) | if (JS::IsIncrementalGCInProgress(m_cx)) | ||||
{ | { | ||||
#if GC_DEBUG_PRINT | #if GC_DEBUG_PRINT | ||||
printf("Finishing incremental GC because gcBytes > m_ContextSize / 2. \n"); | printf("Finishing incremental GC because gcBytes > m_ContextSize / 2. \n"); | ||||
#endif | #endif | ||||
PrepareCompartmentsForIncrementalGC(); | PrepareCompartmentsForIncrementalGC(); | ||||
JS::FinishIncrementalGC(m_cx, JS::gcreason::REFRESH_FRAME); | JS::FinishIncrementalGC(m_cx, JS::gcreason::API); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (gcBytes > m_ContextSize * 0.75) | if (gcBytes > m_ContextSize * 0.75) | ||||
{ | { | ||||
ShrinkingGC(); | ShrinkingGC(); | ||||
#if GC_DEBUG_PRINT | #if GC_DEBUG_PRINT | ||||
printf("Running shrinking GC because gcBytes > m_ContextSize * 0.75. \n"); | printf("Running shrinking GC because gcBytes > m_ContextSize * 0.75. \n"); | ||||
Show All 13 Lines | |||||
#if GC_DEBUG_PRINT | #if GC_DEBUG_PRINT | ||||
if (!JS::IsIncrementalGCInProgress(m_cx)) | if (!JS::IsIncrementalGCInProgress(m_cx)) | ||||
printf("Starting incremental GC \n"); | printf("Starting incremental GC \n"); | ||||
else | else | ||||
printf("Running incremental GC slice \n"); | printf("Running incremental GC slice \n"); | ||||
#endif | #endif | ||||
PrepareCompartmentsForIncrementalGC(); | PrepareCompartmentsForIncrementalGC(); | ||||
if (!JS::IsIncrementalGCInProgress(m_cx)) | if (!JS::IsIncrementalGCInProgress(m_cx)) | ||||
JS::StartIncrementalGC(m_cx, GC_NORMAL, JS::gcreason::REFRESH_FRAME, GCSliceTimeBudget); | JS::StartIncrementalGC(m_cx, GC_NORMAL, JS::gcreason::API, GCSliceTimeBudget); | ||||
else | else | ||||
JS::IncrementalGCSlice(m_cx, JS::gcreason::REFRESH_FRAME, GCSliceTimeBudget); | JS::IncrementalGCSlice(m_cx, JS::gcreason::API, GCSliceTimeBudget); | ||||
} | } | ||||
m_LastGCBytes = gcBytes; | m_LastGCBytes = gcBytes; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void ScriptContext::ShrinkingGC() | void ScriptContext::ShrinkingGC() | ||||
{ | { | ||||
JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_ZONE); | JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_ZONE); | ||||
JS::PrepareForFullGC(m_cx); | JS::PrepareForFullGC(m_cx); | ||||
JS::GCForReason(m_cx, GC_SHRINK, JS::gcreason::REFRESH_FRAME); | JS::GCForReason(m_cx, GC_SHRINK, JS::gcreason::API); | ||||
JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_INCREMENTAL); | JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_INCREMENTAL); | ||||
} | } | ||||
void ScriptContext::PrepareCompartmentsForIncrementalGC() const | void ScriptContext::PrepareCompartmentsForIncrementalGC() const | ||||
{ | { | ||||
for (JSCompartment* const& cmpt : m_Compartments) | for (JSCompartment* const& cmpt : m_Compartments) | ||||
JS::PrepareZoneForGC(js::GetCompartmentZone(cmpt)); | JS::PrepareZoneForGC(js::GetCompartmentZone(cmpt)); | ||||
} | } |
Wildfire Games · Phabricator