Ignore:
Timestamp:
Nov 17, 2010, 5:15:56 AM (15 years ago)
Author:
Csaba Osztrogonác
Message:

YARR JIT should fallback to YARR Interpreter instead of PCRE.
https://bugs.webkit.org/show_bug.cgi?id=46719

Patch by Peter Varga <[email protected]> on 2010-11-17
Reviewed by Gavin Barraclough.

Remove the ENABLE_YARR macro and the option of matching regular
expressions with PCRE from JavaScriptCore.

JavaScriptCore:

  • runtime/JSGlobalData.h:
  • runtime/RegExp.cpp:

(JSC::RegExp::compile):
(JSC::RegExp::match):

  • tests/mozilla/expected.html:
  • wtf/Platform.h:
  • yarr/RegexCompiler.cpp:
  • yarr/RegexCompiler.h:
  • yarr/RegexInterpreter.cpp:

(JSC::Yarr::byteCompileRegex):

  • 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::isFallback):
(JSC::Yarr::RegexCodeBlock::setFallback):
(JSC::Yarr::executeRegex):

  • yarr/RegexParser.h:
  • yarr/RegexPattern.h:

LayoutTests:

  • 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/yarr/RegexJIT.h

    r71691 r72197  
    3030
    3131#include "MacroAssembler.h"
     32#include "RegexInterpreter.h" // temporary, remove when fallback is removed.
    3233#include "RegexPattern.h"
    3334#include "UString.h"
    34 
    35 #include "pcre.h"
    36 struct JSRegExp; // temporary, remove when fallback is removed.
    3735
    3836#if CPU(X86) && !COMPILER(MSVC)
     
    5452public:
    5553    RegexCodeBlock()
    56         : m_fallback(0)
     54        : m_needFallback(false)
    5755    {
    5856    }
     
    6058    ~RegexCodeBlock()
    6159    {
    62         if (m_fallback)
    63             jsRegExpFree(m_fallback);
    6460    }
    6561
    66     JSRegExp* getFallback() { return m_fallback; }
    67     void setFallback(JSRegExp* fallback) { m_fallback = fallback; }
     62    BytecodePattern* getFallback() { return m_fallback.get(); }
     63    bool isFallback() { return m_needFallback; }
     64    void setFallback(PassOwnPtr<BytecodePattern> fallback)
     65    {
     66        m_fallback = fallback;
     67        m_needFallback = true;
     68    }
    6869
    6970    bool operator!() { return (!m_ref.m_code.executableAddress() && !m_fallback); }
     
    7475        return reinterpret_cast<RegexJITCode>(m_ref.m_code.executableAddress())(input, start, length, output);
    7576    }
    76    
     77
    7778#if ENABLE(REGEXP_TRACING)
    7879    void *getAddr() { return m_ref.m_code.executableAddress(); }
     
    8182private:
    8283    MacroAssembler::CodeRef m_ref;
    83     JSRegExp* m_fallback;
     84    OwnPtr<Yarr::BytecodePattern> m_fallback;
     85    bool m_needFallback;
    8486};
    8587
    86 void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase = false, bool multiline = false);
     88void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& pattern, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator* allocator, bool ignoreCase = false, bool multiline = false);
    8789
    88 inline int executeRegex(RegexCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output, int outputArraySize)
     90inline int executeRegex(RegexCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output)
    8991{
    90     if (JSRegExp* fallback = jitObject.getFallback())
    91         return (jsRegExpExecute(fallback, input, length, start, output, outputArraySize) < 0) ? -1 : output[0];
     92    if (jitObject.isFallback())
     93        return (interpretRegex(jitObject.getFallback(), input, start, length, output));
    9294
    9395    return jitObject.execute(input, start, length, output);
Note: See TracChangeset for help on using the changeset viewer.