Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0d6cf47c3b1211a20135cc74ae54768dbeb1aa93
      
https://github.com/WebKit/WebKit/commit/0d6cf47c3b1211a20135cc74ae54768dbeb1aa93
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-09-03 (Thu, 03 Sep 2026)

  Changed paths:
    A JSTests/microbenchmarks/array-prototype-includes-int32-miss.js
    A JSTests/microbenchmarks/array-prototype-indexOf-double-long.js
    A JSTests/stress/array-indexof-includes-long-int32-double.js
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/runtime/ArrayPrototype.cpp
    M Source/JavaScriptCore/runtime/JSArray.cpp
    M Source/WTF/wtf/SIMDHelpers.h
    M Source/WTF/wtf/text/StringCommon.cpp
    M Source/WTF/wtf/text/StringCommon.h

  Log Message:
  -----------
  [JSC] Vectorize `Array#indexOf` and `Array#includes` on long Int32 and Double 
arrays
https://bugs.webkit.org/show_bug.cgi?id=323192

Reviewed by Yusuke Suzuki.

DFG and FTL compile ArrayIndexOf / ArrayIncludes on Int32 and Double arrays
into a scalar loop, while the C++ paths for Int32 arrays already scan the
butterfly with the vectorized WTF::find64. On a long array the JIT-compiled
code was slower per element than the interpreter, about 1.8x slower than V8.

When at least 32 elements remain, the JIT now calls a NOEXCEPT operation that
runs WTF::find64 / WTF::findDouble and keeps the inline loop for shorter scans;
the threshold is where the call overhead stops mattering on Apple Silicon.
findDouble is rewritten to share find64's unrolled kernel, since its aligned
variant was slower than the scalar loop, and the remaining scalar double
searches in the runtime call it too.

                                                   baseline                  
patched

array-prototype-indexOf-int32-from-contiguous
                                               13.2918+-0.4091           
13.0476+-0.3309          might be 1.0187x faster
array-prototype-includes-int32-from-contiguous
                                               12.9337+-0.0922           
12.8622+-0.4050
array-prototype-includes-int32-miss           285.7966+-0.9708     ^     
85.4147+-1.1408        ^ definitely 3.3460x faster
array-prototype-includes-double                12.5542+-0.5818     ^      
6.5374+-0.1602        ^ definitely 1.9204x faster
array-prototype-includes-int32                148.5482+-2.2786     ^     
53.7430+-0.5775        ^ definitely 2.7640x faster
array-prototype-indexOf-int32                 148.3728+-2.5853     ^     
53.8890+-0.9227        ^ definitely 2.7533x faster
array-prototype-includes-double-from-contiguous
                                               32.8554+-1.6434     ?     
32.8829+-1.2574        ?
array-prototype-indexOf-double-long           153.0529+-4.8413     ^     
62.5287+-1.7941        ^ definitely 2.4477x faster

Tests: JSTests/microbenchmarks/array-prototype-includes-int32-miss.js
       JSTests/microbenchmarks/array-prototype-indexOf-double-long.js
       JSTests/stress/array-indexof-includes-long-int32-double.js

* JSTests/microbenchmarks/array-prototype-includes-int32-miss.js: Added.
(test):
* JSTests/microbenchmarks/array-prototype-indexOf-double-long.js: Added.
(test):
* JSTests/stress/array-indexof-includes-long-int32-double.js: Added.
(shouldBe):
(int32IndexOf):
(int32IndexOfFrom):
(int32Includes):
(int32IncludesFrom):
(doubleIndexOf):
(doubleIndexOfFrom):
(doubleIncludes):
(doubleIncludesFrom):
(makeInt32Array):
(makeDoubleArray):
(let.length.of.lengths.3):
(let.length.of.lengths.0.5):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::arrayIncludesDouble):
(JSC::DFG::arrayIndexOfDouble):
(JSC::DFG::JSC_DEFINE_NOEXCEPT_JIT_OPERATION):
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArrayIndexOfOrArrayIncludes):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileArrayIndexOfOrArrayIncludes):
* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::fastIndexOf):
* Source/JavaScriptCore/runtime/JSArray.cpp:
(JSC::JSArray::fastIncludes):
* Source/WTF/wtf/SIMDHelpers.h:
(WTF::SIMD::splatDouble):
(WTF::SIMD::splat):
* Source/WTF/wtf/text/StringCommon.cpp:
(WTF::findFloatAlignedImpl):
(WTF::findDoubleAlignedImpl): Deleted.
* Source/WTF/wtf/text/StringCommon.h:
(WTF::find64BitLaneImpl):
(WTF::find64):
(WTF::findDouble):

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



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

Reply via email to