Changeset 73124 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Dec 2, 2010, 5:36:45 AM (14 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExp.cpp
r72489 r73124 3 3 * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2009 Torch Mobile, Inc. 5 * Copyright (C) 2010 Peter Varga ([email protected]), University of Szeged 5 6 * 6 7 * This library is free software; you can redistribute it and/or … … 30 31 31 32 #include "yarr/RegexCompiler.h" 32 #if ENABLE(YARR_JIT)33 33 #include "yarr/RegexJIT.h" 34 #else35 34 #include "yarr/RegexInterpreter.h" 36 # endif35 #include "yarr/RegexPattern.h" 37 36 38 37 namespace JSC { … … 41 40 #if ENABLE(YARR_JIT) 42 41 Yarr::RegexCodeBlock m_regExpJITCode; 43 #e lse42 #endif 44 43 OwnPtr<Yarr::BytecodePattern> m_regExpBytecode; 45 #endif46 44 }; 47 45 48 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern , const UString& flags)49 : m_pattern (pattern)46 inline RegExp::RegExp(JSGlobalData* globalData, const UString& patternString, const UString& flags) 47 : m_patternString(patternString) 50 48 , m_flagBits(0) 51 49 , m_constructionError(0) … … 67 65 m_flagBits |= Multiline; 68 66 } 69 compile(globalData); 67 68 m_state = compile(globalData); 70 69 } 71 70 … … 74 73 } 75 74 76 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern , const UString& flags)75 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& patternString, const UString& flags) 77 76 { 78 RefPtr<RegExp> res = adoptRef(new RegExp(globalData, pattern , flags));77 RefPtr<RegExp> res = adoptRef(new RegExp(globalData, patternString, flags)); 79 78 #if ENABLE(REGEXP_TRACING) 80 79 globalData->addRegExpToTrace(res); … … 83 82 } 84 83 85 voidRegExp::compile(JSGlobalData* globalData)84 RegExp::RegExpState RegExp::compile(JSGlobalData* globalData) 86 85 { 86 Yarr::RegexPattern pattern(ignoreCase(), multiline()); 87 88 if ((m_constructionError = Yarr::compileRegex(m_patternString, pattern))) 89 return ParseError; 90 91 m_numSubpatterns = pattern.m_numSubpatterns; 92 87 93 #if ENABLE(YARR_JIT) 88 Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline()); 89 #else 90 m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline()); 94 if (!pattern.m_containsBackreferences && globalData->canUseJIT()) { 95 Yarr::jitCompileRegex(pattern, globalData, m_representation->m_regExpJITCode); 96 if (!m_representation->m_regExpJITCode.isFallBack()) 97 return JITCode; 98 } 91 99 #endif 100 101 m_representation->m_regExpBytecode = Yarr::byteCompileRegex(pattern, &globalData->m_regexAllocator); 102 return ByteCode; 92 103 } 93 104 … … 104 115 return -1; 105 116 106 #if ENABLE(YARR_JIT) 107 if (!!m_representation->m_regExpJITCode) { 108 #else 109 if (m_representation->m_regExpBytecode) { 110 #endif 117 if (m_state != ParseError) { 111 118 int offsetVectorSize = (m_numSubpatterns + 1) * 2; 112 119 int* offsetVector; … … 127 134 offsetVector[j] = -1; 128 135 136 int result; 129 137 #if ENABLE(YARR_JIT) 130 i nt result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector);131 #else 132 int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);138 if (m_state == JITCode) 139 result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector); 140 else 133 141 #endif 142 result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector); 134 143 135 144 ASSERT(result >= -1);; … … 163 172 164 173 char jitAddr[20]; 165 if ( codeBlock.getFallback())174 if (m_state == JITCode) 166 175 sprintf(jitAddr, "fallback"); 167 176 else -
trunk/JavaScriptCore/runtime/RegExp.h
r67146 r73124 42 42 bool multiline() const { return m_flagBits & Multiline; } 43 43 44 const UString& pattern() const { return m_pattern ; }44 const UString& pattern() const { return m_patternString; } 45 45 46 46 bool isValid() const { return !m_constructionError; } … … 57 57 RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags); 58 58 59 void compile(JSGlobalData*); 59 enum RegExpState { 60 ParseError, 61 JITCode, 62 ByteCode 63 } m_state; 64 65 RegExpState compile(JSGlobalData*); 60 66 61 67 enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 }; 62 63 UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this. 68 UString m_patternString; 64 69 int m_flagBits; 65 70 const char* m_constructionError;
Note:
See TracChangeset
for help on using the changeset viewer.