Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 186e2a91934e2dd2fe1f4e21b46c2135cca0fcbe
      
https://github.com/WebKit/WebKit/commit/186e2a91934e2dd2fe1f4e21b46c2135cca0fcbe
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    A JSTests/microbenchmarks/int32-to-string-int-cache-hit.js
    A JSTests/stress/to-string-int32-int-cache.js
    M Source/JavaScriptCore/b3/B3AbstractHeapRepository.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/runtime/NumericStrings.h

  Log Message:
  -----------
  [JSC] Inline `NumericStrings` int cache lookup in DFG and FTL 
`ToString(Int32)`
https://bugs.webkit.org/show_bug.cgi?id=317537

Reviewed by Yusuke Suzuki.

DFG and FTL already inline the NumericStrings small-int cache lookup
(values 0..1023) for ToString(Int32) with radix 10, but values outside
that range always take a vmCall to operationInt32ToStringWithValidRadix
even when the int cache would hit. The hash used by the int cache is
WTF::IntHash<int>, which is the rapidhash mum mixer that DFG/FTL already
emit inline for Map/Set hashing via rapidHashMix64.

Emit the same hash inline, index into m_intCache, and return the cached
JSString directly when the slot's key matches and its jsString is
non-null. Only the miss path (collision or empty slot) calls into the
runtime.

The radix-10 Int32 case is split out into compileInt32ToStringRadix10 so
that the 64-bit and 32-bit DFG backends can diverge cleanly: the 64-bit
backend adds the int-cache lookup (rapidHashMix64 needs 128-bit multiply)
while the 32-bit backend keeps the existing small-int-only path.

                                        baseline                  patched

int32-to-string-int-cache-hit       27.1492+-0.3189     ^     11.4171+-0.1587   
     ^ definitely 2.3779x faster

* JSTests/microbenchmarks/int32-to-string-int-cache-hit.js: Added.
* JSTests/stress/to-string-int32-int-cache.js: Added.
* Source/JavaScriptCore/b3/B3AbstractHeapRepository.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
* Source/JavaScriptCore/runtime/NumericStrings.h:

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



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

Reply via email to