Title: [127978] trunk/Source/WebCore
Revision
127978
Author
[email protected]
Date
2012-09-09 00:39:13 -0700 (Sun, 09 Sep 2012)

Log Message

[V8] V8PerContextData holds m_context using a v8::Handle rather than a v8::Persistent
https://bugs.webkit.org/show_bug.cgi?id=96193

Reviewed by Kentaro Hara.

There are two types of handles in V8: Local and Persistent. We are now
permitted to keep Local handles in the heap because they get
deallocated when the C++ stack unwinds and v8::HandleScope objects are
destructed.

V8PerContextData holds its m_context using the non-specific v8::Handle
type. If we used a Local handle here, we'd have a memory safety
problem. Thankfully, we use a Persistent handle, which need to be
allocated and freed manually.

This patch makes the type of V8PerContextData::m_context more specific
to ensure that we never try to store a local handle in this variable.
This patch should not have any behavior change because we were already
storing a Persistent handle.

* bindings/v8/V8PerContextData.h:
(WebCore::V8PerContextData::create):
(WebCore::V8PerContextData::V8PerContextData):
(V8PerContextData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127977 => 127978)


--- trunk/Source/WebCore/ChangeLog	2012-09-09 07:27:40 UTC (rev 127977)
+++ trunk/Source/WebCore/ChangeLog	2012-09-09 07:39:13 UTC (rev 127978)
@@ -1,5 +1,32 @@
 2012-09-09  Adam Barth  <[email protected]>
 
+        [V8] V8PerContextData holds m_context using a v8::Handle rather than a v8::Persistent
+        https://bugs.webkit.org/show_bug.cgi?id=96193
+
+        Reviewed by Kentaro Hara.
+
+        There are two types of handles in V8: Local and Persistent. We are now
+        permitted to keep Local handles in the heap because they get
+        deallocated when the C++ stack unwinds and v8::HandleScope objects are
+        destructed.
+
+        V8PerContextData holds its m_context using the non-specific v8::Handle
+        type. If we used a Local handle here, we'd have a memory safety
+        problem. Thankfully, we use a Persistent handle, which need to be
+        allocated and freed manually.
+
+        This patch makes the type of V8PerContextData::m_context more specific
+        to ensure that we never try to store a local handle in this variable.
+        This patch should not have any behavior change because we were already
+        storing a Persistent handle.
+
+        * bindings/v8/V8PerContextData.h:
+        (WebCore::V8PerContextData::create):
+        (WebCore::V8PerContextData::V8PerContextData):
+        (V8PerContextData):
+
+2012-09-09  Adam Barth  <[email protected]>
+
         [V8] V8DOMWindowShell does not need to be RefCounted
         https://bugs.webkit.org/show_bug.cgi?id=96192
 

Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.h (127977 => 127978)


--- trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-09-09 07:27:40 UTC (rev 127977)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-09-09 07:39:13 UTC (rev 127978)
@@ -41,7 +41,7 @@
 
 class V8PerContextData {
 public:
-    static PassOwnPtr<V8PerContextData> create(v8::Handle<v8::Context> context)
+    static PassOwnPtr<V8PerContextData> create(v8::Persistent<v8::Context> context)
     {
         return adoptPtr(new V8PerContextData(context));
     }
@@ -73,7 +73,7 @@
     }
 
 private:
-    explicit V8PerContextData(v8::Handle<v8::Context> context)
+    explicit V8PerContextData(v8::Persistent<v8::Context> context)
         : m_context(context)
     {
     }
@@ -91,7 +91,7 @@
     typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Function> > ConstructorMap;
     ConstructorMap m_constructorMap;
 
-    v8::Handle<v8::Context> m_context;
+    v8::Persistent<v8::Context> m_context;
     ScopedPersistent<v8::Value> m_errorPrototype;
     ScopedPersistent<v8::Value> m_objectPrototype;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to