diff options
Diffstat (limited to 'JavaScriptCore/yarr/RegexJIT.h')
| -rw-r--r-- | JavaScriptCore/yarr/RegexJIT.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/JavaScriptCore/yarr/RegexJIT.h b/JavaScriptCore/yarr/RegexJIT.h index 935b9a3..c4c382c 100644 --- a/JavaScriptCore/yarr/RegexJIT.h +++ b/JavaScriptCore/yarr/RegexJIT.h @@ -26,16 +26,12 @@ #ifndef RegexJIT_h #define RegexJIT_h -#include <wtf/Platform.h> - #if ENABLE(YARR_JIT) #include "MacroAssembler.h" +#include "RegexInterpreter.h" // temporary, remove when fallback is removed. #include "RegexPattern.h" -#include <UString.h> - -#include <pcre.h> -struct JSRegExp; // temporary, remove when fallback is removed. +#include "UString.h" #if CPU(X86) && !COMPILER(MSVC) #define YARR_CALL __attribute__ ((regparm (3))) @@ -55,20 +51,23 @@ class RegexCodeBlock { public: RegexCodeBlock() - : m_fallback(0) + : m_needFallback(false) { } ~RegexCodeBlock() { - if (m_fallback) - jsRegExpFree(m_fallback); } - JSRegExp* getFallback() { return m_fallback; } - void setFallback(JSRegExp* fallback) { m_fallback = fallback; } + BytecodePattern* getFallback() { return m_fallback.get(); } + bool isFallback() { return m_needFallback; } + void setFallback(PassOwnPtr<BytecodePattern> fallback) + { + m_fallback = fallback; + m_needFallback = true; + } - bool operator!() { return !m_ref.m_code.executableAddress(); } + bool operator!() { return (!m_ref.m_code.executableAddress() && !m_fallback); } void set(MacroAssembler::CodeRef ref) { m_ref = ref; } int execute(const UChar* input, unsigned start, unsigned length, int* output) @@ -76,17 +75,22 @@ public: return reinterpret_cast<RegexJITCode>(m_ref.m_code.executableAddress())(input, start, length, output); } +#if ENABLE(REGEXP_TRACING) + void *getAddr() { return m_ref.m_code.executableAddress(); } +#endif + private: MacroAssembler::CodeRef m_ref; - JSRegExp* m_fallback; + OwnPtr<Yarr::BytecodePattern> m_fallback; + bool m_needFallback; }; -void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase = false, bool multiline = false); +void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& pattern, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator* allocator, bool ignoreCase = false, bool multiline = false); -inline int executeRegex(RegexCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output, int outputArraySize) +inline int executeRegex(RegexCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output) { - if (JSRegExp* fallback = jitObject.getFallback()) - return (jsRegExpExecute(fallback, input, length, start, output, outputArraySize) < 0) ? -1 : output[0]; + if (jitObject.isFallback()) + return (interpretRegex(jitObject.getFallback(), input, start, length, output)); return jitObject.execute(input, start, length, output); } |
