Changeset 202597 in webkit


Ignore:
Timestamp:
Jun 28, 2016 5:38:58 PM (8 years ago)
Author:
msaboff@apple.com
Message:

REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
https://bugs.webkit.org/show_bug.cgi?id=159233

Reviewed by Mark Lam.

Source/JavaScriptCore:

Jump to fail exit code when the last alternative of a sticky pattern fails.

  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::backtrack):

LayoutTests:

Updated tests.

  • js/regexp-sticky-expected.txt:
  • js/script-tests/regexp-sticky.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202596 r202597  
     12016-06-28  Michael Saboff  <msaboff@apple.com>
     2
     3        REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
     4        https://bugs.webkit.org/show_bug.cgi?id=159233
     5
     6        Reviewed by Mark Lam.
     7
     8        Updated tests.
     9
     10        * js/regexp-sticky-expected.txt:
     11        * js/script-tests/regexp-sticky.js:
     12
    1132016-06-28  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/js/regexp-sticky-expected.txt

    r200946 r202597  
    2727PASS Global Flag - exec
    2828PASS Global Flag - match
     29PASS Global Flag - Alternates, long to short
    2930PASS Unicode Flag - Any Character
    3031PASS Unicode & Ignore Case Flags
    3132PASS Multiline
    3233PASS Multiline with BOL Anchor
     34PASS Multiline with EOL Anchor at start of Alternative
    3335PASS "123 1234 ".search(re) is 0
    3436PASS "123 1234 ".search(re) is 0
  • trunk/LayoutTests/js/script-tests/regexp-sticky.js

    r200946 r202597  
    9393testStickyExec("Global Flag - exec", /\s*(\+|[0-9]+)\s*/gy, "3 + 4", 0, ["3 ,3", "+ ,+", "4,4", null]);
    9494testStickyMatch("Global Flag - match", /\s*(\+|[0-9]+)\s*/gy, "3 + 4", 0, [["3 ", "+ ", "4"], ["3 ", "+ ", "4"]]);
     95testStickyMatch("Global Flag - Alternates, long to short", /x.|[\d]/gy, ".a", 0, [null]);
    9596testStickyExec("Unicode Flag - Any Character", /./uy, "a@\u{10402}1\u202a\u{12345}", 0, ["a", "@", "\u{10402}", "1", "\u202a", "\u{12345}", null]);
    9697testStickyMatch("Unicode & Ignore Case Flags", /(?:\u{118c0}|\u{10cb0}|\w):/iuy, "a:\u{118a0}:x:\u{10cb0}", 0, [["a:"], ["\u{118a0}:"], ["x:"], null]);
    9798testStickyExec("Multiline", /(?:\w+ *)+(?:\n|$)/my, "Line One\nLine Two", 0, ["Line One\n", "Line Two", null]);
    9899testStickyMatch("Multiline with BOL Anchor", /^\d*\s?/my, "13574\n295\n99", 0, [["13574\n"], ["295\n"], ["99"], null]);
     100testStickyExec("Multiline with EOL Anchor at start of Alternative", /.{2}|(?=$)./my, "\n", 0, [null]);
    99101
    100102// Verify that String.search starts at 0 even with the sticky flag.
  • trunk/Source/JavaScriptCore/ChangeLog

    r202588 r202597  
     12016-06-28  Michael Saboff  <msaboff@apple.com>
     2
     3        REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
     4        https://bugs.webkit.org/show_bug.cgi?id=159233
     5
     6        Reviewed by Mark Lam.
     7
     8        Jump to fail exit code when the last alternative of a sticky pattern fails.
     9
     10        * yarr/YarrJIT.cpp:
     11        (JSC::Yarr::YarrGenerator::backtrack):
     12
    1132016-06-28  Saam Barati  <sbarati@apple.com>
    214
  • trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp

    r200946 r202597  
    18291829
    18301830                bool onceThrough = endOp.m_nextOp == notFound;
     1831               
     1832                JumpList lastStickyAlternativeFailures;
    18311833
    18321834                // First, generate code to handle cases where we backtrack out of an attempted match
     
    18441846                        && (alternative->m_minimumSize - beginOp->m_alternative->m_minimumSize == 1))
    18451847                        m_backtrackingState.linkTo(beginOp->m_reentry, this);
    1846                     else {
     1848                    else if (m_pattern.sticky() && m_ops[op.m_nextOp].m_op == OpBodyAlternativeEnd) {
     1849                        // It is a sticky pattern and the last alternative failed, jump to the end.
     1850                        m_backtrackingState.takeBacktracksToJumpList(lastStickyAlternativeFailures, this);
     1851                    } else {
    18471852                        // We need to generate a trampoline of code to execute before looping back
    18481853                        // around to the first alternative.
    18491854                        m_backtrackingState.link(this);
    18501855
    1851                         // No need to advance and retry for a stick pattern.
     1856                        // No need to advance and retry for a sticky pattern.
    18521857                        if (!m_pattern.sticky()) {
    18531858                            // If the pattern size is not fixed, then store the start index for use if we match.
     
    19992004                    matchFailed.link(this);
    20002005                }
     2006
     2007                lastStickyAlternativeFailures.link(this);
    20012008                removeCallFrame();
    20022009                generateFailReturn();
Note: See TracChangeset for help on using the changeset viewer.