From bb6f14aeaadad333483feda1c838c045493bfcc9 Mon Sep 17 00:00:00 2001 From: Itms Date: Wed, 3 Sep 2025 12:04:22 +0200 Subject: [PATCH] Use new GC API to turn off nursery size heuristic Refs: #7714 --- source/scriptinterface/Context.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/source/scriptinterface/Context.cpp b/source/scriptinterface/Context.cpp index 11c79f82df..8acd88d374 100644 --- a/source/scriptinterface/Context.cpp +++ b/source/scriptinterface/Context.cpp @@ -20,7 +20,6 @@ #include "Context.h" #include "js/Modules.h" -#include "js/friend/PerformanceHint.h" #include "lib/alignment.h" #include "lib/debug.h" #include "ps/Profile.h" @@ -137,6 +136,9 @@ Context::Context(int contextSize, uint32_t heapGrowthBytesGCTrigger): JS_SetGCParameter(m_cx, JSGC_SLICE_TIME_BUDGET_MS, 6); JS_SetGCParameter(m_cx, JSGC_MIN_LAST_DITCH_GC_PERIOD, 0); + // Turn off nursery size heuristic. + // See https://gitea.wildfiregames.com/0ad/0ad/issues/7714 for details. + JS_SetGCParameter(m_cx, JSGC_NURSERY_MAX_TIME_GOAL_MS, 0); JS_SetOffthreadIonCompilationEnabled(m_cx, true); @@ -155,10 +157,6 @@ Context::Context(int contextSize, uint32_t heapGrowthBytesGCTrigger): JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_STRING_MITIGATIONS, 0); JS_SetGlobalJitCompilerOption(m_cx, JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS, 0); - // Workaround to turn off nursery size heuristic. - // See https://gitea.wildfiregames.com/0ad/0ad/issues/7714 for details. - js::gc::SetPerformanceHint(m_cx, js::gc::PerformanceHint::InPageLoad); - Engine::GetSingleton().RegisterContext(m_cx); JS::SetJobQueue(m_cx, m_JobQueue.get()); @@ -179,9 +177,6 @@ Context::~Context() JS::SetModuleResolveHook(runtime, nullptr); JS::SetModuleMetadataHook(runtime, nullptr); - // Switch back to normal performance mode to avoid assertion in debug mode. - js::gc::SetPerformanceHint(m_cx, js::gc::PerformanceHint::Normal); - JS_DestroyContext(m_cx); Engine::GetSingleton().UnRegisterContext(m_cx); } @@ -291,4 +286,4 @@ void Context::PrepareZonesForIncrementalGC() const JS::PrepareZoneForGC(m_cx, js::GetRealmZone(realm)); } -} // namespace Script \ No newline at end of file +} // namespace Script