Title: [128127] trunk/Source/WebCore
Revision
128127
Author
[email protected]
Date
2012-09-10 16:23:36 -0700 (Mon, 10 Sep 2012)

Log Message

[V8] V8PerIsolateData::m_toStringTemplate leaks memory
https://bugs.webkit.org/show_bug.cgi?id=96322

Patch by Adam Barth <[email protected]> on 2012-09-10
Reviewed by Kentaro Hara.

We never call Dispose to balance the call to v8::Persistent::New. This
patch uses ScopedPersistent to call Dispose automatically.

* bindings/v8/V8PerIsolateData.cpp:
(WebCore::V8PerIsolateData::toStringTemplate):
    - I've changed this function to return a new local handle in case
      anyone is trying to hold on to these handles during shutdown.
* bindings/v8/V8PerIsolateData.h:
(V8PerIsolateData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128126 => 128127)


--- trunk/Source/WebCore/ChangeLog	2012-09-10 23:23:00 UTC (rev 128126)
+++ trunk/Source/WebCore/ChangeLog	2012-09-10 23:23:36 UTC (rev 128127)
@@ -1,5 +1,22 @@
 2012-09-10  Adam Barth  <[email protected]>
 
+        [V8] V8PerIsolateData::m_toStringTemplate leaks memory
+        https://bugs.webkit.org/show_bug.cgi?id=96322
+
+        Reviewed by Kentaro Hara.
+
+        We never call Dispose to balance the call to v8::Persistent::New. This
+        patch uses ScopedPersistent to call Dispose automatically.
+
+        * bindings/v8/V8PerIsolateData.cpp:
+        (WebCore::V8PerIsolateData::toStringTemplate):
+            - I've changed this function to return a new local handle in case
+              anyone is trying to hold on to these handles during shutdown.
+        * bindings/v8/V8PerIsolateData.h:
+        (V8PerIsolateData):
+
+2012-09-10  Adam Barth  <[email protected]>
+
         [V8] V8LazyEventListener::prepareListenerObject uses inefficient string operations
         https://bugs.webkit.org/show_bug.cgi?id=96324
 

Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp (128126 => 128127)


--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp	2012-09-10 23:23:00 UTC (rev 128126)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp	2012-09-10 23:23:36 UTC (rev 128127)
@@ -74,6 +74,13 @@
     isolate->SetData(0);
 }
 
+v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate()
+{
+    if (m_toStringTemplate.isEmpty())
+        m_toStringTemplate.set(v8::FunctionTemplate::New(constructorOfToString));
+    return v8::Local<v8::FunctionTemplate>::New(m_toStringTemplate.get());
+}
+
 void V8PerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);

Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h (128126 => 128127)


--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-09-10 23:23:00 UTC (rev 128126)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-09-10 23:23:36 UTC (rev 128127)
@@ -71,13 +71,7 @@
     TemplateMap& rawTemplateMap() { return m_rawTemplates; }
     TemplateMap& templateMap() { return m_templates; }
 
-    v8::Persistent<v8::FunctionTemplate>& toStringTemplate()
-    {
-        if (m_toStringTemplate.IsEmpty())
-            m_toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorOfToString));
-        return m_toStringTemplate;
-    }
-
+    v8::Handle<v8::FunctionTemplate> toStringTemplate();
     v8::Persistent<v8::FunctionTemplate>& lazyEventListenerToStringTemplate()
     {
         return m_lazyEventListenerToStringTemplate;
@@ -143,7 +137,7 @@
 
     TemplateMap m_rawTemplates;
     TemplateMap m_templates;
-    v8::Persistent<v8::FunctionTemplate> m_toStringTemplate;
+    ScopedPersistent<v8::FunctionTemplate> m_toStringTemplate;
     v8::Persistent<v8::FunctionTemplate> m_lazyEventListenerToStringTemplate;
     OwnPtr<StringCache> m_stringCache;
     OwnPtr<IntegerCache> m_integerCache;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to