X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..2d39b0e377c0896910ee49ae70082ba665faf986:/runtime/RegExp.h diff --git a/runtime/RegExp.h b/runtime/RegExp.h index 79f4694..fec8f6a 100644 --- a/runtime/RegExp.h +++ b/runtime/RegExp.h @@ -22,40 +22,51 @@ #ifndef RegExp_h #define RegExp_h -#include "UString.h" #include "ExecutableAllocator.h" -#include "Structure.h" +#include "MatchResult.h" #include "RegExpKey.h" +#include "Structure.h" +#include "yarr/Yarr.h" #include #include +#include + +#if ENABLE(YARR_JIT) +#include "yarr/YarrJIT.h" +#endif namespace JSC { struct RegExpRepresentation; - class JSGlobalData; + class VM; - RegExpFlags regExpFlags(const UString&); + JS_EXPORT_PRIVATE RegExpFlags regExpFlags(const String&); class RegExp : public JSCell { public: - static RegExp* create(JSGlobalData*, const UString& pattern, RegExpFlags); - ~RegExp(); + typedef JSCell Base; + + JS_EXPORT_PRIVATE static RegExp* create(VM&, const String& pattern, RegExpFlags); + static const bool needsDestruction = true; + static const bool hasImmortalStructure = true; + static void destroy(JSCell*); bool global() const { return m_flags & FlagGlobal; } bool ignoreCase() const { return m_flags & FlagIgnoreCase; } bool multiline() const { return m_flags & FlagMultiline; } - const UString& pattern() const { return m_patternString; } + const String& pattern() const { return m_patternString; } bool isValid() const { return !m_constructionError && m_flags != InvalidFlags; } const char* errorMessage() const { return m_constructionError; } - int match(JSGlobalData&, const UString&, int startOffset, Vector* ovector = 0); + JS_EXPORT_PRIVATE int match(VM&, const String&, unsigned startOffset, Vector& ovector); + MatchResult match(VM&, const String&, unsigned startOffset); unsigned numSubpatterns() const { return m_numSubpatterns; } bool hasCode() { - return m_representation; + return m_state != NotCompiled; } void invalidateCode(); @@ -64,49 +75,60 @@ namespace JSC { void printTraceData(); #endif - static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(globalData, prototype, TypeInfo(LeafType, 0), 0, &s_info); + return Structure::create(vm, globalObject, prototype, TypeInfo(LeafType, StructureFlags), info()); } - static JS_EXPORTDATA const ClassInfo s_info; + DECLARE_INFO; RegExpKey key() { return RegExpKey(m_flags, m_patternString); } + protected: + static const unsigned StructureFlags = StructureIsImmortal; + + void finishCreation(VM&); + private: friend class RegExpCache; - RegExp(JSGlobalData* globalData, const UString& pattern, RegExpFlags); + RegExp(VM&, const String&, RegExpFlags); + + static RegExp* createWithoutCaching(VM&, const String&, RegExpFlags); enum RegExpState { ParseError, JITCode, ByteCode, - NotCompiled, - Compiling + NotCompiled } m_state; - void compile(JSGlobalData*); - void compileIfNecessary(JSGlobalData& globalData) - { - if (m_representation) - return; - compile(&globalData); - } + void compile(VM*, Yarr::YarrCharSize); + void compileIfNecessary(VM&, Yarr::YarrCharSize); + + void compileMatchOnly(VM*, Yarr::YarrCharSize); + void compileIfNecessaryMatchOnly(VM&, Yarr::YarrCharSize); #if ENABLE(YARR_JIT_DEBUG) - void matchCompareWithInterpreter(const UString&, int startOffset, int* offsetVector, int jitResult); + void matchCompareWithInterpreter(const String&, int startOffset, int* offsetVector, int jitResult); #endif - UString m_patternString; + String m_patternString; RegExpFlags m_flags; const char* m_constructionError; unsigned m_numSubpatterns; #if ENABLE(REGEXP_TRACING) + double m_rtMatchOnlyTotalSubjectStringLen; + double m_rtMatchTotalSubjectStringLen; + unsigned m_rtMatchOnlyCallCount; + unsigned m_rtMatchOnlyFoundCount; unsigned m_rtMatchCallCount; unsigned m_rtMatchFoundCount; #endif - OwnPtr m_representation; +#if ENABLE(YARR_JIT) + Yarr::YarrCodeBlock m_regExpJITCode; +#endif + OwnPtr m_regExpBytecode; }; } // namespace JSC