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

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 13:09:51 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7648c2450d3fc97d4d8eb2938ee4a3cf6c9ae700
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 8 00:33:15 2010 +0000

    2010-09-07  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Oliver Hunt.
    
            pushState and replaceState do not clone RegExp objects correctly
            https://bugs.webkit.org/show_bug.cgi?id=44718
    
            Move internal representation of JSC::RegExp (which depends on wether
            YARR and YARR_JIT is enabled) into RegExpRepresentation which can live
            in the implementation only. This makes it feasible to use RegExp in
            WebCore without bringing in all of YARR.
    
            * JavaScriptCore.exp: Export RegExp and RegExpObject functions that are
            needed inside WebCore's JSC bindings.
            * runtime/RegExp.cpp:
            (JSC::RegExpRepresentation::~RegExpRepresentation):
            (JSC::RegExp::RegExp):
            (JSC::RegExp::~RegExp):
            (JSC::RegExp::compile):
            (JSC::RegExp::match):
            * runtime/RegExp.h:
    2010-09-07  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Oliver Hunt.
    
            pushState and replaceState do not clone RegExp objects correctly
            https://bugs.webkit.org/show_bug.cgi?id=44718
    
            Make RegExp test of pushstate-object-types.html actually test a RegExp
            value with flags.
    
            Also adds ImageData since it can be serialized as of r54646.
    
            * fast/loader/stateobjects/pushstate-object-types-expected.txt:
            * fast/loader/stateobjects/pushstate-object-types.html:
    2010-09-07  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Oliver Hunt.
    
            pushState and replaceState do not clone RegExp objects correctly
            https://bugs.webkit.org/show_bug.cgi?id=44718
    
            Add RegExp support to the JSC implementation of SerializedScriptValue
            (it stores the pattern and flags read from a RegExpObject, and creates
            a new one on deserialization).
    
            Tests: fast/loader/stateobjects/pushstate-object-types.html
    
            * ForwardingHeaders/runtime/RegExp.h: Added.
            * ForwardingHeaders/runtime/RegExpObject.h: Added.
            * bindings/js/SerializedScriptValue.cpp:
            (WebCore::CloneSerializer::dumpIfTerminal):
            (WebCore::CloneDeserializer::readTerminal):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66936 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 69f365c..3e501de 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-09-07  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Oliver Hunt.
+
+        pushState and replaceState do not clone RegExp objects correctly
+        https://bugs.webkit.org/show_bug.cgi?id=44718
+        
+        Move internal representation of JSC::RegExp (which depends on wether
+        YARR and YARR_JIT is enabled) into RegExpRepresentation which can live
+        in the implementation only. This makes it feasible to use RegExp in
+        WebCore without bringing in all of YARR.
+
+        * JavaScriptCore.exp: Export RegExp and RegExpObject functions that are
+        needed inside WebCore's JSC bindings.
+        * runtime/RegExp.cpp:
+        (JSC::RegExpRepresentation::~RegExpRepresentation):
+        (JSC::RegExp::RegExp):
+        (JSC::RegExp::~RegExp):
+        (JSC::RegExp::compile):
+        (JSC::RegExp::match):
+        * runtime/RegExp.h:
+
 2010-09-07  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 7df9376..b8fbb08 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -481,6 +481,8 @@ __ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
 __ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_10JSFunctionE
 __ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
 __ZNK3JSC12PropertySlot14functionGetterEPNS_9ExecStateE
+__ZN3JSC12RegExpObject4infoE
+__ZN3JSC12RegExpObjectC1EPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEENS4_INS_6RegExpEEE
 __ZNK3JSC14JSGlobalObject14isDynamicScopeERb
 __ZNK3JSC16InternalFunction9classInfoEv
 __ZNK3JSC16JSVariableObject16isVariableObjectEv
@@ -511,6 +513,8 @@ __ZNK3JSC6JSCell9getStringEPNS_9ExecStateE
 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateERNS_7UStringE
 __ZNK3JSC6JSCell9getUInt32ERj
 __ZNK3JSC6JSCell9toBooleanEPNS_9ExecStateE
