[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

abecsi at webkit.org abecsi at webkit.org
Wed Dec 22 17:54:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 59e1c412caad80c6dff18bffa2f26d6a05353f84
Author: abecsi at webkit.org <abecsi at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 13:36:45 2010 +0000

    2010-12-02  Peter Varga  <pvarga at inf.u-szeged.hu>
    
            Reviewed by Gavin Barraclough.
    
            Move regex parsing and fallback handling to runtime/RegExp.cpp
            https://bugs.webkit.org/show_bug.cgi?id=50015
    
            * runtime/RegExp.cpp:
            (JSC::RegExp::RegExp):
            (JSC::RegExp::create):
            (JSC::RegExp::compile):
            (JSC::RegExp::match):
            (JSC::RegExp::printTraceData):
            * runtime/RegExp.h:
            (JSC::RegExp::pattern):
            * yarr/RegexInterpreter.cpp:
            * yarr/RegexInterpreter.h:
            * yarr/RegexJIT.cpp:
            (JSC::Yarr::RegexGenerator::compile):
            (JSC::Yarr::jitCompileRegex):
            * yarr/RegexJIT.h:
            (JSC::Yarr::RegexCodeBlock::RegexCodeBlock):
            (JSC::Yarr::RegexCodeBlock::setFallBack):
            (JSC::Yarr::RegexCodeBlock::isFallBack):
            (JSC::Yarr::executeRegex):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 7175c5d..b3b0135 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-12-02  Peter Varga  <pvarga at inf.u-szeged.hu>
+
+        Reviewed by Gavin Barraclough.
+
+        Move regex parsing and fallback handling to runtime/RegExp.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=50015
+
+        * runtime/RegExp.cpp:
+        (JSC::RegExp::RegExp):
+        (JSC::RegExp::create):
+        (JSC::RegExp::compile):
+        (JSC::RegExp::match):
+        (JSC::RegExp::printTraceData):
+        * runtime/RegExp.h:
+        (JSC::RegExp::pattern):
+        * yarr/RegexInterpreter.cpp:
+        * yarr/RegexInterpreter.h:
+        * yarr/RegexJIT.cpp:
+        (JSC::Yarr::RegexGenerator::compile):
+        (JSC::Yarr::jitCompileRegex):
+        * yarr/RegexJIT.h:
+        (JSC::Yarr::RegexCodeBlock::RegexCodeBlock):
+        (JSC::Yarr::RegexCodeBlock::setFallBack):
+        (JSC::Yarr::RegexCodeBlock::isFallBack):
+        (JSC::Yarr::executeRegex):
+
 2010-12-01  Geoffrey Garen  <ggaren at apple.com>
 
         Try to fix the GTK build.
diff --git a/JavaScriptCore/runtime/RegExp.cpp b/JavaScriptCore/runtime/RegExp.cpp
index a33fa91..9b2e3f3 100644
--- a/JavaScriptCore/runtime/RegExp.cpp
+++ b/JavaScriptCore/runtime/RegExp.cpp
@@ -2,6 +2,7 @@
  *  Copyright (C) 1999-2001, 2004 Harri Porten (porten at kde.org)
  *  Copyright (c) 2007, 2008 Apple Inc. All rights reserved.
  *  Copyright (C) 2009 Torch Mobile, Inc.
+ *  Copyright (C) 2010 Peter Varga (pvarga at inf.u-szeged.hu), University of Szeged
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -29,24 +30,21 @@
 #include <wtf/OwnArrayPtr.h>
 
 #include "yarr/RegexCompiler.h"
-#if ENABLE(YARR_JIT)
 #include "yarr/RegexJIT.h"
-#else
 #include "yarr/RegexInterpreter.h"
-#endif
+#include "yarr/RegexPattern.h"
 
 namespace JSC {
 
 struct RegExpRepresentation {
 #if ENABLE(YARR_JIT)
     Yarr::RegexCodeBlock m_regExpJITCode;
-#else
-    OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
 #endif
+    OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
 };
 
-inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags)
-    : m_pattern(pattern)
+inline RegExp::RegExp(JSGlobalData* globalData, const UString& patternString, const UString& flags)
+    : m_patternString(patternString)
     , m_flagBits(0)
     , m_constructionError(0)
     , m_numSubpatterns(0)
@@ -66,29 +64,42 @@ inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const US
         if (flags.find('m') != notFound)
             m_flagBits |= Multiline;
     }
-    compile(globalData);
+
+    m_state = compile(globalData);
 }
 
 RegExp::~RegExp()
 {
 }
 
-PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
+PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& patternString, const UString& flags)
 {
-    RefPtr<RegExp> res = adoptRef(new RegExp(globalData, pattern, flags));
+    RefPtr<RegExp> res = adoptRef(new RegExp(globalData, patternString, flags));
 #if ENABLE(REGEXP_TRACING)
     globalData->addRegExpToTrace(res);
 #endif
     return res.release();
 }
 
