Ignore:
Timestamp:
Mar 10, 2018, 11:20:29 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

[FTL] Drop NewRegexp for String.prototype.match with RegExp + global flag
https://bugs.webkit.org/show_bug.cgi?id=181848

Reviewed by Sam Weinig.

JSTests:

  • microbenchmarks/regexp-u-global-es5.js: Added.

(fn):

  • microbenchmarks/regexp-u-global-es6.js: Added.

(fn):

  • stress/materialized-regexp-has-correct-last-index-set-by-match-at-osr-exit.js: Added.

(shouldBe):
(test):
(i.switch):

  • stress/materialized-regexp-has-correct-last-index-set-by-match.js: Added.

(shouldBe):
(test):

Source/JavaScriptCore:

In r181535, we support string.match(/nonglobal/) code. However, string.match(/global/g) is not
optimized since it sets lastIndex value before performing RegExp operation.

This patch optimizes the above "with a global flag" case by emitting SetRegExpObjectLastIndex properly.
RegExpMatchFast is converted to SetRegExpObjectLastIndex and RegExpMatchFastGlobal. The latter node
just holds RegExp (not RegExpObject) cell so that it can offer a chance to make NewRegexp PhantomNewRegexp
in object allocation sinking phase.

Added microbenchmarks shows that this patch makes NewRegexp PhantomNewRegexp even if the given RegExp
has a global flag. And it improves the performance.

baseline patched

regexp-u-global-es5 44.1298+-4.6128 33.7920+-2.0110 definitely 1.3059x faster
regexp-u-global-es6 182.3272+-2.2861 154.3414+-7.6769 definitely 1.1813x faster

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGDoesGC.cpp:

(JSC::DFG::doesGC):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • dfg/DFGMayExit.cpp:
  • dfg/DFGNode.cpp:

(JSC::DFG::Node::convertToRegExpMatchFastGlobal):

  • dfg/DFGNode.h:

(JSC::DFG::Node::hasHeapPrediction):
(JSC::DFG::Node::hasCellOperand):

  • dfg/DFGNodeType.h:
  • dfg/DFGOperations.cpp:
  • dfg/DFGOperations.h:
  • dfg/DFGPredictionPropagationPhase.cpp:
  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileRegExpMatchFastGlobal):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGStrengthReductionPhase.cpp:

(JSC::DFG::StrengthReductionPhase::handleNode):

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileRegExpMatchFastGlobal):

  • runtime/RegExpObject.cpp:

(JSC::collectMatches): Deleted.

  • runtime/RegExpObject.h:
  • runtime/RegExpObjectInlines.h:

(JSC::RegExpObject::execInline):
(JSC::RegExpObject::matchInline):
(JSC::advanceStringUnicode):
(JSC::collectMatches):
(JSC::RegExpObject::advanceStringUnicode): Deleted.

  • runtime/RegExpPrototype.cpp:

(JSC::advanceStringIndex):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGNode.cpp

    r228411 r229514  
    235235}
    236236
     237void Node::convertToRegExpMatchFastGlobal(FrozenValue* regExp)
     238{
     239    ASSERT(op() == RegExpMatchFast);
     240    setOpAndDefaultFlags(RegExpMatchFastGlobal);
     241    children.child1() = Edge(children.child1().node(), KnownCellUse);
     242    children.child2() = Edge(children.child3().node(), StringUse);
     243    children.child3() = Edge();
     244    m_opInfo = regExp;
     245}
     246
    237247String Node::tryGetString(Graph& graph)
    238248{
Note: See TracChangeset for help on using the changeset viewer.