[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:38:44 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 744d028c5ec1c5109bf54a7fb3e6b0269fce27a0
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Oct 4 17:12:37 2009 +0000

    2009-10-04  Vitaly Repeshko  <vitalyr at chromium.org>
    
            Reviewed by Adam Barth.
    
            [V8] Fixed Function leak in V8LazyEventListener.
            (Should fix the remaning leak in
            https://bugs.webkit.org/show_bug.cgi?id=29093).
            V8LazyEventListeners used to create FunctionTemplates for each
            wrapped listener which in turn created Functions that were cached
            forever in V8 Context. Now there is at most one such Function per
            Context.
            https://bugs.webkit.org/show_bug.cgi?id=30060
    
            Added new hidden property name to store toString result:
            * bindings/v8/V8HiddenPropertyName.cpp:
            * bindings/v8/V8HiddenPropertyName.h:
    
            Switched to static FunctionTemplate:
            * bindings/v8/V8LazyEventListener.cpp:
            (WebCore::V8LazyEventListenerToString):
            (WebCore::V8LazyEventListener::prepareListenerObject):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49074 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ce9f76f..55205e6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2009-10-04  Vitaly Repeshko  <vitalyr at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        [V8] Fixed Function leak in V8LazyEventListener.
+        (Should fix the remaning leak in
+        https://bugs.webkit.org/show_bug.cgi?id=29093).
+        V8LazyEventListeners used to create FunctionTemplates for each
+        wrapped listener which in turn created Functions that were cached
+        forever in V8 Context. Now there is at most one such Function per
+        Context.
+        https://bugs.webkit.org/show_bug.cgi?id=30060
+
+        Added new hidden property name to store toString result:
+        * bindings/v8/V8HiddenPropertyName.cpp:
+        * bindings/v8/V8HiddenPropertyName.h:
+
+        Switched to static FunctionTemplate:
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListenerToString):
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+
 2009-10-03  Joseph Pecoraro  <joepeck at webkit.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/bindings/v8/V8HiddenPropertyName.cpp b/WebCore/bindings/v8/V8HiddenPropertyName.cpp
index 7ea2a4c..d83573f 100644
--- a/WebCore/bindings/v8/V8HiddenPropertyName.cpp
+++ b/WebCore/bindings/v8/V8HiddenPropertyName.cpp
@@ -33,29 +33,17 @@
 
 namespace WebCore {
 
-v8::Handle<v8::String> V8HiddenPropertyName::objectPrototype()
-{
-    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::objectPrototype");
-    return *string;
+#define V8_AS_STRING(x) V8_AS_STRING_IMPL(x)
+#define V8_AS_STRING_IMPL(x) #x
+
+#define V8_DEFINE_PROPERTY(name) \
+v8::Handle<v8::String> V8HiddenPropertyName::name() \
+{ \
+    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::" V8_AS_STRING(name)); \
+    return *string; \
 }
 
-v8::Handle<v8::String> V8HiddenPropertyName::isolatedWorld()
-{
-    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::isolatedWorld");
-    return *string;
-}
-
-v8::Handle<v8::String> V8HiddenPropertyName::listener()
-{
-    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::listener");
-    return *string;
-}
-
-v8::Handle<v8::String> V8HiddenPropertyName::attributeListener()
-{
-    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::attributeListener");
-    return *string;
-}
+V8_HIDDEN_PROPERTIES(V8_DEFINE_PROPERTY);
 
 v8::Persistent<v8::String>* V8HiddenPropertyName::createString(const char* key)
 {
diff --git a/WebCore/bindings/v8/V8HiddenPropertyName.h b/WebCore/bindings/v8/V8HiddenPropertyName.h
index dbe992f..58c01eb 100644
--- a/WebCore/bindings/v8/V8HiddenPropertyName.h
+++ b/WebCore/bindings/v8/V8HiddenPropertyName.h
@@ -35,12 +35,18 @@
 
 namespace WebCore {
 
+#define V8_HIDDEN_PROPERTIES(V) \
+    V(objectPrototype) \
+    V(isolatedWorld) \
+    V(listener) \
+    V(attributeListener) \
+    V(toStringString)
+
     class V8HiddenPropertyName {
     public:
-        static v8::Handle<v8::String> objectPrototype();
-        static v8::Handle<v8::String> isolatedWorld();
-        static v8::Handle<v8::String> listener();
-        static v8::Handle<v8::String> attributeListener();
+#define V8_DECLARE_PROPERTY(name) static v8::Handle<v8::String> name();
+        V8_HIDDEN_PROPERTIES(V8_DECLARE_PROPERTY);
+#undef V8_DECLARE_PROPERTY
 
     private:
         static v8::Persistent<v8::String>* createString(const char* key);
diff --git a/WebCore/bindings/v8/V8LazyEventListener.cpp b/WebCore/bindings/v8/V8LazyEventListener.cpp
index 120957a..9b58571 100644
--- a/WebCore/bindings/v8/V8LazyEventListener.cpp
+++ b/WebCore/bindings/v8/V8LazyEventListener.cpp
@@ -33,8 +33,11 @@
 
 #include "Frame.h"
 #include "V8Binding.h"
+#include "V8HiddenPropertyName.h"
 #include "V8Proxy.h"
 
+#include <wtf/StdLibExtras.h>
+
 namespace WebCore {
 
 V8LazyEventListener::V8LazyEventListener(Frame* frame, const String& code, const String& functionName, bool isSVGEvent)
@@ -60,7 +63,7 @@ v8::Local<v8::Value> V8LazyEventListener::callListenerFunction(v8::Handle<v8::Va
 
 static v8::Handle<v8::Value> V8LazyEventListenerToString(const v8::Arguments& args)
 {
-    return args.Callee()->GetHiddenValue(v8::String::New("toStringString"));
+    return args.Holder()->GetHiddenValue(V8HiddenPropertyName::toStringString());
 }
 
 void V8LazyEventListener::prepareListenerObject()
@@ -108,11 +111,17 @@ void V8LazyEventListener::prepareListenerObject()
 
             v8::Local<v8::Function> wrappedFunction = v8::Local<v8::Function>::Cast(value);
 
-            // Change the toString function on the wrapper function to avoid it returning the source for the actual wrapper function. Instead
-            // it returns source for a clean wrapper function with the event argument wrapping the event source code. The reason for this
-            // is that some web sites uses toString on event functions and the evals the source returned (some times a RegExp is applied as
-            // well) for some other use. That fails miserably if the actual wrapper source is returned.
-            v8::Local<v8::FunctionTemplate> toStringTemplate = v8::FunctionTemplate::New(V8LazyEventListenerToString);
+            // Change the toString function on the wrapper function to avoid it
+            // returning the source for the actual wrapper function. Instead it
+            // returns source for a clean wrapper function with the event
+            // argument wrapping the event source code. The reason for this is
+            // that some web sites use toString on event functions and eval the
+            // source returned (sometimes a RegExp is applied as well) for some
+            // other use. That fails miserably if the actual wrapper source is
+            // returned.
+            DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, toStringTemplate, ());
+            if (toStringTemplate.IsEmpty())
+                toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(V8LazyEventListenerToString));
             v8::Local<v8::Function> toStringFunction;
             if (!toStringTemplate.IsEmpty())
                 toStringFunction = toStringTemplate->GetFunction();
@@ -120,14 +129,11 @@ void V8LazyEventListener::prepareListenerObject()
                 String toStringResult = "function ";
                 toStringResult.append(m_functionName);
                 toStringResult.append("(");
-                if (m_isSVGEvent)
-                    toStringResult.append("evt");
-                else
-                    toStringResult.append("event");
+                toStringResult.append(m_isSVGEvent ? "evt" : "event");
                 toStringResult.append(") {\n  ");
                 toStringResult.append(m_code);
                 toStringResult.append("\n}");
-                toStringFunction->SetHiddenValue(v8::String::New("toStringString"), v8ExternalString(toStringResult));
+                wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8ExternalString(toStringResult));
                 wrappedFunction->Set(v8::String::New("toString"), toStringFunction);
             }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list