Title: [133194] trunk/Source/WebCore
Revision
133194
Author
aba...@webkit.org
Date
2012-11-01 10:48:32 -0700 (Thu, 01 Nov 2012)

Log Message

[V8] The DOMWrapperVisitor abstraction is no longer needed
https://bugs.webkit.org/show_bug.cgi?id=100965

Reviewed by Kentaro Hara.

This patch removes the DOMWrapperVisitor interface because it is no
longer needed. As a consequence, DOMWrapperMaps no longer need to
support enumeration, and we can move more DOM objects to use the faster
intrusive wrappers.

There was one remaining user of DOMWrapperVisitor in the
ScriptProfiler, which I've moved over to enumerating objects directly
from V8, similar to a function above it in the same file.

* bindings/v8/DOMWrapperMap.h:
(WebCore):
(DOMWrapperMap):
* bindings/v8/IntrusiveDOMWrapperMap.h:
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::visitNodeWrappers):
(WebCore::ScriptProfiler::visitExternalArrays):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133193 => 133194)


--- trunk/Source/WebCore/ChangeLog	2012-11-01 17:46:28 UTC (rev 133193)
+++ trunk/Source/WebCore/ChangeLog	2012-11-01 17:48:32 UTC (rev 133194)
@@ -1,3 +1,27 @@
+2012-11-01  Adam Barth  <aba...@webkit.org>
+
+        [V8] The DOMWrapperVisitor abstraction is no longer needed
+        https://bugs.webkit.org/show_bug.cgi?id=100965
+
+        Reviewed by Kentaro Hara.
+
+        This patch removes the DOMWrapperVisitor interface because it is no
+        longer needed. As a consequence, DOMWrapperMaps no longer need to
+        support enumeration, and we can move more DOM objects to use the faster
+        intrusive wrappers.
+
+        There was one remaining user of DOMWrapperVisitor in the
+        ScriptProfiler, which I've moved over to enumerating objects directly
+        from V8, similar to a function above it in the same file.
+
+        * bindings/v8/DOMWrapperMap.h:
+        (WebCore):
+        (DOMWrapperMap):
+        * bindings/v8/IntrusiveDOMWrapperMap.h:
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::visitNodeWrappers):
+        (WebCore::ScriptProfiler::visitExternalArrays):
+
 2012-11-01  Mike West  <mk...@chromium.org>
 
         CSP 1.0: Warn when old-style directives encountered.

Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperMap.h (133193 => 133194)


--- trunk/Source/WebCore/bindings/v8/DOMWrapperMap.h	2012-11-01 17:46:28 UTC (rev 133193)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperMap.h	2012-11-01 17:48:32 UTC (rev 133194)
@@ -42,20 +42,12 @@
 class DOMDataStore;
 
 template<class KeyType>
-class DOMWrapperVisitor {
-public:
-    virtual void visitDOMWrapper(DOMDataStore*, KeyType*, v8::Persistent<v8::Object> wrapper) = 0;
-    virtual ~DOMWrapperVisitor() { }
-};
-
-template<class KeyType>
 class DOMWrapperMap {
 public:
     virtual ~DOMWrapperMap() { }
 
     virtual v8::Persistent<v8::Object> get(KeyType*) = 0;
     virtual void set(KeyType*, v8::Persistent<v8::Object>) = 0;
-    virtual void visit(DOMDataStore*, DOMWrapperVisitor<KeyType>*) = 0;
     virtual void clear() = 0;
 
     virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
@@ -84,12 +76,6 @@
         m_map.set(key, wrapper);
     }
 
-    virtual void visit(DOMDataStore* store, DOMWrapperVisitor<KeyType>* visitor) OVERRIDE
-    {
-        for (typename MapType::iterator it = m_map.begin(); it != m_map.end(); ++it)
-            visitor->visitDOMWrapper(store, it->key, it->value);
-    }
-
     virtual void clear() OVERRIDE
     {
         for (typename MapType::iterator it = m_map.begin(); it != m_map.end(); ++it) {

Modified: trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h (133193 => 133194)


--- trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-11-01 17:46:28 UTC (rev 133193)
+++ trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-11-01 17:48:32 UTC (rev 133194)
@@ -50,11 +50,6 @@
         wrapper.MakeWeak(node, weakCallback);
     }
 
-    virtual void visit(DOMDataStore* store, DOMWrapperVisitor<Node>* visitor) OVERRIDE
-    {
-        ASSERT_NOT_REACHED();
-    }
-
     virtual void clear() OVERRIDE
     {
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (133193 => 133194)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-11-01 17:46:28 UTC (rev 133193)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-11-01 17:48:32 UTC (rev 133194)
@@ -181,14 +181,14 @@
 {
     v8::HandleScope scope;
 
-    class VisitorAdapter : public v8::PersistentHandleVisitor {
+    class DOMNodeWrapperVisitor : public v8::PersistentHandleVisitor {
     public:
-        explicit VisitorAdapter(WrappedNodeVisitor* visitor)
+        explicit DOMNodeWrapperVisitor(WrappedNodeVisitor* visitor)
             : m_visitor(visitor)
         {
         }
 
-        virtual void VisitPersistentHandle(v8::Persistent<v8::Value> value, uint16_t classId)
+        virtual void VisitPersistentHandle(v8::Persistent<v8::Value> value, uint16_t classId) OVERRIDE
         {
             if (classId != v8DOMNodeClassId)
                 return;
@@ -200,9 +200,9 @@
 
     private:
         WrappedNodeVisitor* m_visitor;
-    } visitorAdapter(visitor);
+    } wrapperVisitor(visitor);
 
-    v8::V8::VisitHandlesWithClassIds(&visitorAdapter);
+    v8::V8::VisitHandlesWithClassIds(&wrapperVisitor);
 }
 
 void ScriptProfiler::visitExternalStrings(ExternalStringVisitor* visitor)
@@ -212,24 +212,29 @@
 
 void ScriptProfiler::visitExternalArrays(ExternalArrayVisitor* visitor)
 {
-    class VisitorAdapter : public DOMWrapperVisitor<void> {
+    class DOMObjectWrapperVisitor : public v8::PersistentHandleVisitor {
     public:
-        VisitorAdapter(ExternalArrayVisitor* visitor) : m_visitor(visitor) { }
+        explicit DOMObjectWrapperVisitor(ExternalArrayVisitor* visitor)
+            : m_visitor(visitor)
+        {
+        }
 
-        virtual void visitDOMWrapper(DOMDataStore*, void* impl, v8::Persistent<v8::Object> v8Object)
+        virtual void VisitPersistentHandle(v8::Persistent<v8::Value> value, uint16_t classId) OVERRIDE
         {
-            WrapperTypeInfo* type = V8DOMWrapper::domWrapperType(v8Object);
-            if (!type->isSubclass(&V8ArrayBufferView::info))
+            if (classId != v8DOMObjectClassId)
                 return;
-            ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8Object);
-            m_visitor->visitJSExternalArray(arrayBufferView);
+            ASSERT(value->IsObject());
+            v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::Cast(value);
+            if (!V8DOMWrapper::domWrapperType(wrapper)->isSubclass(&V8ArrayBufferView::info))
+                return;
+            m_visitor->visitJSExternalArray(V8ArrayBufferView::toNative(wrapper));
         }
+
     private:
         ExternalArrayVisitor* m_visitor;
-    } adapter(visitor);
+    } wrapperVisitor(visitor);
 
-    getDOMObjectMap().visit(0, &adapter);
-
+    v8::V8::VisitHandlesWithClassIds(&wrapperVisitor);
 }
 
 void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to