Changeset 112564 in webkit
- Timestamp:
- Mar 29, 2012 1:16:03 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r112562 r112564 1 2012-03-29 Gavin Barraclough <barraclough@apple.com> 2 3 Template the Yarr::Interpreter on the character type 4 https://bugs.webkit.org/show_bug.cgi?id=82637 5 6 Reviewed by Sam Weinig. 7 8 We should be able to call to the interpreter after having already checked the character type, 9 without having to re-package the character pointer back up into a string! 10 11 * runtime/RegExp.cpp: 12 (JSC::RegExp::match): 13 (JSC::RegExp::matchCompareWithInterpreter): 14 - Don't pass length. 15 * yarr/Yarr.h: 16 - moved function declarations to YarrInterpreter.h. 17 * yarr/YarrInterpreter.cpp: 18 (Yarr): 19 (Interpreter): 20 (JSC::Yarr::Interpreter::InputStream::InputStream): 21 (InputStream): 22 (JSC::Yarr::Interpreter::Interpreter): 23 (JSC::Yarr::interpret): 24 - templated Interpreter class on CharType. 25 * yarr/YarrInterpreter.h: 26 (Yarr): 27 - added function declarations. 28 1 29 2012-03-29 David Kilzer <ddkilzer@apple.com> 2 30 -
trunk/Source/JavaScriptCore/runtime/RegExp.cpp
r112536 r112564 344 344 } else 345 345 #endif 346 result = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, s.length(),reinterpret_cast<unsigned*>(offsetVector));346 result = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(offsetVector)); 347 347 348 348 // FIXME: The YARR engine should handle unsigned or size_t length matches. … … 468 468 nonReturnedOvector.resize(offsetVectorSize); 469 469 offsetVector = nonReturnedOvector.data(); 470 int r = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, s.length(),reinterpret_cast<unsigned*>(offsetVector));470 int r = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(offsetVector)); 471 471 #if REGEXP_FUNC_TEST_DATA_GEN 472 472 RegExpFunctionalTestCollector::get()->outputOneTest(this, s, startOffset, offsetVector, result); … … 510 510 interpreterOffsetVector[j] = -1; 511 511 512 interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, s.length(),interpreterOffsetVector);512 interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, interpreterOffsetVector); 513 513 514 514 if (jitResult != interpreterResult) -
trunk/Source/JavaScriptCore/yarr/Yarr.h
r108858 r112564 64 64 }; 65 65 66 JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);67 JS_EXPORT_PRIVATE unsigned interpret(BytecodePattern*, const UString& input, unsigned start, unsigned length, unsigned* output);68 69 66 } } // namespace JSC::Yarr 70 67 -
trunk/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
r112143 r112564 43 43 namespace JSC { namespace Yarr { 44 44 45 template<typename CharType> 45 46 class Interpreter { 46 47 public: … … 171 172 } 172 173 173 // This class is a placeholder for future character iterator, current174 // proposed name StringConstCharacterIterator.175 class CharAccess {176 public:177 CharAccess(const UString& s)178 {179 if (s.is8Bit()) {180 m_charSize = Char8;181 m_ptr.ptr8 = s.characters8();182 } else {183 m_charSize = Char16;184 m_ptr.ptr16 = s.characters16();185 }186 }187 188 CharAccess(const LChar* ptr)189 : m_charSize(Char8)190 {191 m_ptr.ptr8 = ptr;192 }193 194 CharAccess(const UChar* ptr)195 : m_charSize(Char16)196 {197 m_ptr.ptr16 = ptr;198 }199 200 ~CharAccess()201 {202 }203 204 inline UChar operator[](unsigned index)205 {206 if (m_charSize == Char8)207 return m_ptr.ptr8[index];208 return m_ptr.ptr16[index];209 }210 211 private:212 union {213 const LChar* ptr8;214 const UChar* ptr16;215 } m_ptr;216 YarrCharSize m_charSize;217 };218 219 174 class InputStream { 220 175 public: 221 InputStream(const UString&input, unsigned start, unsigned length)176 InputStream(const CharType* input, unsigned start, unsigned length) 222 177 : input(input) 223 178 , pos(start) … … 333 288 334 289 private: 335 CharAccessinput;290 const CharType* input; 336 291 unsigned pos; 337 292 unsigned length; … … 1490 1445 } 1491 1446 1492 Interpreter(BytecodePattern* pattern, unsigned* output, const UString input, unsigned start, unsigned length)1447 Interpreter(BytecodePattern* pattern, unsigned* output, const CharType* input, unsigned length, unsigned start) 1493 1448 : pattern(pattern) 1494 1449 , output(output) … … 1980 1935 } 1981 1936 1982 unsigned interpret(BytecodePattern* bytecode, const UString& input, unsigned start, unsigned length, unsigned* output)1937 unsigned interpret(BytecodePattern* bytecode, const UString& input, unsigned start, unsigned* output) 1983 1938 { 1984 return Interpreter(bytecode, output, input, start, length).interpret(); 1939 if (input.is8Bit()) 1940 return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret(); 1941 return Interpreter<UChar>(bytecode, output, input.characters16(), input.length(), start).interpret(); 1985 1942 } 1986 1943 1987 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter); 1988 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass); 1989 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference); 1990 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoAlternative) == (YarrStackSpaceForBackTrackInfoAlternative * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoAlternative); 1991 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoParentheticalAssertion) == (YarrStackSpaceForBackTrackInfoParentheticalAssertion * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheticalAssertion); 1992 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoParenthesesOnce) == (YarrStackSpaceForBackTrackInfoParenthesesOnce * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParenthesesOnce); 1993 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoParentheses) == (YarrStackSpaceForBackTrackInfoParentheses * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheses); 1944 unsigned interpret(BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output) 1945 { 1946 return Interpreter<LChar>(bytecode, output, input, length, start).interpret(); 1947 } 1948 1949 unsigned interpret(BytecodePattern* bytecode, const UChar* input, unsigned length, unsigned start, unsigned* output) 1950 { 1951 return Interpreter<UChar>(bytecode, output, input, length, start).interpret(); 1952 } 1953 1954 // These should be the same for both UChar & LChar. 1955 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter); 1956 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass); 1957 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference); 1958 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoAlternative) == (YarrStackSpaceForBackTrackInfoAlternative * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoAlternative); 1959 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheticalAssertion) == (YarrStackSpaceForBackTrackInfoParentheticalAssertion * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheticalAssertion); 1960 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParenthesesOnce) == (YarrStackSpaceForBackTrackInfoParenthesesOnce * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParenthesesOnce); 1961 COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheses) == (YarrStackSpaceForBackTrackInfoParentheses * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheses); 1994 1962 1995 1963 -
trunk/Source/JavaScriptCore/yarr/YarrInterpreter.h
r108858 r112564 376 376 }; 377 377 378 JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*); 379 JS_EXPORT_PRIVATE unsigned interpret(BytecodePattern*, const UString& input, unsigned start, unsigned* output); 380 unsigned interpret(BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output); 381 unsigned interpret(BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output); 382 378 383 } } // namespace JSC::Yarr 379 384 -
trunk/Source/WebCore/ChangeLog
r112559 r112564 1 2012-03-29 Gavin Barraclough <barraclough@apple.com> 2 3 Template the Yarr::Interpreter on the character type 4 https://bugs.webkit.org/show_bug.cgi?id=82637 5 6 Reviewed by Sam Weinig. 7 8 We should be able to call to the interpreter after having already checked the character type, 9 without having to re-package the character pointer back up into a string! 10 11 * inspector/ContentSearchUtils.cpp: 12 (WebCore::ContentSearchUtils::findMagicComment): 13 * platform/text/RegularExpression.cpp: 14 (WebCore::RegularExpression::match): 15 - Don't pass length. 16 1 17 2012-03-29 Sheriff Bot <webkit.review.bot@gmail.com> 2 18 -
trunk/Source/WebCore/inspector/ContentSearchUtils.cpp
r111005 r112564 153 153 Vector<int, 4> matches; 154 154 matches.resize(4); 155 unsigned result = JSC::Yarr::interpret(bytecodePattern.get(), JSC::UString(content.impl()), 0, content.length(),reinterpret_cast<unsigned*>(matches.data()));155 unsigned result = JSC::Yarr::interpret(bytecodePattern.get(), JSC::UString(content.impl()), 0, reinterpret_cast<unsigned*>(matches.data())); 156 156 if (result == JSC::Yarr::offsetNoMatch) 157 157 return String(); -
trunk/Source/WebCore/platform/text/RegularExpression.cpp
r108874 r112564 113 113 unsigned result; 114 114 if (str.length() <= INT_MAX) 115 result = JSC::Yarr::interpret(d->m_regExpByteCode.get(), JSC::UString(str.impl()), startFrom, str.length(),offsetVector);115 result = JSC::Yarr::interpret(d->m_regExpByteCode.get(), JSC::UString(str.impl()), startFrom, offsetVector); 116 116 else { 117 117 // This code can't handle unsigned offsets. Limit our processing to strings with offsets that
Note: See TracChangeset
for help on using the changeset viewer.