-void RegExp::compile(JSGlobalData* globalData)
+RegExp::RegExpState RegExp::compile(JSGlobalData* globalData)
 {
+    Yarr::RegexPattern pattern(ignoreCase(), multiline());
+
+    if ((m_constructionError = Yarr::compileRegex(m_patternString, pattern)))
+        return ParseError;
+
+    m_numSubpatterns = pattern.m_numSubpatterns;
+
 #if ENABLE(YARR_JIT)
-    Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
-#else
-    m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
+    if (!pattern.m_containsBackreferences && globalData->canUseJIT()) {
+        Yarr::jitCompileRegex(pattern, globalData, m_representation->m_regExpJITCode);
+        if (!m_representation->m_regExpJITCode.isFallBack())
+            return JITCode;
+    }
 #endif
+
+    m_representation->m_regExpBytecode = Yarr::byteCompileRegex(pattern, &globalData->m_regexAllocator);
+    return ByteCode;
 }
 
 int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
@@ -103,11 +114,7 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
     if (static_cast<unsigned>(startOffset) > s.length() || s.isNull())
         return -1;
 
-#if ENABLE(YARR_JIT)
-    if (!!m_representation->m_regExpJITCode) {
-#else
-    if (m_representation->m_regExpBytecode) {
-#endif
+    if (m_state != ParseError) {
         int offsetVectorSize = (m_numSubpatterns + 1) * 2;
         int* offsetVector;
         Vector<int, 32> nonReturnedOvector;
@@ -126,11 +133,13 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
         for (unsigned j = 0, i = 0; i < m_numSubpatterns + 1; j += 2, i++)            
             offsetVector[j] = -1;
 
+        int result;
 #if ENABLE(YARR_JIT)
-        int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector);
-#else
-        int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
+        if (m_state == JITCode)
+            result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector);
+        else
 #endif
+            result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
 
         ASSERT(result >= -1);;
         
@@ -162,7 +171,7 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
         Yarr::RegexCodeBlock& codeBlock = m_representation->m_regExpJITCode;
 
         char jitAddr[20];
-        if (codeBlock.getFallback())
+        if (m_state == JITCode)
             sprintf(jitAddr, "fallback");
         else
             sprintf(jitAddr, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.getAddr()));
diff --git a/JavaScriptCore/runtime/RegExp.h b/JavaScriptCore/runtime/RegExp.h
index e6e2fbc..8f33f57 100644
--- a/JavaScriptCore/runtime/RegExp.h
+++ b/JavaScriptCore/runtime/RegExp.h
@@ -41,7 +41,7 @@ namespace JSC {
         bool ignoreCase() const { return m_flagBits & IgnoreCase; }
         bool multiline() const { return m_flagBits & Multiline; }
 
-        const UString& pattern() const { return m_pattern; }
+        const UString& pattern() const { return m_patternString; }
 
         bool isValid() const { return !m_constructionError; }
         const char* errorMessage() const { return m_constructionError; }
@@ -56,11 +56,16 @@ namespace JSC {
     private:
         RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags);
 
-        void compile(JSGlobalData*);
+        enum RegExpState {
+            ParseError,
+            JITCode,
+            ByteCode
+        } m_state;
 
-        enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 };
+        RegExpState compile(JSGlobalData*);
 
-        UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this.
+        enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 };
+        UString m_patternString;
         int m_flagBits;
         const char* m_constructionError;
         unsigned m_numSubpatterns;
diff --git a/JavaScriptCore/yarr/RegexInterpreter.cpp b/JavaScriptCore/yarr/RegexInterpreter.cpp
index a51cd25..d0fe41d 100644
--- a/JavaScriptCore/yarr/RegexInterpreter.cpp
+++ b/JavaScriptCore/yarr/RegexInterpreter.cpp
@@ -1883,19 +1883,6 @@ private:
     Vector<ByteDisjunction*> m_allParenthesesInfo;
 };
 
-
-PassOwnPtr<BytecodePattern> byteCompileRegex(const UString& patternString, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator* allocator, bool ignoreCase, bool multiline)
-{
-    RegexPattern pattern(ignoreCase, multiline);
-
-    if ((error = compileRegex(patternString, pattern)))
-        return PassOwnPtr<BytecodePattern>();
-
-    numSubpatterns = pattern.m_numSubpatterns;
-
-    return ByteCompiler(pattern).compile(allocator);
-}
-
 PassOwnPtr<BytecodePattern> byteCompileRegex(RegexPattern& pattern, BumpPointerAllocator* allocator)
 {
     return ByteCompiler(pattern).compile(allocator);
diff --git a/JavaScriptCore/yarr/RegexInterpreter.h b/JavaScriptCore/yarr/RegexInterpreter.h
index 2e23472..3980ab9 100644
--- a/JavaScriptCore/yarr/RegexInterpreter.h
+++ b/JavaScriptCore/yarr/RegexInterpreter.h
@@ -364,7 +364,6 @@ private:
     Vector<CharacterClass*> m_userCharacterClasses;
 };
 