+__ZN3JSC6RegExp6createEPNS_12JSGlobalDataERKNS_7UStringES5_
+__ZN3JSC6RegExpD1Ev
 __ZNK3JSC7ArgList8getSliceEiRS0_
 __ZNK3JSC7JSArray12subclassDataEv
 __ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateE
diff --git a/JavaScriptCore/runtime/RegExp.cpp b/JavaScriptCore/runtime/RegExp.cpp
index 5ad9f3f..cb9342c 100644
--- a/JavaScriptCore/runtime/RegExp.cpp
+++ b/JavaScriptCore/runtime/RegExp.cpp
@@ -46,11 +46,29 @@
 
 namespace JSC {
 
+struct RegExpRepresentation {
+#if ENABLE(YARR_JIT)
+    Yarr::RegexCodeBlock m_regExpJITCode;
+#elif ENABLE(YARR)
+    OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
+#else
+    JSRegExp* m_regExp;
+#endif
+
+#if !ENABLE(YARR)
+    ~RegExpRepresentation()
+    {
+        jsRegExpFree(m_regExp);
+    }
+#endif
+};
+
 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags)
     : m_pattern(pattern)
     , m_flagBits(0)
     , m_constructionError(0)
     , m_numSubpatterns(0)
+    , m_representation(adoptPtr(new RegExpRepresentation))
 {
     // NOTE: The global flag is handled on a case-by-case basis by functions like
     // String::match and RegExpObject::match.
@@ -65,12 +83,9 @@ inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const US
     compile(globalData);
 }
 
-#if !ENABLE(YARR)
 RegExp::~RegExp()
 {
-    jsRegExpFree(m_regExp);
 }
