Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6124a5f9c43785a89d933967c63a50d8fae79eea
      
https://github.com/WebKit/WebKit/commit/6124a5f9c43785a89d933967c63a50d8fae79eea
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    M JSTests/stress/date-get-full-year-jit.js
    M JSTests/stress/date-get-utc-full-year-jit.js
    A JSTests/stress/date-local-fields-invalidated-across-tz-change.js
    M JSTests/stress/date-set-time.js
    M JSTests/stress/intl-datetimeformat-cache-dst-transition.js
    M 
JSTests/stress/intl-datetimeformat-default-formatter-stale-across-tz-change.js
    M JSTests/stress/intl-datetimeformat-stale-data-across-tz-change.js
    M JSTests/stress/intl-datetimeformat-stale-data-evicted-across-tz-change.js
    M Source/JavaScriptCore/CMakeLists.txt
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M 
Source/JavaScriptCore/SaferCPPExpectations/MemoryUnsafeCastCheckerExpectations
    M Source/JavaScriptCore/b3/B3AbstractHeapRepository.h
    M Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
    M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
    M Source/JavaScriptCore/dfg/DFGClobberize.h
    M Source/JavaScriptCore/dfg/DFGDoesGC.cpp
    M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
    M Source/JavaScriptCore/dfg/DFGNode.h
    M Source/JavaScriptCore/dfg/DFGNodeType.h
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.h
    M Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGSafeToExecute.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
    M Source/JavaScriptCore/ftl/FTLCapabilities.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/heap/Heap.h
    M Source/JavaScriptCore/runtime/DateConstructor.cpp
    M Source/JavaScriptCore/runtime/DateConversion.cpp
    M Source/JavaScriptCore/runtime/DateConversion.h
    M Source/JavaScriptCore/runtime/DateInstance.cpp
    M Source/JavaScriptCore/runtime/DateInstance.h
    R Source/JavaScriptCore/runtime/DateInstanceCache.h
    M Source/JavaScriptCore/runtime/DatePrototype.cpp
    M Source/JavaScriptCore/runtime/JSDateMath.cpp
    M Source/JavaScriptCore/runtime/JSDateMath.h
    A Source/JavaScriptCore/runtime/PlainGregorianDateTime.h
    M Source/JavaScriptCore/runtime/TemporalNow.cpp
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/JavaScriptCore/runtime/temporal/core/InstantCore.cpp
    M Source/WebCore/WebCorePrefix.h

  Log Message:
  -----------
  [JSC] Make DateInstance non-destructible
https://bugs.webkit.org/show_bug.cgi?id=323204
rdar://186444744

Reviewed by Yijia Huang.

This patch makes DateInstance non-destructible by adding packed
breakdown of date time information instead of having RefPtr<DateInstanceData>.

PlainGregorianDateTime packs a broken-down date into one word (year, month,
monthDay, weekDay, hour, minute, second, UTC offset, isDST). monthDay is never
zero in a real date, so those bits double as the validity tag. That leaves the
all-zero payload to mean "never computed" and a separate stale marker to mean
"computed for a time value that has since changed", which Date#setTime writes.

To keep Date breakdown computation faster, instead of DateInstanceCache,
we have BrokenDownDateCache, which quickly looks up the past breakdown
result, so without having RefPtr to DateInstanceData, we can keep
breakdown fast.

In DFG / FTL, we introduce DateGetStorage which extracts
PlainGregorianDateTime (64bit data), so subsequent accessors (e.g.
getFullYear) can take this storage and extract the necessary number.

Also, when timezone gets changed, we scan the heap and invalidate all
DateInstance breakdown data. That is the improvement compared to old
DateInstanceData as we were invalidating them only when this data is
still reachable from the cache.

Test: JSTests/stress/date-local-fields-invalidated-across-tz-change.js

