Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1440f8619f8200437d51173a3a53aeb4b6f8de99
      
https://github.com/WebKit/WebKit/commit/1440f8619f8200437d51173a3a53aeb4b6f8de99
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-05-16 (Sat, 16 May 2026)

  Changed paths:
    A JSTests/microbenchmarks/regexp-match-digit-cached.js
    A JSTests/microbenchmarks/regexp-match-digit-literal.js
    A JSTests/microbenchmarks/string-match-digit-short.js
    A JSTests/microbenchmarks/string-match-letter-short.js
    A JSTests/stress/string-prototype-match-edge-cases.js
    A JSTests/stress/string-prototype-match-strength-reduction.js
    A JSTests/stress/string-prototype-match-watchpoint-invalidation.js
    M Source/JavaScriptCore/builtins/StringPrototype.js
    M Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
    M Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
    M Source/JavaScriptCore/dfg/DFGClobberize.h
    M Source/JavaScriptCore/dfg/DFGCloneHelper.h
    M Source/JavaScriptCore/dfg/DFGDoesGC.cpp
    M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
    M Source/JavaScriptCore/dfg/DFGGraph.h
    M Source/JavaScriptCore/dfg/DFGJITCode.cpp
    M Source/JavaScriptCore/dfg/DFGJITCode.h
    M Source/JavaScriptCore/dfg/DFGNode.cpp
    M Source/JavaScriptCore/dfg/DFGNode.h
    M Source/JavaScriptCore/dfg/DFGNodeType.h
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.h
    M Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGSafeToExecute.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
    M Source/JavaScriptCore/ftl/FTLCapabilities.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/runtime/Intrinsic.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h
    M Source/JavaScriptCore/runtime/RegExpConstructor.cpp
    M Source/JavaScriptCore/runtime/RegExpConstructor.h
    M Source/JavaScriptCore/runtime/RegExpObject.h
    M Source/JavaScriptCore/runtime/RegExpObjectInlines.h
    M Source/JavaScriptCore/runtime/RegExpPrototype.cpp
    M Source/JavaScriptCore/runtime/RegExpPrototype.h
    M Source/JavaScriptCore/runtime/StringPrototype.cpp
    M Source/JavaScriptCore/runtime/StringPrototype.h

  Log Message:
  -----------
  [JSC] Implement `String#match` in C++
https://bugs.webkit.org/show_bug.cgi?id=314466

Reviewed by Yusuke Suzuki.

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:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to