-#endif
 
 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
 {
@@ -82,9 +97,9 @@ PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& patte
 void RegExp::compile(JSGlobalData* globalData)
 {
 #if ENABLE(YARR_JIT)
-    Yarr::jitCompileRegex(globalData, m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());
+    Yarr::jitCompileRegex(globalData, m_representation->m_regExpJITCode, m_pattern, m_numSubpatterns, m_constructionError, ignoreCase(), multiline());
 #else
-    m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
+    m_representation->m_regExpBytecode = Yarr::byteCompileRegex(m_pattern, m_numSubpatterns, m_constructionError, &globalData->m_regexAllocator, ignoreCase(), multiline());
 #endif
 }
 
@@ -99,9 +114,9 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
         return -1;
 
 #if ENABLE(YARR_JIT)
-    if (!!m_regExpJITCode) {
+    if (!!m_representation->m_regExpJITCode) {
 #else
-    if (m_regExpBytecode) {
+    if (m_representation->m_regExpBytecode) {
 #endif
         int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre.
         int* offsetVector;
@@ -119,9 +134,9 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
             offsetVector[j] = -1;
 
 #if ENABLE(YARR_JIT)
-        int result = Yarr::executeRegex(m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
+        int result = Yarr::executeRegex(m_representation->m_regExpJITCode, s.characters(), startOffset, s.length(), offsetVector, offsetVectorSize);
 #else
-        int result = Yarr::interpretRegex(m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
+        int result = Yarr::interpretRegex(m_representation->m_regExpBytecode.get(), s.characters(), startOffset, s.length(), offsetVector);
 #endif
 
         if (result < 0) {
@@ -144,10 +159,10 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
 
 void RegExp::compile(JSGlobalData*)
 {
-    m_regExp = 0;
+    m_representation->m_regExp = 0;
     JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase;
     JSRegExpMultilineOption multilineOption = multiline() ? JSRegExpMultiline : JSRegExpSingleLine;
-    m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
+    m_representation->m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.characters()), m_pattern.length(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError);
 }
 
 int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
@@ -160,7 +175,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 (m_regExp) {
+    if (m_representation->m_regExp) {
         // Set up the offset vector for the result.
         // First 2/3 used for result, the last third used by PCRE.
         int* offsetVector;
@@ -175,7 +190,7 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
             offsetVector = ovector->data();
         }
 
-        int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);
+        int numMatches = jsRegExpExecute(m_representation->m_regExp, reinterpret_cast<const UChar*>(s.characters()), s.length(), startOffset, offsetVector, offsetVectorSize);
     
         if (numMatches < 0) {
 #ifndef NDEBUG
diff --git a/JavaScriptCore/runtime/RegExp.h b/JavaScriptCore/runtime/RegExp.h
index aadad6b..befbb8e 100644
--- a/JavaScriptCore/runtime/RegExp.h
+++ b/JavaScriptCore/runtime/RegExp.h
@@ -26,21 +26,16 @@
 #include "ExecutableAllocator.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
-#include "yarr/RegexJIT.h"
-#include "yarr/RegexInterpreter.h"
-
-struct JSRegExp;
 
 namespace JSC {
 
+    struct RegExpRepresentation;
     class JSGlobalData;
 
     class RegExp : public RefCounted<RegExp> {
     public:
         static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern, const UString& flags);
-#if !ENABLE(YARR)
         ~RegExp();
-#endif
 
         bool global() const { return m_flagBits & Global; }
         bool ignoreCase() const { return m_flagBits & IgnoreCase; }
@@ -65,14 +60,8 @@ namespace JSC {
         int m_flagBits;
         const char* m_constructionError;
         unsigned m_numSubpatterns;
-
-#if ENABLE(YARR_JIT)
-        Yarr::RegexCodeBlock m_regExpJITCode;
-#elif ENABLE(YARR)
-        OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
-#else
-        JSRegExp* m_regExp;
-#endif
+        
+        OwnPtr<RegExpRepresentation> m_representation;
     };
 
 } // namespace JSC
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index d79024f..bf4bc88 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-09-07  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Oliver Hunt.
+
+        pushState and replaceState do not clone RegExp objects correctly
+        https://bugs.webkit.org/show_bug.cgi?id=44718
+        
+        Make RegExp test of pushstate-object-types.html actually test a RegExp
+        value with flags.
+        
+        Also adds ImageData since it can be serialized as of r54646.        
+
+        * fast/loader/stateobjects/pushstate-object-types-expected.txt:
+        * fast/loader/stateobjects/pushstate-object-types.html:
+
 2010-09-07  Kenneth Russell  <kbr at google.com>
 
         Reviewed by James Robinson.
diff --git a/LayoutTests/fast/loader/stateobjects/pushstate-object-types-expected.txt b/LayoutTests/fast/loader/stateobjects/pushstate-object-types-expected.txt
index 910b795..e1f57db 100644
--- a/LayoutTests/fast/loader/stateobjects/pushstate-object-types-expected.txt
+++ b/LayoutTests/fast/loader/stateobjects/pushstate-object-types-expected.txt
@@ -1,9 +1,10 @@
 This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the events contain the expected objects when the states are popped.
 
+State popped - [object ImageData] (type object)
 State popped - [object Object] (type object)
 State popped - [object Object] (type object)
 State popped -  (type object)
-State popped - null (type object)
+State popped - /foo/gi (type function)
 State popped - 0 (type object)
 State popped - String (type string)
 State popped - 42 (type number)
diff --git a/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html b/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html
index 0989114..5a28439 100644
--- a/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html
+++ b/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html
@@ -24,13 +24,13 @@ function runTest()
     history.pushState(42, "Number entry");
     history.pushState("String", "String entry");
     history.pushState(new Date(0), "Date entry");
-    history.pushState(new RegExp, "RegExp entry");
+    history.pushState(new RegExp("foo", "gi"), "RegExp entry");
     history.pushState(new Array, "Array entry");
     history.pushState(new Object, "Object entry");
     history.pushState(new Error, "Error entry");
+    history.pushState(document.createElement("canvas").getContext("2d").createImageData(10,10), "ImageData entry");
 
 /* The following are not yet well enough supported in WebKit to meaningfully test here:
-history.pushState([ImageData], "ImageData entry");
 history.pushState([Blob], "Blob entry");
 history.pushState([File], "File entry");
 history.pushState([FileList], "FileList entry");
@@ -53,7 +53,7 @@ onpopstate = function(event)
     }
     
     if (event.state instanceof Date)
-        log("State popped - " + event.state.getTime()  + " (type " + typeof event.state + ")");
+        log("State popped - " + event.state.getTime() + " (type " + typeof event.state + ")");
     else
         log("State popped - " + event.state + " (type " + typeof event.state + ")");
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 257a4b1..f8807ee 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-09-07  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Oliver Hunt.
+
+        pushState and replaceState do not clone RegExp objects correctly
+        https://bugs.webkit.org/show_bug.cgi?id=44718
+        
+        Add RegExp support to the JSC implementation of SerializedScriptValue
+        (it stores the pattern and flags read from a RegExpObject, and creates
+        a new one on deserialization).
+        
+        Tests: fast/loader/stateobjects/pushstate-object-types.html 
+
+        * ForwardingHeaders/runtime/RegExp.h: Added.
+        * ForwardingHeaders/runtime/RegExpObject.h: Added.
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneSerializer::dumpIfTerminal):
+        (WebCore::CloneDeserializer::readTerminal):
+
 2010-09-07  James Robinson  <jamesr at chromium.org>
 
         Reviewed by Kenneth Russell.
diff --git a/WebCore/ForwardingHeaders/runtime/RegExp.h b/WebCore/ForwardingHeaders/runtime/RegExp.h
new file mode 100644
index 0000000..b6e8894
--- /dev/null
+++ b/WebCore/ForwardingHeaders/runtime/RegExp.h
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_RegExp_h
+#define WebCore_FWD_RegExp_h
+#include <JavaScriptCore/RegExp.h>
+#endif
diff --git a/WebCore/ForwardingHeaders/runtime/RegExpObject.h b/WebCore/ForwardingHeaders/runtime/RegExpObject.h
new file mode 100644
index 0000000..b3f2516
--- /dev/null
+++ b/WebCore/ForwardingHeaders/runtime/RegExpObject.h
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_RegExpObject_h
+#define WebCore_FWD_RegExpObject_h
+#include <JavaScriptCore/RegExpObject.h>
+#endif
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index 92c8936..f229088 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -44,6 +44,8 @@
 #include <runtime/ExceptionHelpers.h>
 #include <runtime/JSLock.h>
 #include <runtime/PropertyNameArray.h>
+#include <runtime/RegExp.h>
+#include <runtime/RegExpObject.h>
 #include <wtf/ByteArray.h>
 #include <wtf/HashTraits.h>
 #include <wtf/Vector.h>
@@ -83,6 +85,7 @@ enum SerializationTag {
     BlobTag = 15,
     StringTag = 16,
     EmptyStringTag = 17,
+    RegExpTag = 18,
     ErrorTag = 255
 };
 
@@ -145,6 +148,8 @@ static const unsigned int StringPoolTag = 0xFFFFFFFE;
  * Blob :-
  *    BlobTag <url:StringData><type:StringData><size:long long>
  *
+ * RegExp :-
+ *    RegExpTag <pattern:StringData><flags:StringData>
  */
 
 class CloneBase {
@@ -389,6 +394,21 @@ private:
                 write(data->data()->data()->data(), data->data()->length());
                 return true;
             }
+            if (obj->inherits(&RegExpObject::info)) {
+                RegExpObject* regExp = asRegExpObject(obj);
+                char flags[3];
+                int flagCount = 0;
+                if (regExp->regExp()->global())
+                    flags[flagCount++] = 'g';
+                if (regExp->regExp()->ignoreCase())
+                    flags[flagCount++] = 'i';
+                if (regExp->regExp()->multiline())
+                    flags[flagCount++] = 'm';
+                write(RegExpTag);
+                write(regExp->regExp()->pattern());
+                write(UString(flags, flagCount));
+                return true;
+            }
 
             CallData unusedData;
             if (getCallData(value, unusedData) == CallTypeNone)
@@ -1066,6 +1086,16 @@ private:
         }
         case EmptyStringTag:
             return jsEmptyString(&m_exec->globalData());
+        case RegExpTag: {
+            Identifier pattern;
+            if (!readStringData(pattern))
+                return JSValue();
+            Identifier flags;
+            if (!readStringData(flags))
+                return JSValue();
+            RefPtr<RegExp> regExp = RegExp::create(&m_exec->globalData(), pattern.ustring(), flags.ustring());
+            return new (m_exec) RegExpObject(m_exec->lexicalGlobalObject(), m_globalObject->regExpStructure(), regExp); 
+        }
         default:
             m_ptr--; // Push the tag back
             return JSValue();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list