Skip to content

[JSC] DFG RegExpTest asserts when the RegExp is also the argument - #74030

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/regexp-test-minimum-length-filter-same-register
Sep 15, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/regexp-test-minimum-length-filter-same-register

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

d22fa24

[JSC] DFG `RegExpTest` asserts when the RegExp is also the argument
https://bugs.webkit.org/show_bug.cgi?id=324211

Reviewed by Yusuke Suzuki.

In `regExp.test(regExp)` both operands of RegExpTest are the same node, so
baseGPR and argumentGPR are the same register. Debug builds then hit
ASSERT(noOverlap(baseGPR, argumentGPR, scratch1GPR, scratch2GPR)) in
emitRegExpMinimumLengthFilterGuards(), added in 320487@main.

The function only reads baseGPR and argumentGPR and only writes the scratch
registers, so assert each input against the scratch registers separately, as
emitRegExpStickyFirstCharacterFilterGuards() already does. The generated code
does not change: a RegExp argument is not a string, so it branches to the
slow path call before the guards run.

Test: JSTests/stress/regexp-test-regexp-is-also-the-argument.js

* JSTests/stress/regexp-test-regexp-is-also-the-argument.js: Added.
(shouldBe):
(testConstant):
(testConstantAnchored):
(testConstantSticky):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::emitRegExpMinimumLengthFilterGuards):

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

dd3477f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2   🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2   🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt   🧪 api-mac-debug ✅ 🧪 jsc-wpe
✅ 🧪 jsc-x86-64   🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp   🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 🧪 merge ✅ 🛠 vision-sim   🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
  🛠 watch
✅ 🛠 watch-sim

@sosukesuzuki
sosukesuzuki requested a review from a team as a code owner September 15, 2026 03:58
@sosukesuzuki sosukesuzuki self-assigned this Sep 15, 2026
@sosukesuzuki sosukesuzuki added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Sep 15, 2026
@sosukesuzuki sosukesuzuki added the merge-queue Applied to send a pull request to merge-queue label Sep 15, 2026
https://bugs.webkit.org/show_bug.cgi?id=324211

Reviewed by Yusuke Suzuki.

In `regExp.test(regExp)` both operands of RegExpTest are the same node, so
baseGPR and argumentGPR are the same register. Debug builds then hit
ASSERT(noOverlap(baseGPR, argumentGPR, scratch1GPR, scratch2GPR)) in
emitRegExpMinimumLengthFilterGuards(), added in 320487@main.

The function only reads baseGPR and argumentGPR and only writes the scratch
registers, so assert each input against the scratch registers separately, as
emitRegExpStickyFirstCharacterFilterGuards() already does. The generated code
does not change: a RegExp argument is not a string, so it branches to the
slow path call before the guards run.

Test: JSTests/stress/regexp-test-regexp-is-also-the-argument.js

* JSTests/stress/regexp-test-regexp-is-also-the-argument.js: Added.
(shouldBe):
(testConstant):
(testConstantAnchored):
(testConstantSticky):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::emitRegExpMinimumLengthFilterGuards):

Canonical link: https://commits.webkit.org/321146@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/regexp-test-minimum-length-filter-same-register branch from dd3477f to d22fa24 Compare September 15, 2026 07:29
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 321146@main (d22fa24): https://commits.webkit.org/321146@main

Reviewed commits have been landed. Closing PR #74030 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants