Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d545f589c8b77bfa599eed91f845687ed97c2e2b
https://github.com/WebKit/WebKit/commit/d545f589c8b77bfa599eed91f845687ed97c2e2b
Author: Sosuke Suzuki <[email protected]>
Date: 2026-08-29 (Sat, 29 Aug 2026)
Changed paths:
A
JSTests/stress/dfg-string-replace-regexp-unicode-empty-match-surrogate-pair.js
M Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
Log Message:
-----------
[JSC] DFG `StringReplace` constant folding steps into a surrogate pair after
an empty match for unicode RegExps
https://bugs.webkit.org/show_bug.cgi?id=322889
Reviewed by Yusuke Suzuki.
DFGStrengthReductionPhase folds String.prototype.replace with a constant
string, RegExp and replacement by replaying the match loop at compile
time. After an empty match it advanced by one code unit regardless of
the /u and /v flags, while replaceUsingRegExpSearch advances past a
surrogate pair, so "a\u{1F600}b".replace(/(?:)/gu, "-") changed its
result once the function reached the DFG.
Advance past a lead/trail pair after an empty match when the RegExp is
unicode, the same way the runtime does.
Test:
JSTests/stress/dfg-string-replace-regexp-unicode-empty-match-surrogate-pair.js
*
JSTests/stress/dfg-string-replace-regexp-unicode-empty-match-surrogate-pair.js:
Added.
(shouldBe):
(replaceUnicodeSets):
(replaceAllUnicode):
(replaceLoneLead):
(replaceNonUnicode):
* Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
Canonical link: https://commits.webkit.org/320099@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications