diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/runtime/RegExp.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/runtime/RegExp.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/RegExp.cpp | 86 |
1 files changed, 31 insertions, 55 deletions
diff --git a/Source/JavaScriptCore/runtime/RegExp.cpp b/Source/JavaScriptCore/runtime/RegExp.cpp index 26750b3c7..30c105d29 100644 --- a/Source/JavaScriptCore/runtime/RegExp.cpp +++ b/Source/JavaScriptCore/runtime/RegExp.cpp @@ -24,7 +24,7 @@ #include "RegExp.h" #include "Lexer.h" -#include "JSCInlines.h" +#include "Operations.h" #include "RegExpCache.h" #include "Yarr.h" #include "YarrJIT.h" @@ -40,7 +40,7 @@ namespace JSC { -const ClassInfo RegExp::s_info = { "RegExp", 0, 0, CREATE_METHOD_TABLE(RegExp) }; +const ClassInfo RegExp::s_info = { "RegExp", 0, 0, 0, CREATE_METHOD_TABLE(RegExp) }; RegExpFlags regExpFlags(const String& string) { @@ -113,7 +113,7 @@ RegExpFunctionalTestCollector* RegExpFunctionalTestCollector::get() return s_instance; } -void RegExpFunctionalTestCollector::outputOneTest(RegExp* regExp, const String& s, int startOffset, int* ovector, int result) +void RegExpFunctionalTestCollector::outputOneTest(RegExp* regExp, String s, int startOffset, int* ovector, int result) { if ((!m_lastRegExp) || (m_lastRegExp != regExp)) { m_lastRegExp = regExp; @@ -227,10 +227,6 @@ RegExp::RegExp(VM& vm, const String& patternString, RegExpFlags flags) , m_constructionError(0) , m_numSubpatterns(0) #if ENABLE(REGEXP_TRACING) - , m_rtMatchOnlyTotalSubjectStringLen(0.0) - , m_rtMatchTotalSubjectStringLen(0.0) - , m_rtMatchOnlyCallCount(0) - , m_rtMatchOnlyFoundCount(0) , m_rtMatchCallCount(0) , m_rtMatchFoundCount(0) #endif @@ -256,16 +252,6 @@ void RegExp::destroy(JSCell* cell) thisObject->RegExp::~RegExp(); } -size_t RegExp::estimatedSize(JSCell* cell) -{ - RegExp* thisObject = static_cast<RegExp*>(cell); - size_t regexDataSize = thisObject->m_regExpBytecode ? thisObject->m_regExpBytecode->estimatedSizeInBytes() : 0; -#if ENABLE(YARR_JIT) - regexDataSize += thisObject->m_regExpJITCode.size(); -#endif - return Base::estimatedSize(cell) + regexDataSize; -} - RegExp* RegExp::createWithoutCaching(VM& vm, const String& patternString, RegExpFlags flags) { RegExp* regExp = new (NotNull, allocateCell<RegExp>(vm.heap)) RegExp(vm, patternString, flags); @@ -283,10 +269,8 @@ void RegExp::compile(VM* vm, Yarr::YarrCharSize charSize) Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) { RELEASE_ASSERT_NOT_REACHED(); -#if COMPILER_QUIRK(CONSIDERS_UNREACHABLE_CODE) m_state = ParseError; return; -#endif } ASSERT(m_numSubpatterns == pattern.m_numSubpatterns); @@ -297,18 +281,24 @@ void RegExp::compile(VM* vm, Yarr::YarrCharSize charSize) } #if ENABLE(YARR_JIT) - if (!pattern.m_containsBackreferences && !pattern.containsUnsignedLengthPattern() && vm->canUseRegExpJIT()) { + if (!pattern.m_containsBackreferences && vm->canUseRegExpJIT()) { Yarr::jitCompile(pattern, charSize, vm, m_regExpJITCode); +#if ENABLE(YARR_JIT_DEBUG) + if (!m_regExpJITCode.isFallBack()) + m_state = JITCode; + else + m_state = ByteCode; +#else if (!m_regExpJITCode.isFallBack()) { m_state = JITCode; return; } +#endif } #else UNUSED_PARAM(charSize); #endif - m_state = ByteCode; m_regExpBytecode = Yarr::byteCompile(pattern, &vm->m_regExpAllocator); } @@ -334,7 +324,6 @@ int RegExp::match(VM& vm, const String& s, unsigned startOffset, Vector<int, 32> { #if ENABLE(REGEXP_TRACING) m_rtMatchCallCount++; - m_rtMatchTotalSubjectStringLen += (double)(s.length() - startOffset); #endif ASSERT(m_state != ParseError); @@ -402,10 +391,8 @@ void RegExp::compileMatchOnly(VM* vm, Yarr::YarrCharSize charSize) Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) { RELEASE_ASSERT_NOT_REACHED(); -#if COMPILER_QUIRK(CONSIDERS_UNREACHABLE_CODE) m_state = ParseError; return; -#endif } ASSERT(m_numSubpatterns == pattern.m_numSubpatterns); @@ -416,18 +403,24 @@ void RegExp::compileMatchOnly(VM* vm, Yarr::YarrCharSize charSize) } #if ENABLE(YARR_JIT) - if (!pattern.m_containsBackreferences && !pattern.containsUnsignedLengthPattern() && vm->canUseRegExpJIT()) { + if (!pattern.m_containsBackreferences && vm->canUseRegExpJIT()) { Yarr::jitCompile(pattern, charSize, vm, m_regExpJITCode, Yarr::MatchOnly); +#if ENABLE(YARR_JIT_DEBUG) + if (!m_regExpJITCode.isFallBack()) + m_state = JITCode; + else + m_state = ByteCode; +#else if (!m_regExpJITCode.isFallBack()) { m_state = JITCode; return; } +#endif } #else UNUSED_PARAM(charSize); #endif - m_state = ByteCode; m_regExpBytecode = Yarr::byteCompile(pattern, &vm->m_regExpAllocator); } @@ -452,8 +445,7 @@ void RegExp::compileIfNecessaryMatchOnly(VM& vm, Yarr::YarrCharSize charSize) MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset) { #if ENABLE(REGEXP_TRACING) - m_rtMatchOnlyCallCount++; - m_rtMatchOnlyTotalSubjectStringLen += (double)(s.length() - startOffset); + m_rtMatchCallCount++; #endif ASSERT(m_state != ParseError); @@ -466,7 +458,7 @@ MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset) m_regExpJITCode.execute(s.characters16(), startOffset, s.length()); #if ENABLE(REGEXP_TRACING) if (!result) - m_rtMatchOnlyFoundCount++; + m_rtMatchFoundCount++; #endif return result; } @@ -484,7 +476,7 @@ MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset) if (r >= 0) { #if ENABLE(REGEXP_TRACING) - m_rtMatchOnlyFoundCount++; + m_rtMatchFoundCount++; #endif return MatchResult(r, reinterpret_cast<unsigned*>(offsetVector)[1]); } @@ -492,7 +484,7 @@ MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset) return MatchResult::failed(); } -void RegExp::deleteCode() +void RegExp::invalidateCode() { if (!hasCode()) return; @@ -500,7 +492,7 @@ void RegExp::deleteCode() #if ENABLE(YARR_JIT) m_regExpJITCode.clear(); #endif - m_regExpBytecode = nullptr; + m_regExpBytecode.clear(); } #if ENABLE(YARR_JIT_DEBUG) @@ -571,32 +563,16 @@ void RegExp::matchCompareWithInterpreter(const String& s, int startOffset, int* Yarr::YarrCodeBlock& codeBlock = m_regExpJITCode; const size_t jitAddrSize = 20; - char jit8BitMatchOnlyAddr[jitAddrSize]; - char jit16BitMatchOnlyAddr[jitAddrSize]; - char jit8BitMatchAddr[jitAddrSize]; - char jit16BitMatchAddr[jitAddrSize]; - if (m_state == ByteCode) { - snprintf(jit8BitMatchOnlyAddr, jitAddrSize, "fallback "); - snprintf(jit16BitMatchOnlyAddr, jitAddrSize, "---- "); - snprintf(jit8BitMatchAddr, jitAddrSize, "fallback "); - snprintf(jit16BitMatchAddr, jitAddrSize, "---- "); - } else { - snprintf(jit8BitMatchOnlyAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get8BitMatchOnlyAddr())); - snprintf(jit16BitMatchOnlyAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get16BitMatchOnlyAddr())); - snprintf(jit8BitMatchAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get8BitMatchAddr())); - snprintf(jit16BitMatchAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get16BitMatchAddr())); - } + char jitAddr[jitAddrSize]; + if (m_state == JITCode) + snprintf(jitAddr, jitAddrSize, "fallback"); + else + snprintf(jitAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.getAddr())); #else - const char* jit8BitMatchOnlyAddr = "JIT Off"; - const char* jit16BitMatchOnlyAddr = ""; - const char* jit8BitMatchAddr = "JIT Off"; - const char* jit16BitMatchAddr = ""; + const char* jitAddr = "JIT Off"; #endif - unsigned averageMatchOnlyStringLen = (unsigned)(m_rtMatchOnlyTotalSubjectStringLen / m_rtMatchOnlyCallCount); - unsigned averageMatchStringLen = (unsigned)(m_rtMatchTotalSubjectStringLen / m_rtMatchCallCount); - printf("%-40.40s %16.16s %16.16s %10d %10d %10u\n", formattedPattern, jit8BitMatchOnlyAddr, jit16BitMatchOnlyAddr, m_rtMatchOnlyCallCount, m_rtMatchOnlyFoundCount, averageMatchOnlyStringLen); - printf(" %16.16s %16.16s %10d %10d %10u\n", jit8BitMatchAddr, jit16BitMatchAddr, m_rtMatchCallCount, m_rtMatchFoundCount, averageMatchStringLen); + printf("%-40.40s %16.16s %10d %10d\n", formattedPattern, jitAddr, m_rtMatchCallCount, m_rtMatchFoundCount); } #endif |