Changeset 66936 in webkit for trunk/JavaScriptCore/runtime/RegExp.cpp
- Timestamp:
- Sep 7, 2010, 5:33:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExp.cpp
r66031 r66936 47 47 namespace JSC { 48 48 49 struct RegExpRepresentation { 50 #if ENABLE(YARR_JIT) 51 Yarr::RegexCodeBlock m_regExpJITCode; 52 #elif ENABLE(YARR) 53 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 } 63 #endif 64 }; 65 49 66 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags) 50 67 : m_pattern(pattern) … … 52 69 , m_constructionError(0) 53 70 , m_numSubpatterns(0) 71 , m_representation(adoptPtr(new RegExpRepresentation)) 54 72 { 55 73 // NOTE: The global flag is handled on a case-by-case basis by functions like … … 66 84 } 67 85 68 #if !ENABLE(YARR)69 86 RegExp::~RegExp() 70 87 { 71 jsRegExpFree(m_regExp); 72 } 73 #endif 88 } 74 89 75 90 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags) … … 83 98 { 84 99 #if ENABLE(YARR_JIT) 85 Yarr::jitCompileRegex(globalData, m_re gExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());86 #else 87 m_re gExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());100 Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline()); 101 #else 102 m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline()); 88 103 #endif 89 104 } … … 100 115 101 116 #if ENABLE(YARR_JIT) 102 if (!!m_re gExpJITCode) {103 #else 104 if (m_re gExpBytecode) {117 if (!!m_representation->m_regExpJITCode) { 118 #else 119 if (m_representation->m_regExpBytecode) { 105 120 #endif 106 121 int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre. … … 120 135 121 136 #if ENABLE(YARR_JIT) 122 int result = Yarr::executeRegex(m_re gExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);123 #else 124 int result = Yarr::interpretRegex(m_re gExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);137 int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize); 138 #else 139 int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector); 125 140 #endif 126 141 … … 145 160 void RegExp::compile(JSGlobalData*) 146 161 { 147 m_re gExp = 0;162 m_representation->m_regExp = 0; 148 163 JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase; 149 164 JSRegExpMultilineOption multilineOption = multiline() ? JSRegExpMultiline : JSRegExpSingleLine; 150 m_re gExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);165 m_representation->m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); 151 166 } 152 167 … … 161 176 return -1; 162 177 163 if (m_re gExp) {178 if (m_representation->m_regExp) { 164 179 // Set up the offset vector for the result. 165 180 // First 2/3 used for result, the last third used by PCRE. … … 176 191 } 177 192 178 int numMatches = jsRegExpExecute(m_re gExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);193 int numMatches = jsRegExpExecute(m_representation->m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize); 179 194 180 195 if (numMatches < 0) {
Note:
See TracChangeset
for help on using the changeset viewer.