⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 235538 in webkit


Ignore:
Timestamp:
Aug 31, 2018, 12:45:02 AM (8 years ago)
Author:
sbarati@apple.com
Message:

convertToRegExpMatchFastGlobal must use KnownString as the child use kind
https://bugs.webkit.org/show_bug.cgi?id=189173
<rdar://problem/43501645>

Reviewed by Michael Saboff.

JSTests:

  • stress/may-exit-should-be-false-regexp-constant-folding.js: Added.

(foo):
(bar):

Source/JavaScriptCore:

We were crashing during validation because mayExit returned true
at a point in the program when we weren't allowed to exit.

The issue was is in StrengthReduction: we end up emitting code that
had a StringUse on an edge after a node that did side effects and before
an ExitOK/bytecode number transition. However, StrenghReduction did the
right thing here and also emitted the type checks before the node with
side effects. It just did bad bookkeeping. The node we convert to needs
to use KnownStringUse instead of StringUse for the child edge.

  • dfg/DFGNode.cpp:

(JSC::DFG::Node::convertToRegExpExecNonGlobalOrStickyWithoutChecks):
(JSC::DFG::Node::convertToRegExpMatchFastGlobalWithoutChecks):
(JSC::DFG::Node::convertToRegExpExecNonGlobalOrSticky): Deleted.
(JSC::DFG::Node::convertToRegExpMatchFastGlobal): Deleted.

  • dfg/DFGNode.h:
  • dfg/DFGStrengthReductionPhase.cpp:

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

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r235515 r235538  
     12018-08-31  Saam barati  <sbarati@apple.com>
     2
     3        convertToRegExpMatchFastGlobal must use KnownString as the child use kind
     4        https://bugs.webkit.org/show_bug.cgi?id=189173
     5        <rdar://problem/43501645>
     6
     7        Reviewed by Michael Saboff.
     8
     9        * stress/may-exit-should-be-false-regexp-constant-folding.js: Added.
     10        (foo):
     11        (bar):
     12
    1132018-08-30  Saam barati  <sbarati@apple.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r235527 r235538  
     12018-08-31  Saam barati  <sbarati@apple.com>
     2
     3        convertToRegExpMatchFastGlobal must use KnownString as the child use kind
     4        https://bugs.webkit.org/show_bug.cgi?id=189173
     5        <rdar://problem/43501645>
     6
     7        Reviewed by Michael Saboff.
     8
     9        We were crashing during validation because mayExit returned true
     10        at a point in the program when we weren't allowed to exit.
     11       
     12        The issue was is in StrengthReduction: we end up emitting code that
     13        had a StringUse on an edge after a node that did side effects and before
     14        an ExitOK/bytecode number transition. However, StrenghReduction did the
     15        right thing here and also emitted the type checks before the node with
     16        side effects. It just did bad bookkeeping. The node we convert to needs
     17        to use KnownStringUse instead of StringUse for the child edge.
     18
     19        * dfg/DFGNode.cpp:
     20        (JSC::DFG::Node::convertToRegExpExecNonGlobalOrStickyWithoutChecks):
     21        (JSC::DFG::Node::convertToRegExpMatchFastGlobalWithoutChecks):
     22        (JSC::DFG::Node::convertToRegExpExecNonGlobalOrSticky): Deleted.
     23        (JSC::DFG::Node::convertToRegExpMatchFastGlobal): Deleted.
     24        * dfg/DFGNode.h:
     25        * dfg/DFGStrengthReductionPhase.cpp:
     26        (JSC::DFG::StrengthReductionPhase::handleNode):
     27
    1282018-08-30  Saam barati  <sbarati@apple.com>
    229
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r235106 r235538  
    22182218    case RegExpMatchFast:
    22192219        ASSERT(node->child2().useKind() == RegExpObjectUse);
    2220         ASSERT(node->child3().useKind() == StringUse);
     2220        ASSERT(node->child3().useKind() == StringUse || node->child3().useKind() == KnownStringUse);
    22212221        setTypeForNode(node, SpecOther | SpecArray);
    22222222        break;
    22232223
    22242224    case RegExpMatchFastGlobal:
    2225         ASSERT(node->child2().useKind() == StringUse);
     2225        ASSERT(node->child2().useKind() == StringUse || node->child2().useKind() == KnownStringUse);
    22262226        setTypeForNode(node, SpecOther | SpecArray);
    22272227        break;
  • trunk/Source/JavaScriptCore/dfg/DFGNode.cpp

    r232000 r235538  
    269269}
    270270
    271 void Node::convertToRegExpExecNonGlobalOrSticky(FrozenValue* regExp)
     271void Node::convertToRegExpExecNonGlobalOrStickyWithoutChecks(FrozenValue* regExp)
    272272{
    273273    ASSERT(op() == RegExpExec);
    274274    setOpAndDefaultFlags(RegExpExecNonGlobalOrSticky);
    275275    children.child1() = Edge(children.child1().node(), KnownCellUse);
    276     children.child2() = Edge(children.child3().node(), StringUse);
     276    children.child2() = Edge(children.child3().node(), KnownStringUse);
    277277    children.child3() = Edge();
    278278    m_opInfo = regExp;
    279279}
    280280
    281 void Node::convertToRegExpMatchFastGlobal(FrozenValue* regExp)
     281void Node::convertToRegExpMatchFastGlobalWithoutChecks(FrozenValue* regExp)
    282282{
    283283    ASSERT(op() == RegExpMatchFast);
    284284    setOpAndDefaultFlags(RegExpMatchFastGlobal);
    285285    children.child1() = Edge(children.child1().node(), KnownCellUse);
    286     children.child2() = Edge(children.child3().node(), StringUse);
     286    children.child2() = Edge(children.child3().node(), KnownStringUse);
    287287    children.child3() = Edge();
    288288    m_opInfo = regExp;
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r235106 r235538  
    758758    void convertToCallDOM(Graph&);
    759759
    760     void convertToRegExpExecNonGlobalOrSticky(FrozenValue* regExp);
    761     void convertToRegExpMatchFastGlobal(FrozenValue* regExp);
     760    void convertToRegExpExecNonGlobalOrStickyWithoutChecks(FrozenValue* regExp);
     761    void convertToRegExpMatchFastGlobalWithoutChecks(FrozenValue* regExp);
    762762
    763763    void convertToSetRegExpObjectLastIndex()
  • trunk/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp

    r234178 r235538  
    509509                            m_nodeIndex, origin, jsNumber(0), UntypedUse));
    510510                    origin = origin.withInvalidExit();
    511                     m_node->convertToRegExpMatchFastGlobal(m_graph.freeze(regExp));
     511                    m_node->convertToRegExpMatchFastGlobalWithoutChecks(m_graph.freeze(regExp));
    512512                    m_node->origin = origin;
    513513                    m_changed = true;
     
    775775                m_insertionSet.insertNode(
    776776                    m_nodeIndex, SpecNone, Check, origin, m_node->children.justChecks());
    777                 m_node->convertToRegExpExecNonGlobalOrSticky(m_graph.freeze(regExp));
     777                m_node->convertToRegExpExecNonGlobalOrStickyWithoutChecks(m_graph.freeze(regExp));
    778778                m_changed = true;
    779779                return true;
Note: See TracChangeset for help on using the changeset viewer.