[JSC] Implement String#match in C++#64600
Open
sosukesuzuki wants to merge 1 commit intoWebKit:mainfrom
Open
Conversation
Collaborator
|
EWS run on previous version of this PR (hash bd01109) Details |
https://bugs.webkit.org/show_bug.cgi?id=314466 Reviewed by NOBODY (OOPS!). Move String.prototype.match from a JS builtin to a C++ host function and add a StringMatch DFG node, mirroring the String#split work in 312843@main. Notes: * StringMatch is converted to RegExpMatchFast in fixup so the existing RegExpMatchFastGlobal / RegExpExec strength reductions apply. * addStringMatchPrimordialChecks uses a single CheckStructure instead of the TryGetById chain in addStringReplacePrimordialChecks. Fixup-inserted TryGetByIds have no bytecode profile and never specialise, so they stay as repeated vmCalls. CheckStructure is stricter (subclasses OSR exit) but matches isSymbolMatchFastAndNonObservable, and the parser bails on BadCache. * isSymbolMatchFastAndNonObservable mirrors the replace variant: lastIndex must be a number since RegExp.prototype[@@match] reads it. No species watchpoint is needed since @@match does not use SpeciesConstructor. * stringProtoFuncMatch re-validates after ToString(this), since a user toString can mutate the regexp before RegExp.prototype[@@match] reads flags/exec. TipOfTree Patched regexp-match-digit-literal 64.9662+-0.6089 ^ 62.2319+-0.5453 ^ definitely 1.0439x faster string-match-digit-short 273.6600+-0.7725 ^ 269.4541+-1.5833 ^ definitely 1.0156x faster global-atom-match-one-char 0.7787+-0.0359 ^ 0.5617+-0.0209 ^ definitely 1.3863x faster Tests: JSTests/microbenchmarks/regexp-match-digit-cached.js JSTests/microbenchmarks/regexp-match-digit-literal.js JSTests/microbenchmarks/string-match-digit-short.js JSTests/microbenchmarks/string-match-letter-short.js JSTests/stress/string-prototype-match-edge-cases.js JSTests/stress/string-prototype-match-strength-reduction.js JSTests/stress/string-prototype-match-watchpoint-invalidation.js * JSTests/microbenchmarks/regexp-match-digit-cached.js: Added. (match): * JSTests/microbenchmarks/regexp-match-digit-literal.js: Added. (match): * JSTests/microbenchmarks/string-match-digit-short.js: Added. (match): * JSTests/microbenchmarks/string-match-letter-short.js: Added. (match): * JSTests/stress/string-prototype-match-edge-cases.js: Added. (shouldBe): (shouldThrow): (shouldBe.String.prototype.match.call.toString): (shouldBe.string_appeared_here.match.x.a): (shouldBe.re.Symbol.match): (shouldThrow.obj3.get Symbol): (shouldBe.MyRegExp): (shouldBe.MyRegExp2.prototype.Symbol.match): (shouldBe.MyRegExp2): (shouldBe.fake.get flags): (shouldBe.fake.get global): (shouldBe.fake.get hasIndices): (shouldBe.fake.get ignoreCase): (shouldBe.fake.get multiline): (shouldBe.fake.get sticky): (shouldBe.fake.get unicode): (shouldBe.fake.get unicodeSets): (shouldBe.fake.get dotAll): * JSTests/stress/string-prototype-match-strength-reduction.js: Added. (shouldBe): (matchGlobalLiteral): (matchNonGlobalLiteral): (matchStickyLiteral): (matchUnicodeGlobal): (matchCached): (matchStringPattern): (matchPoly): (shouldBe.matchPoly): * JSTests/stress/string-prototype-match-watchpoint-invalidation.js: Added. (shouldBe): (match): (re.Symbol.match): (RegExp.prototype.Symbol.match): (RegExp.prototype.exec): (value): (receiver.toString.re.exec): (receiver.toString.RegExp.prototype.exec): (get return): * Source/JavaScriptCore/builtins/StringPrototype.js: (match): Deleted. * 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): (JSC::DFG::FixupPhase::addStringMatchPrimordialChecks): * Source/JavaScriptCore/dfg/DFGGraph.h: * Source/JavaScriptCore/dfg/DFGJITCode.cpp: (JSC::DFG::JITData::JITData): (JSC::DFG::JITData::tryInitialize): * Source/JavaScriptCore/dfg/DFGJITCode.h: * Source/JavaScriptCore/dfg/DFGNodeType.h: * Source/JavaScriptCore/dfg/DFGOperations.cpp: (JSC::DFG::JSC_DEFINE_JIT_OPERATION): * 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/ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileStringMatch): * Source/JavaScriptCore/runtime/Intrinsic.h: * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * Source/JavaScriptCore/runtime/JSGlobalObject.h: * Source/JavaScriptCore/runtime/RegExpConstructor.cpp: (JSC::regExpCreate): * Source/JavaScriptCore/runtime/RegExpConstructor.h: * Source/JavaScriptCore/runtime/RegExpObject.h: * Source/JavaScriptCore/runtime/RegExpObjectInlines.h: (JSC::RegExpObject::isSymbolMatchFastAndNonObservable): * Source/JavaScriptCore/runtime/RegExpPrototype.cpp: (JSC::regExpMatchFast): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/RegExpPrototype.h: * Source/JavaScriptCore/runtime/StringPrototype.cpp: (JSC::StringPrototype::finishCreation): (JSC::stringMatchSlow): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/StringPrototype.h:
bd01109 to
a7b3161
Compare
Collaborator
|
EWS run on current version of this PR (hash a7b3161) Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bd01109
a7b3161