Changeset 73962 in webkit


Ignore:
Timestamp:
Dec 13, 2010 2:19:48 PM (13 years ago)
Author:
msaboff@apple.com
Message:

2010-12-13 Michael Saboff <msaboff@apple.com>

Reviewed by Oliver Hunt.

REGRESSION: mobileme mail viewing is broken
https://bugs.webkit.org/show_bug.cgi?id=50884

Fixed problem where simple parenthesis (those without capture and
with a fixed count) where not propagating backtrack to labels for
nested parentheses. Also added the nesting level for the parentheses
state created in that case as well.

  • yarr/RegexJIT.cpp: (JSC::Yarr::RegexGenerator::BacktrackDestination::copyBacktrackToLabel): (JSC::Yarr::RegexGenerator::TermGenerationState::isLastTerm): (JSC::Yarr::RegexGenerator::ParenthesesTail::generateCode): (JSC::Yarr::RegexGenerator::generateParenthesesSingle):

2010-12-13 Michael Saboff <msaboff@apple.com>

Reviewed by Oliver Hunt.

REGRESSION: mobileme mail viewing is broken
https://bugs.webkit.org/show_bug.cgi?id=50884

Added a test to check parentheses nesting within parentheses that
don't capture and that are fixed count. There is special handling
for this case in the RegExp JIT code.

  • fast/regex/parentheses-expected.txt:
  • fast/regex/script-tests/parentheses.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r73903 r73962  
     12010-12-13  Michael Saboff  <msaboff@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        REGRESSION: mobileme mail viewing is broken
     6        https://bugs.webkit.org/show_bug.cgi?id=50884
     7
     8        Fixed problem where simple parenthesis (those without capture and
     9        with a fixed count) where not propagating backtrack to labels for
     10        nested parentheses.  Also added the nesting level for the parentheses
     11        state created in that case as well.
     12
     13        * yarr/RegexJIT.cpp:
     14        (JSC::Yarr::RegexGenerator::BacktrackDestination::copyBacktrackToLabel):
     15        (JSC::Yarr::RegexGenerator::TermGenerationState::isLastTerm):
     16        (JSC::Yarr::RegexGenerator::ParenthesesTail::generateCode):
     17        (JSC::Yarr::RegexGenerator::generateParenthesesSingle):
     18
    1192010-12-13  Peter Varga  <pvarga@inf.u-szeged.hu>
    220
  • trunk/JavaScriptCore/yarr/RegexJIT.cpp

    r73866 r73962  
    573573        }
    574574
     575        void copyBacktrackToLabel(BacktrackDestination& rhs)
     576        {
     577            if (rhs.m_backtrackToLabel)
     578                m_backtrackToLabel = rhs.m_backtrackToLabel;
     579        }
     580
    575581        void setBacktrackToLabel(Label* backtrackToLabel)
    576582        {
     
    820826            ASSERT(alternativeValid());
    821827            return (t + 1) == alternative()->m_terms.size();
    822         }       
     828        }
    823829        unsigned getSubParenNum()
    824830        {
     
    829835            return !disjunction->m_parent;
    830836        }
    831        
     837
    832838        void setParenthesesTail(ParenthesesTail* parenthesesTail)
    833839        {
     
    839845            return m_parenthesesTail;
    840846        }
    841        
     847
    842848        PatternTerm& lookaheadTerm()
    843849        {
     
    10831089                fromPriorBacktrack.link(generator);
    10841090            m_parenBacktrack.linkAlternativeBacktracks(generator);
    1085             m_withinBacktrackJumps.link(generator);           
     1091            m_withinBacktrackJumps.link(generator);
    10861092
    10871093            if (m_term.capture())
     
    16031609        // optimized case - no capture & no quantifier can be handled in a light-weight manner.
    16041610        if (!term.capture() && (term.quantityType == QuantifierFixedCount)) {
     1611            m_expressionState.incrementParenNestingLevel();
     1612
    16051613            TermGenerationState parenthesesState(disjunction, state.checkedTotal);
    16061614            generateParenthesesDisjunction(state.term(), parenthesesState, alternativeFrameLocation);
     
    16081616            // parenthesesState's m_backTrackJumps vector, and that if they need backtracking
    16091617            // they will have set an entry point on the parenthesesState's m_backtrackLabel.
    1610             state.propagateBacktrackingFrom(this, parenthesesState.getBacktrackDestination());
     1618            BacktrackDestination& parenthesesBacktrack = parenthesesState.getBacktrackDestination();
     1619            state.propagateBacktrackingFrom(this, parenthesesBacktrack);
     1620            state.getBacktrackDestination().copyBacktrackToLabel(parenthesesBacktrack);
     1621
     1622            m_expressionState.decrementParenNestingLevel();
    16111623        } else {
    16121624            Jump nonGreedySkipParentheses;
     
    16371649
    16381650            TermGenerationState parenthesesState(disjunction, state.checkedTotal);
    1639            
     1651
    16401652            // Save the parenthesesTail for backtracking from nested parens to this one.
    16411653            parenthesesState.setParenthesesTail(parenthesesTail);
  • trunk/LayoutTests/ChangeLog

    r73961 r73962  
     12010-12-13  Michael Saboff  <msaboff@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        REGRESSION: mobileme mail viewing is broken
     6        https://bugs.webkit.org/show_bug.cgi?id=50884
     7
     8        Added a test to check parentheses nesting within parentheses that
     9        don't capture and that are fixed count.  There is special handling
     10        for this case in the RegExp JIT code.
     11
     12        * fast/regex/parentheses-expected.txt:
     13        * fast/regex/script-tests/parentheses.js:
     14
    1152010-12-13  Chris Fleizach  <cfleizach@apple.com>
    216
  • trunk/LayoutTests/fast/regex/parentheses-expected.txt

    r73866 r73962  
    3838PASS regexp31.exec('Committer:') is null
    3939PASS regexp32.exec('Committer:') is null
     40PASS regexp33.exec('> <head>') is ['>',undefined,undefined,'>']
    4041PASS 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) is ['Bob',undefined,'Bob',undefined,undefined]
    4142PASS successfullyParsed is true
  • trunk/LayoutTests/fast/regex/script-tests/parentheses.js

    r73866 r73962  
    138138shouldBeNull("regexp32.exec('Committer:')");
    139139
     140var regexp33 = RegExp('^(?:(?:(a)(xyz|[^>"\'\s]*)?)|(/?>)|.[^\w\s>]*)');
     141shouldBe("regexp33.exec('> <head>')","['>',undefined,undefined,'>']");
     142
    140143shouldBe("'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", "['Bob',undefined,'Bob',undefined,undefined]");
    141144
Note: See TracChangeset for help on using the changeset viewer.