From 9fe7caac91132f87776e72c6b79da762c9abe0bc Mon Sep 17 00:00:00 2001 From: Ciro Spaciari MacBook Date: Wed, 13 May 2026 16:53:13 -0700 Subject: [PATCH] [JSC] Make CodeBlock old-age TTL configurable via Options Adds four Double options with the existing hardcoded values as defaults: interpreterThunkTimeToLiveSeconds = 5.0 baselineJITTimeToLiveSeconds = 15.0 dfgJITTimeToLiveSeconds = 20.0 ftlJITTimeToLiveSeconds = 60.0 and reads them in CodeBlock.cpp timeToLive() in place of the hardcoded literals. Behavior is unchanged at defaults; embedders can now tune the old-age jettison window per tier (e.g. via BUN_JSC_* env vars in Bun) without choosing between the production 5-60 s table and the stress-test useEagerCodeBlockJettisonTiming 10-120 ms table. The useEagerCodeBlockJettisonTiming path is unchanged and still short-circuits before these options are read. --- Source/JavaScriptCore/bytecode/CodeBlock.cpp | 8 ++++---- Source/JavaScriptCore/runtime/OptionsList.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp index 07e027b60868..b1454175db72 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp @@ -1282,15 +1282,15 @@ static Seconds NODELETE timeToLive(JITType jitType) switch (jitType) { case JITType::InterpreterThunk: - return 5_s; + return Seconds(Options::interpreterThunkTimeToLiveSeconds()); case JITType::BaselineJIT: // Effectively 10 additional seconds, since BaselineJIT and // InterpreterThunk share a CodeBlock. - return 15_s; + return Seconds(Options::baselineJITTimeToLiveSeconds()); case JITType::DFGJIT: - return 20_s; + return Seconds(Options::dfgJITTimeToLiveSeconds()); case JITType::FTLJIT: - return 60_s; + return Seconds(Options::ftlJITTimeToLiveSeconds()); default: return Seconds::infinity(); } diff --git a/Source/JavaScriptCore/runtime/OptionsList.h b/Source/JavaScriptCore/runtime/OptionsList.h index 631571757017..d9b39d6971d3 100644 --- a/Source/JavaScriptCore/runtime/OptionsList.h +++ b/Source/JavaScriptCore/runtime/OptionsList.h @@ -436,6 +436,10 @@ bool hasCapacityToUseLargeGigacage(); v(Bool, dumpHeapOnLowMemory, false, Normal, "Dump a heap dump when the memory handler is triggered. Use alongside $vm.triggerMemoryPressure() and enableStrongRefTracker."_s) \ v(Bool, forceCodeBlockToJettisonDueToOldAge, false, Normal, "If true, this means that anytime we can jettison a CodeBlock due to old age, we do."_s) \ v(Bool, useEagerCodeBlockJettisonTiming, false, Normal, "If true, the time slices for jettisoning a CodeBlock due to old age are shrunk significantly."_s) \ + v(Double, interpreterThunkTimeToLiveSeconds, 5.0, Normal, "Seconds before an InterpreterThunk CodeBlock is eligible for old-age jettison."_s) \ + v(Double, baselineJITTimeToLiveSeconds, 15.0, Normal, "Seconds before a BaselineJIT CodeBlock is eligible for old-age jettison."_s) \ + v(Double, dfgJITTimeToLiveSeconds, 20.0, Normal, "Seconds before a DFGJIT CodeBlock is eligible for old-age jettison."_s) \ + v(Double, ftlJITTimeToLiveSeconds, 60.0, Normal, "Seconds before an FTLJIT CodeBlock is eligible for old-age jettison."_s) \ \ v(Bool, useTypeProfiler, false, Normal, nullptr) \ v(Bool, useControlFlowProfiler, false, Normal, nullptr) \