-PassOwnPtr<BytecodePattern> byteCompileRegex(const UString& pattern, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator*, bool ignoreCase = false, bool multiline = false);
 PassOwnPtr<BytecodePattern> byteCompileRegex(RegexPattern& pattern, BumpPointerAllocator*);
 int interpretRegex(BytecodePattern* v_regex, const UChar* input, unsigned start, unsigned length, int* output);
 
diff --git a/JavaScriptCore/yarr/RegexJIT.cpp b/JavaScriptCore/yarr/RegexJIT.cpp
index 1eac667..04fa69e 100644
--- a/JavaScriptCore/yarr/RegexJIT.cpp
+++ b/JavaScriptCore/yarr/RegexJIT.cpp
@@ -31,7 +31,6 @@
 #include "LinkBuffer.h"
 #include "MacroAssembler.h"
 #include "RegexCompiler.h"
-#include "RegexInterpreter.h" // temporary, remove when fallback is removed.
 
 #if ENABLE(YARR_JIT)
 
@@ -1496,11 +1495,7 @@ public:
             patchBuffer.patch(m_backtrackRecords[i].dataLabel, patchBuffer.locationOf(m_backtrackRecords[i].backtrackLocation));
 
         jitObject.set(patchBuffer.finalizeCode());
-    }
-
-    bool shouldFallBack()
-    {
-        return m_shouldFallBack;
+        jitObject.setFallBack(m_shouldFallBack);
     }
 
 private:
@@ -1509,23 +1504,13 @@ private:
     Vector<AlternativeBacktrackRecord> m_backtrackRecords;
 };
 
-void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& patternString, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator* allocator, bool ignoreCase, bool multiline)
+void jitCompileRegex(RegexPattern& pattern, JSGlobalData* globalData, RegexCodeBlock& jitObject)
 {
-    RegexPattern pattern(ignoreCase, multiline);
-    if ((error = compileRegex(patternString, pattern)))
-        return;
-    numSubpatterns = pattern.m_numSubpatterns;
-
-    if (!pattern.m_containsBackreferences && globalData->canUseJIT()) {
-        RegexGenerator generator(pattern);
-        generator.compile(globalData, jitObject);
-        if (!generator.shouldFallBack())
-            return;
-    }
-
-    jitObject.setFallback(byteCompileRegex(pattern, allocator));
+    RegexGenerator generator(pattern);
+    generator.compile(globalData, jitObject);
 }
 
+
 }}
 
 #endif
diff --git a/JavaScriptCore/yarr/RegexJIT.h b/JavaScriptCore/yarr/RegexJIT.h
index c4c382c..5e3dca1 100644
--- a/JavaScriptCore/yarr/RegexJIT.h
+++ b/JavaScriptCore/yarr/RegexJIT.h
@@ -29,7 +29,6 @@
 #if ENABLE(YARR_JIT)
 
 #include "MacroAssembler.h"
-#include "RegexInterpreter.h" // temporary, remove when fallback is removed.
 #include "RegexPattern.h"
 #include "UString.h"
 
@@ -51,7 +50,7 @@ class RegexCodeBlock {
 
 public:
     RegexCodeBlock()
-        : m_needFallback(false)
+        : m_needFallBack(false)
     {
     }
 
@@ -59,15 +58,8 @@ public:
     {
     }
 
-    BytecodePattern* getFallback() { return m_fallback.get(); }
-    bool isFallback() { return m_needFallback; }
-    void setFallback(PassOwnPtr<BytecodePattern> fallback)
-    {
-        m_fallback = fallback;
-        m_needFallback = true;
-    }
-
-    bool operator!() { return (!m_ref.m_code.executableAddress() && !m_fallback); }
+    void setFallBack(bool fallback) { m_needFallBack = fallback; }
+    bool isFallBack() { return m_needFallBack; }
     void set(MacroAssembler::CodeRef ref) { m_ref = ref; }
 
     int execute(const UChar* input, unsigned start, unsigned length, int* output)
@@ -81,17 +73,13 @@ public:
 
 private:
     MacroAssembler::CodeRef m_ref;
-    OwnPtr<Yarr::BytecodePattern> m_fallback;
-    bool m_needFallback;
+    bool m_needFallBack;
 };
 
-void jitCompileRegex(JSGlobalData* globalData, RegexCodeBlock& jitObject, const UString& pattern, unsigned& numSubpatterns, const char*& error, BumpPointerAllocator* allocator, bool ignoreCase = false, bool multiline = false);
+void jitCompileRegex(RegexPattern& pattern, JSGlobalData* globalData, RegexCodeBlock& jitObject);
 
 inline int executeRegex(RegexCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output)
 {
-    if (jitObject.isFallback())
-        return (interpretRegex(jitObject.getFallback(), input, start, length, output));
-
     return jitObject.execute(input, start, length, output);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list