-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[JSC] RegExp.prototype's @@match and @@replace should use "flags" getter only #7281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
582aab2
to
d5ae907
Compare
…ter only https://bugs.webkit.org/show_bug.cgi?id=248605 Reviewed by NOBODY (OOPS!). This change implements recent spec change [1], aligning RegExp.prototype's @@match / @@replace with @@split / @@matchall to use only "flags" getter to check for flags, which is observable. Ensures that DFG watches and constant-folds all related invoked prototype getters, which was proven to be neutral on both JetStream2 and Speedometer2. [1]: tc39/ecma262#2791 * JSTests/test262/expectations.yaml: Mark 12 test cases as passing. * Source/JavaScriptCore/builtins/BuiltinNames.h: * Source/JavaScriptCore/builtins/RegExpPrototype.js: (linkTimeConstant.hasObservableSideEffectsForRegExpMatch): (linkTimeConstant.matchSlow): (overriddenName.string_appeared_here.replace): (linkTimeConstant.hasObservableSideEffectsForRegExpSplit): * Source/JavaScriptCore/builtins/StringPrototype.js: (linkTimeConstant.hasObservableSideEffectsForStringReplace): * Source/JavaScriptCore/bytecode/LinkTimeConstant.h: * Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * Source/JavaScriptCore/dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::addStringReplacePrimordialChecks): * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * Source/JavaScriptCore/runtime/JSGlobalObject.h: * Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h: (JSC::JSGlobalObject::regExpProtoFlagsGetter const): (JSC::JSGlobalObject::regExpProtoDotAllGetter const): (JSC::JSGlobalObject::regExpProtoHasIndicesGetter const): (JSC::JSGlobalObject::regExpProtoIgnoreCaseGetter const): (JSC::JSGlobalObject::regExpProtoMultilineGetter const): (JSC::JSGlobalObject::regExpProtoStickyGetter const):
d5ae907
to
64f2b05
Compare
EWS run on current version of this PR (hash 582aab2)
|
@@ -291,11 +314,13 @@ function replace(strArg, replace) | |||
if (!functionalReplace) | |||
replace = @toString(replace); | |||
|
|||
var global = regexp.global; | |||
var flags = @toString(regexp.flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it used for the fast path? Or not used and only used for slow path? I think flags generates strings, and it is strictly worse than global's flag (just returning boolean) in terms of performance, so I would like to know that we have optimization for flags, or it is not used in the most places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used only for slow path of String.prototype.replace
, if @hasObservableSideEffectsForStringReplace
returns false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
…s` getter only https://bugs.webkit.org/show_bug.cgi?id=248605 Reviewed by Yusuke Suzuki. This patch implements recent spec change [1], aligning RegExp.prototype's @@match / @@replace with @@split / @@matchall to use only "flags" getter to check for flags, which is observable. This patch is based on the PR by Alexey Shvayka[2]. Also according to the PR, no performance regressions. [1]: tc39/ecma262#2791 [2]: WebKit#7281 * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/builtins/RegExpPrototype.js: (linkTimeConstant.hasObservableSideEffectsForRegExpMatch): (linkTimeConstant.matchSlow): (overriddenName.string_appeared_here.replace): * Source/JavaScriptCore/builtins/StringPrototype.js: (linkTimeConstant.hasObservableSideEffectsForStringReplace): Canonical link: https://commits.webkit.org/290785@main
64f2b05
582aab2
🧪 style🛠 ios🛠 mac🛠 wpe🛠 🧪 win🛠 ios-sim🛠 mac-AS-debug🛠 gtk🛠 wincairo🧪 webkitperl🧪 ios-wk2🧪 api-mac🧪 gtk-wk2🧪 api-ios🧪 mac-wk1🧪 api-gtk🛠 🧪 jsc🛠 tv🧪 mac-wk2🛠 jsc-armv7🛠 tv-sim🧪 mac-AS-debug-wk2🧪 jsc-armv7-tests🛠 watch🧪 mac-wk2-stress🛠 jsc-mips🛠 watch-sim🧪 jsc-mips-tests