diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp index 36980cd9bc7b..8896f2349b39 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp @@ -905,7 +905,7 @@ CodeBlock::~CodeBlock() #if ENABLE(JIT) && USE(BUN_JSC_ADDITIONS) if (jitType() == JITType::BaselineJIT) - static_cast(m_jitCode.get())->m_ownerWentAwayAt = ApproximateTime::now(); + static_cast(m_jitCode.get())->m_ownerWentAwayAt = vm.heap.lastGCBoundaryTime(); #endif if (JITCode::isBaselineCode(jitType())) { diff --git a/Source/JavaScriptCore/heap/Heap.cpp b/Source/JavaScriptCore/heap/Heap.cpp index f4596abb7baf..9d8c4ff2704a 100644 --- a/Source/JavaScriptCore/heap/Heap.cpp +++ b/Source/JavaScriptCore/heap/Heap.cpp @@ -1244,7 +1244,7 @@ void Heap::releaseUnusedSharedBaselineCode() #if ENABLE(JIT) && USE(BUN_JSC_ADDITIONS) if (!Options::useBaselineJITCodeSharing() || !Options::useExecutionCountForCodeBlockAging()) return; - ApproximateTime cutoff = ApproximateTime::now() - CodeBlock::timeToLive(JITType::BaselineJIT) * Options::codeBlockAgingLeaseMultiplier(); + MonotonicTime cutoff = m_currentGCStartTime - CodeBlock::timeToLive(JITType::BaselineJIT) * Options::codeBlockAgingLeaseMultiplier(); // End phase: the world is stopped and allocation already is, so no HeapIterationScope. auto visit = [&] (HeapCell* cell, HeapCell::Kind) { auto& code = static_cast(cell)->m_unlinkedBaselineCode; diff --git a/Source/JavaScriptCore/heap/Heap.h b/Source/JavaScriptCore/heap/Heap.h index 479e4b9b498d..0d3d10e94047 100644 --- a/Source/JavaScriptCore/heap/Heap.h +++ b/Source/JavaScriptCore/heap/Heap.h @@ -393,6 +393,10 @@ class Heap { MutatorState mutatorState() const { return m_mutatorState; } std::optional collectionScope() const { return m_collectionScope; } std::optional lastCollectionScope() const { return m_lastCollectionScope; } +#if USE(BUN_JSC_ADDITIONS) + // The most recent collection boundary: the end of the last one, or the start of the one in progress. + MonotonicTime lastGCBoundaryTime() const { return std::max(m_lastGCEndTime, m_currentGCStartTime); } +#endif bool hasHeapAccess() const { return m_worldState.load() & hasAccessBit; } bool worldIsStopped() const { return m_worldIsStopped; } bool worldIsRunning() const { return !worldIsStopped(); } diff --git a/Source/JavaScriptCore/jit/BaselineJITCode.h b/Source/JavaScriptCore/jit/BaselineJITCode.h index 097b15a6feb5..264389f64e5c 100644 --- a/Source/JavaScriptCore/jit/BaselineJITCode.h +++ b/Source/JavaScriptCore/jit/BaselineJITCode.h @@ -27,7 +27,7 @@ #include "CallLinkInfo.h" #include "JITCode.h" -#include +#include #include "JITCodeMap.h" #include "PropertyInlineCache.h" #include @@ -107,9 +107,11 @@ class BaselineJITCode : public DirectJITCode, public MathICHolder { JITCodeMap m_jitCodeMap; JITConstantPool m_constantPool; std::unique_ptr m_pcToCodeOriginMap; - // When a CodeBlock running this code last went away; UnlinkedCodeBlock's cached copy is released once no CodeBlock - // has used it for a while (Heap::releaseUnusedSharedBaselineCode). - ApproximateTime m_ownerWentAwayAt { ApproximateTime::now() }; +#if USE(BUN_JSC_ADDITIONS) + // The collection in which a CodeBlock running this code last died (Heap::lastGCBoundaryTime); UnlinkedCodeBlock's + // cached copy is released once no CodeBlock has used it for a while (Heap::releaseUnusedSharedBaselineCode). + MonotonicTime m_ownerWentAwayAt; +#endif private: // The percentage of ValueProfiles that had some profiling data in them. double m_livenessRate { 0 };