* JSTests/stress/date-get-full-year-jit.js:
* JSTests/stress/date-get-utc-full-year-jit.js:
* JSTests/stress/date-local-fields-invalidated-across-tz-change.js: Added.
(expect):
(set read):
(check):
(setTimeout):
* JSTests/stress/date-set-time.js:
(setThenRead):
(i.shouldBe.setThenRead):
(i.reference.getFullYear):
(i.reference.getMonth):
(i.reference.getDate):
(i.reference.getHours):
* JSTests/stress/intl-datetimeformat-cache-dst-transition.js:
(setTimeout):
* 
JSTests/stress/intl-datetimeformat-default-formatter-stale-across-tz-change.js:
(setTimeout):
* JSTests/stress/intl-datetimeformat-stale-data-across-tz-change.js:
* JSTests/stress/intl-datetimeformat-stale-data-evicted-across-tz-change.js:
(setTimeout):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* 
Source/JavaScriptCore/SaferCPPExpectations/MemoryUnsafeCastCheckerExpectations:
* Source/JavaScriptCore/b3/B3AbstractHeapRepository.h:
* Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* Source/JavaScriptCore/dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* Source/JavaScriptCore/dfg/DFGNode.h:
(JSC::DFG::Node::hasUTC):
(JSC::DFG::Node::isUTC):
(JSC::DFG::Node::hasHeapPrediction):
* Source/JavaScriptCore/dfg/DFGNodeType.h:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_NOEXCEPT_JIT_OPERATION):
(JSC::DFG::triggerFTLReplacementCompile):
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
(JSC::DFG::SpeculativeJIT::compileDateGetStorage):
(JSC::DFG::SpeculativeJIT::compileDateGetInt32OrNaN):
(JSC::DFG::SpeculativeJIT::compileDateGetMilliseconds):
(JSC::DFG::SpeculativeJIT::compileDateGetTime):
(JSC::DFG::SpeculativeJIT::compileDateSet):
(JSC::DFG::SpeculativeJIT::compileDateGet): Deleted.
* Source/JavaScriptCore/ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::Heap):
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/runtime/DateConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/DateConversion.cpp:
(JSC::formatDateTime):
* Source/JavaScriptCore/runtime/DateConversion.h:
* Source/JavaScriptCore/runtime/DateInstance.cpp:
(JSC::useSharedCacheFor):
(JSC::DateInstance::calculateGregorianDateTime const):
(JSC::DateInstance::calculateGregorianDateTimeUTC const):
* Source/JavaScriptCore/runtime/DateInstance.h:
* Source/JavaScriptCore/runtime/DateInstanceCache.h: Removed.
* Source/JavaScriptCore/runtime/DatePrototype.cpp:
(JSC::formateDateInstance):
(JSC::BrokenDownDate::BrokenDownDate):
(JSC::fillStructuresUsingTimeArgs):
(JSC::fillStructuresUsingDateArgs):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
* Source/JavaScriptCore/runtime/JSDateMath.cpp:
(JSC::DateCache::gregorianDateTimeToMS):
(JSC::DateCache::yearMonthDayFromDaysWithCache):
(JSC::DateCache::computeGregorianDateTime):
(JSC::DateCache::msToGregorianDateTime):
(JSC::DateCache::localTimeOffset):
(JSC::DateCache::clearForTimeZoneChange):
(JSC::DateCache::cachedDateInstanceData): Deleted.
* Source/JavaScriptCore/runtime/JSDateMath.h:
(JSC::DateCache::noteCachedLocalGregorianDateTime):
(JSC::DateCache::takeMayHaveCachedLocalGregorianDateTime):
(JSC::DateCache::BrokenDownDateCache::get):
(JSC::DateCache::BrokenDownDateCache::set):
(JSC::DateCache::BrokenDownDateCache::reset):
(JSC::DateCache::BrokenDownDateCache::lookup):
* Source/JavaScriptCore/runtime/PlainGregorianDateTime.h: Added.
(JSC::PlainGregorianDateTime::PlainGregorianDateTime):
(JSC::PlainGregorianDateTime::year const):
(JSC::PlainGregorianDateTime::month const):
(JSC::PlainGregorianDateTime::monthDay const):
(JSC::PlainGregorianDateTime::weekDay const):
(JSC::PlainGregorianDateTime::hour const):
(JSC::PlainGregorianDateTime::minute const):
(JSC::PlainGregorianDateTime::second const):
(JSC::PlainGregorianDateTime::utcOffsetInMinute const):
(JSC::PlainGregorianDateTime::isDST const):
(JSC::PlainGregorianDateTime::operator bool const):
(JSC::PlainGregorianDateTime::staleMarker):
(JSC::PlainGregorianDateTime::hasNeverBeenComputed const):
(JSC::PlainGregorianDateTime::payload const):
* Source/JavaScriptCore/runtime/TemporalNow.cpp:
(JSC::systemDateTime):
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::executeEntryScopeServicesOnEntry):
* Source/JavaScriptCore/runtime/temporal/core/InstantCore.cpp:
* Source/WebCore/WebCorePrefix.h:

Canonical link: https://commits.webkit.org/320364@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to