Ignore:
Timestamp:
Mar 3, 2011, 2:22:56 AM (14 years ago)
Author:
[email protected]
Message:

2011-03-03 Peter Varga <[email protected]>

Reviewed by Oliver Hunt.

Begin Characters Optimization Causes YARR Interpreter Errors
https://bugs.webkit.org/show_bug.cgi?id=55479

The addBeginTerm function is removed because it doesn't correctly handle those
cases when an "invalid" term has been
collected (e.g. CharacterClass). Move the removed function to the
setupAlternativeBeginTerms method's switch-case
where the non-allowed cases are correctly handled.

Reenable the Beginning Character Optimization in the YARR Interpreter again.

  • fast/js/regexp-alternatives-expected.txt: Added.
  • fast/js/regexp-alternatives.html: Added.
  • fast/js/script-tests/regexp-alternatives.js: Added.

2011-03-03 Peter Varga <[email protected]>

Reviewed by Oliver Hunt.

Begin Characters Optimization Causes YARR Interpreter Errors
https://bugs.webkit.org/show_bug.cgi?id=55479

The addBeginTerm function is removed because it doesn't correctly handle those
cases when an "invalid" term has been
collected (e.g. CharacterClass). Move the removed function to the
setupAlternativeBeginTerms method's switch-case
where the non-allowed cases are correctly handled.

Reenable the Beginning Character Optimization in the YARR Interpreter again.

  • yarr/YarrPattern.cpp: (JSC::Yarr::YarrPatternConstructor::setupAlternativeBeginTerms): (JSC::Yarr::YarrPattern::compile):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp

    r80018 r80217  
    815815    }
    816816
    817     bool addBeginTerm(PatternTerm term, Vector<TermChain>* beginTerms, PatternAlternative* alternative, unsigned numTerms, unsigned termIndex, unsigned depth)
    818     {
    819         if (term.quantityType == QuantifierFixedCount) {
    820             beginTerms->append(TermChain(term));
    821             if (depth < 2 && termIndex < numTerms - 1 && term.quantityCount == 1)
    822                 setupAlternativeBeginTerms(alternative, &beginTerms->last().hotTerms, termIndex + 1, depth + 1);
    823         } else if (termIndex != numTerms - 1) {
    824             beginTerms->append(TermChain(term));
    825             return true;
    826         }
    827 
    828         return false;
    829     }
    830 
    831817    // This function collects the terms which are potentially matching the first number of depth characters in the result.
    832818    // If this function returns false then it found at least one term which makes the beginning character
     
    864850
    865851            case PatternTerm::TypePatternCharacter:
    866                 if (addBeginTerm(term, beginTerms, alternative, numTerms, termIndex, depth)) {
     852                if (termIndex != numTerms - 1) {
     853                    beginTerms->append(TermChain(term));
    867854                    termIndex++;
    868855                    checkNext = true;
     856                } else if (term.quantityType == QuantifierFixedCount) {
     857                    beginTerms->append(TermChain(term));
     858                    if (depth < 2 && termIndex < numTerms - 1 && term.quantityCount == 1)
     859                        if (!setupAlternativeBeginTerms(alternative, &beginTerms->last().hotTerms, termIndex + 1, depth + 1))
     860                            return false;
    869861                }
     862
    870863                break;
    871864
     
    884877                    termIndex++;
    885878                    checkNext = true;
    886 
    887879                }
    888880
     
    993985       
    994986    constructor.setupOffsets();
    995     // TODO: Disabling the begin characters optimization due to problems found
    996     //    in https://bugs.webkit.org/show_bug.cgi?id=54978.
    997     //    A new defect was filed to track this issue:
    998     //        https://bugs.webkit.org/show_bug.cgi?id=55479
    999     // constructor.setupBeginChars();
     987    constructor.setupBeginChars();
    1000988
    1001989    return 0;
Note: See TracChangeset for help on using the changeset viewer.