Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 34141654c7a5bedfa41619da1f9513b39a8dd694
https://github.com/WebKit/WebKit/commit/34141654c7a5bedfa41619da1f9513b39a8dd694
Author: Sosuke Suzuki <[email protected]>
Date: 2026-09-03 (Thu, 03 Sep 2026)
Changed paths:
A JSTests/microbenchmarks/regexp-test-non-constant-minimum-length.js
A JSTests/stress/regexp-test-minimum-length-filter.js
M Source/JavaScriptCore/b3/B3AbstractHeapRepository.h
M Source/JavaScriptCore/dfg/DFGGraph.cpp
M Source/JavaScriptCore/dfg/DFGGraph.h
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
M Source/JavaScriptCore/runtime/RegExp.cpp
M Source/JavaScriptCore/runtime/RegExp.h
M Source/JavaScriptCore/runtime/RegExpInlines.h
Log Message:
-----------
[JSC] `RegExp#test` should fast-fail on an input shorter than the pattern's
minimum size
https://bugs.webkit.org/show_bug.cgi?id=322689
Reviewed by Yusuke Suzuki.
RegExp#test on a non-constant RegExp (routes held in an array, as
path-to-regexp routers do) always goes through the operation, RegExp::match
and the Yarr JIT prologue, only for the first Yarr instruction to reject an
input shorter than the pattern's minimum size.
Yarr already computes that minimum (PatternDisjunction::m_minimumSize) but
keeps it only in the transient YarrPattern. Keep a copy in RegExp (it fits in
existing padding), filled in once the pattern has compiled so that a pattern
whose bytecode compilation fails still enters compilation and throws, and
compare against it in RegExp::matchInline and inline in DFG / FTL RegExpTest.
Global and sticky patterns are excluded from the inline check since they
start at lastIndex and reset it on failure.
Baseline
Patched
regexp-test-non-constant-minimum-length 53.1873+-1.0025 ^
10.5381+-1.0628 ^ definitely 5.0471x faster
regexp-prototype-match-short-string 17.4101+-0.1716 ^
16.8127+-0.2799 ^ definitely 1.0355x faster
Tests: JSTests/microbenchmarks/regexp-test-non-constant-minimum-length.js
JSTests/stress/regexp-test-minimum-length-filter.js
* JSTests/microbenchmarks/regexp-test-non-constant-minimum-length.js: Added.
(dispatch):
* JSTests/stress/regexp-test-minimum-length-filter.js: Added.
(shouldBe):
(testUntyped):
(shortObject.toString):
(longObject.toString):
(nonConstantString):
(rope):
(testConstantUnicode):
(testConstantGlobal):
(testConstantZeroMinimum):
(testHoisted):
(shouldThrow):
(testUncompilable):
* Source/JavaScriptCore/b3/B3AbstractHeapRepository.h:
* Source/JavaScriptCore/dfg/DFGGraph.cpp:
(JSC::DFG::constantRegExpFor):
(JSC::DFG::Graph::tryGetConstantRegExpFirstCharacterBitmap):
(JSC::DFG::Graph::tryGetConstantRegExpTestMinimumSize):
* Source/JavaScriptCore/dfg/DFGGraph.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileRegExpTest):
(JSC::DFG::SpeculativeJIT::emitRegExpTestWithFilter):
(JSC::DFG::SpeculativeJIT::tryEmitRegExpTestFirstCharacterFilter): Deleted.
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::emitRegExpMinimumLengthFilterGuards):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/runtime/RegExp.cpp:
(JSC::RegExp::finishCreation):
(JSC::RegExp::compile):
(JSC::RegExp::compileMatchOnly):
(JSC::RegExp::deleteCode):
* Source/JavaScriptCore/runtime/RegExp.h:
* Source/JavaScriptCore/runtime/RegExpInlines.h:
(JSC::RegExp::matchInline):
Canonical link: https://commits.webkit.org/320487@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications