Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5efecc395404bead4efeb1b572adeca3274f3e9a
https://github.com/WebKit/WebKit/commit/5efecc395404bead4efeb1b572adeca3274f3e9a
Author: Yusuke Suzuki <[email protected]>
Date: 2026-04-29 (Wed, 29 Apr 2026)
Changed paths:
A JSTests/stress/string-index-of-empty.js
A JSTests/stress/string-last-index-of-large-fromindex.js
A JSTests/stress/string-last-index-of.js
M Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
M Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp
M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
M Source/JavaScriptCore/dfg/DFGClobberize.h
M Source/JavaScriptCore/dfg/DFGCloneHelper.h
M Source/JavaScriptCore/dfg/DFGDoesGC.cpp
M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
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.cpp
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
M Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
M Source/JavaScriptCore/ftl/FTLCapabilities.cpp
M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
M Source/JavaScriptCore/runtime/Intrinsic.h
M Source/JavaScriptCore/runtime/JSString.h
M Source/JavaScriptCore/runtime/JSStringInlines.h
M Source/JavaScriptCore/runtime/StringPrototype.cpp
M Source/WTF/wtf/SIMDHelpers.h
M Source/WTF/wtf/text/StringCommon.h
M Source/WTF/wtf/text/StringImpl.h
Log Message:
-----------
[JSC] Add String#lastIndexOf optimizations
https://bugs.webkit.org/show_bug.cgi?id=313583
rdar://175797508
Reviewed by Keith Miller and Sosuke Suzuki.
This patch implements String.prototype.lastIndexOf optimizations.
Basically almost all of code is copy-and-paste from existing
String.prototype.indexOf (e.g. DFG / FTL node modeling). We did some
clean up of normal C function based on the latest spec document to clean
up the other part of implementations in DFG / FTL (operations).
To make it fast, we also add SIMD handling of SIMD::reverseFind.
Mostly similar to SIMD::find, but we need to change the iteration
reversed, and introducing findLastNonZeroIndex.
Test: JSTests/stress/string-last-index-of.js
* JSTests/stress/string-index-of-empty.js: Added.
(assertEq):
(specIndexOf):
(specLastIndexOf):
(checkIndex):
(checkLast):
(checkBoth):
(exerciseEmptyNeedle):
(exerciseNonEmptyNeedleOnEmpty):
(idxEmpty):
(lastEmpty):
(idxEmptyAt):
(lastEmptyAt):
(idxOnEmpty):
(lastOnEmpty):
(warmEmpty):
(idxEmptyU):
(lastEmptyU):
(warmEmptyU):
(idxEmptyRope):
(lastEmptyRope):
(warmEmptyRope):
* JSTests/stress/string-last-index-of-large-fromindex.js: Added.
(specLastIndexOf):
(assertEq):
(check):
* JSTests/stress/string-last-index-of.js: Added.
(specLastIndexOf):
(assertEq):
(check):
(pos.valueOf):
(catch):
(100.n.0.n.1.filter):
(makeRope2):
(makeRope3):
(hotSlash):
(warmSingleChar):
(hotRope):
(warmRope):
(buildMiddleBailoutRope):
(buildMiddleOnly):
(hotMiddle):
(hotMixed8):
(hotMixed16):
(warmMiddleMixed):
* Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp:
(JSC::DFG::BackwardsPropagationPhase::propagate):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* Source/JavaScriptCore/dfg/DFGCloneHelper.h:
* Source/JavaScriptCore/dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* Source/JavaScriptCore/dfg/DFGNodeType.h:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
(JSC::DFG::stringLastIndexOfOneCharOperation):
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
* Source/JavaScriptCore/ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileStringIndexOf):
(JSC::FTL::DFG::LowerDFGToB3::compileStringLastIndexOf):
* Source/JavaScriptCore/runtime/Intrinsic.h:
* Source/JavaScriptCore/runtime/JSString.h:
* Source/JavaScriptCore/runtime/JSStringInlines.h:
(JSC::JSString::tryFindLastOneChar const):
* Source/JavaScriptCore/runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/WTF/wtf/SIMDHelpers.h:
(WTF::SIMD::findLastNonZeroIndex):
(WTF::SIMD::reverseFind):
* Source/WTF/wtf/text/StringCommon.h:
(WTF::reverseFind8):
(WTF::reverseFindImpl):
(WTF::reverseFind16):
(WTF::reverseFind32):
* Source/WTF/wtf/text/StringImpl.h:
(WTF::reverseFind):
Canonical link: https://commits.webkit.org/312307@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications