Ignore:
Timestamp:
Nov 17, 2010, 7:52:43 AM (15 years ago)
Author:
[email protected]
Message:

2010-11-17 Sheriff Bot <[email protected]>

Unreviewed, rolling out r72197.
http://trac.webkit.org/changeset/72197
https://bugs.webkit.org/show_bug.cgi?id=49661

broke fast/regex/test1.html (Requested by stampho on #webkit).

  • runtime/JSGlobalData.h:
  • runtime/RegExp.cpp: (JSC::RegExpRepresentation::~RegExpRepresentation): (JSC::RegExp::compile): (JSC::RegExp::match):
  • tests/mozilla/expected.html:
  • wtf/Platform.h:
  • yarr/RegexCompiler.cpp:
  • yarr/RegexCompiler.h:
  • yarr/RegexInterpreter.cpp:
  • yarr/RegexInterpreter.h:
  • yarr/RegexJIT.cpp: (JSC::Yarr::jitCompileRegex):
  • yarr/RegexJIT.h: (JSC::Yarr::RegexCodeBlock::RegexCodeBlock): (JSC::Yarr::RegexCodeBlock::~RegexCodeBlock): (JSC::Yarr::RegexCodeBlock::getFallback): (JSC::Yarr::RegexCodeBlock::setFallback): (JSC::Yarr::executeRegex):
  • yarr/RegexParser.h:
  • yarr/RegexPattern.h:

2010-11-17 Sheriff Bot <[email protected]>

Unreviewed, rolling out r72197.
http://trac.webkit.org/changeset/72197
https://bugs.webkit.org/show_bug.cgi?id=49661

broke fast/regex/test1.html (Requested by stampho on #webkit).

  • fast/js/regexp-look-ahead-empty-expected.txt:
  • fast/js/regexp-overflow-expected.txt:
  • fast/js/script-tests/regexp-overflow.js:
  • fast/js/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.2/15.10.2.5_Term/S15.10.2.5_A1_T4-expected.txt:
  • fast/js/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.2/15.10.2.8_Atom/S15.10.2.8_A2_T1-expected.txt:
  • fast/js/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/15.10.6.2_RegExp.prototype.exec/S15.10.6.2_A1_T6-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExp.cpp

    r72197 r72207  
    2929#include <wtf/OwnArrayPtr.h>
    3030
     31
     32#if ENABLE(YARR)
     33
    3134#include "yarr/RegexCompiler.h"
    3235#if ENABLE(YARR_JIT)
     
    3639#endif
    3740
     41#else
     42
     43#include <pcre/pcre.h>
     44
     45#endif
     46
    3847namespace JSC {
    3948
     
    4150#if ENABLE(YARR_JIT)
    4251    Yarr::RegexCodeBlock m_regExpJITCode;
    43 #else
     52#elif ENABLE(YARR)
    4453    OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
     54#else
     55    JSRegExp* m_regExp;
     56#endif
     57
     58#if !ENABLE(YARR)
     59    ~RegExpRepresentation()
     60    {
     61        jsRegExpFree(m_regExp);
     62    }
    4563#endif
    4664};
     
    83101}
    84102
     103#if ENABLE(YARR)
     104
    85105void RegExp::compile(JSGlobalData* globalData)
    86106{
    87107#if ENABLE(YARR_JIT)
    88     Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
     108    Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());
    89109#else
    90110    m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
     
    109129    if (m_representation->m_regExpBytecode) {
    110130#endif
    111         int offsetVectorSize = (m_numSubpatterns + 1) * 2;
     131        int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre.
    112132        int* offsetVector;
    113133        Vector<int, 32> nonReturnedOvector;
     
    128148
    129149#if ENABLE(YARR_JIT)
    130         int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector);
     150        int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
    131151#else
    132152        int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
     
    152172}
    153173
     174#else
     175
     176void RegExp::compile(JSGlobalData*)
     177{
     178    m_representation->m_regExp = 0;
     179    JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase;
     180    JSRegExpMultilineOption multilineOption = multiline() ? JSRegExpMultiline : JSRegExpSingleLine;
     181    m_representation->m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
     182}
     183
     184int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
     185{
     186#if ENABLE(REGEXP_TRACING)
     187    m_rtMatchCallCount++;
     188#endif
     189   
     190    if (startOffset < 0)
     191        startOffset = 0;
     192    if (ovector)
     193        ovector->clear();
     194
     195    if (static_cast<unsigned>(startOffset) > s.length() || s.isNull())
     196        return -1;
     197
     198    if (m_representation->m_regExp) {
     199        // Set up the offset vector for the result.
     200        // First 2/3 used for result, the last third used by PCRE.
     201        int* offsetVector;
     202        int offsetVectorSize;
     203        int fixedSizeOffsetVector[3];
     204        if (!ovector) {
     205            offsetVectorSize = 3;
     206            offsetVector = fixedSizeOffsetVector;
     207        } else {
     208            offsetVectorSize = (m_numSubpatterns + 1) * 3;
     209            ovector->resize(offsetVectorSize);
     210            offsetVector = ovector->data();
     211        }
     212
     213        int numMatches = jsRegExpExecute(m_representation->m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);
     214   
     215        if (numMatches < 0) {
     216#ifndef NDEBUG
     217            if (numMatches != JSRegExpErrorNoMatch)
     218                fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches);
     219#endif
     220            if (ovector)
     221                ovector->clear();
     222            return -1;
     223        }
     224
     225#if ENABLE(REGEXP_TRACING)
     226        m_rtMatchFoundCount++;
     227#endif
     228       
     229        return offsetVector[0];
     230    }
     231
     232    return -1;
     233}
     234   
     235#endif
     236
    154237#if ENABLE(REGEXP_TRACING)
    155238    void RegExp::printTraceData()
Note: See TracChangeset for help on using the changeset viewer.