[V8] We can merge the wrapper maps for DOM objects and active DOM objects
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 04:58:41 +0000 (04:58 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 04:58:41 +0000 (04:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100432

Reviewed by Eric Seidel.

Now that we use the same object to visit both DOM objects and active
DOM objects, there's no reason to keep them in separate hash maps.

* bindings/scripts/CodeGeneratorV8.pm:
(GetDomMapName):
* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::DOMDataStore):
(WebCore::DOMDataStore::~DOMDataStore):
(WebCore::DOMDataStore::reportMemoryUsage):
* bindings/v8/DOMDataStore.h:
(DOMDataStore):
* bindings/v8/V8DOMMap.cpp:
* bindings/v8/V8DOMMap.h:
(NodeWrapperVisitor):
(WebCore):
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper):
* bindings/v8/V8GCController.cpp:
(WebCore::V8GCController::majorGCPrologue):
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback):
* bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
(WebCore::V8XMLHttpRequest::constructorCallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132570 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/v8/DOMDataStore.cpp
Source/WebCore/bindings/v8/DOMDataStore.h
Source/WebCore/bindings/v8/V8DOMMap.cpp
Source/WebCore/bindings/v8/V8DOMMap.h
Source/WebCore/bindings/v8/V8DOMWrapper.h
Source/WebCore/bindings/v8/V8GCController.cpp
Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp
Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp

index c331a7f..09e3046 100644 (file)
@@ -1,3 +1,34 @@
+2012-10-25  Adam Barth  <abarth@webkit.org>
+
+        [V8] We can merge the wrapper maps for DOM objects and active DOM objects
+        https://bugs.webkit.org/show_bug.cgi?id=100432
+
+        Reviewed by Eric Seidel.
+
+        Now that we use the same object to visit both DOM objects and active
+        DOM objects, there's no reason to keep them in separate hash maps.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GetDomMapName):
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::DOMDataStore):
+        (WebCore::DOMDataStore::~DOMDataStore):
+        (WebCore::DOMDataStore::reportMemoryUsage):
+        * bindings/v8/DOMDataStore.h:
+        (DOMDataStore):
+        * bindings/v8/V8DOMMap.cpp:
+        * bindings/v8/V8DOMMap.h:
+        (NodeWrapperVisitor):
+        (WebCore):
+        * bindings/v8/V8DOMWrapper.h:
+        (V8DOMWrapper):
+        * bindings/v8/V8GCController.cpp:
+        (WebCore::V8GCController::majorGCPrologue):
+        * bindings/v8/custom/V8WebSocketCustom.cpp:
+        (WebCore::V8WebSocket::constructorCallback):
+        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+        (WebCore::V8XMLHttpRequest::constructorCallback):
+
 2012-10-25  Charles Wei  <charles.wei@torchmobile.com.cn>
 
         [BlackBerry] User Challenged again after browser restart for HTTP/FTP sites already successfully authenticated.
index 5340cb4..dfd44cd 100644 (file)
@@ -3481,7 +3481,6 @@ sub GetDomMapName
     my $type = shift;
 
     return "DOMNode" if IsNodeSubType($dataNode);
-    return "ActiveDOMObject" if $dataNode->extendedAttributes->{"ActiveDOMObject"};
     return "DOMObject";
 }
 
index 248471c..a2259b0 100644 (file)
@@ -52,7 +52,6 @@ DOMDataStore::DOMDataStore(Type type)
         m_domNodeMap = adoptPtr(new DOMWrapperHashMap<Node>);
     }
     m_domObjectMap = adoptPtr(new DOMWrapperHashMap<void>);
-    m_activeDomObjectMap = adoptPtr(new DOMWrapperHashMap<void>);
 
     V8PerIsolateData::current()->registerDOMDataStore(this);
 }
@@ -66,7 +65,6 @@ DOMDataStore::~DOMDataStore()
     if (m_type == IsolatedWorld)
         m_domNodeMap->clear();
     m_domObjectMap->clear();
-    m_activeDomObjectMap->clear();
 }
 
 DOMDataStore* DOMDataStore::current(v8::Isolate* isolate)
@@ -86,7 +84,6 @@ void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);
     info.addMember(m_domNodeMap);
     info.addMember(m_domObjectMap);
-    info.addMember(m_activeDomObjectMap);
 }
 
 } // namespace WebCore
index f8c0614..f0cc708 100644 (file)
@@ -61,7 +61,6 @@ public:
 
     DOMWrapperMap<Node>& domNodeMap() { return *m_domNodeMap; }
     DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; }
-    DOMWrapperMap<void>& activeDomObjectMap() { return *m_activeDomObjectMap; }
 
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
@@ -69,7 +68,6 @@ protected:
     Type m_type;
     OwnPtr<DOMWrapperMap<Node> > m_domNodeMap;
     OwnPtr<DOMWrapperMap<void> > m_domObjectMap;
-    OwnPtr<DOMWrapperMap<void> > m_activeDomObjectMap;
 };
 
 } // namespace WebCore
index c6757da..f661dd9 100644 (file)
@@ -56,13 +56,6 @@ DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* isolate)
     return DOMDataStore::current(isolate)->domObjectMap();
 }
 
-DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* isolate)
-{
-    if (!isolate)
-        isolate = v8::Isolate::GetCurrent();
-    return DOMDataStore::current(isolate)->activeDomObjectMap();
-}
-
 void visitAllDOMNodes(NodeWrapperVisitor* visitor)
 {
     v8::HandleScope scope;
@@ -104,16 +97,4 @@ void visitDOMObjects(DOMWrapperVisitor<void>* visitor)
     }
 }
 
-void visitActiveDOMObjects(DOMWrapperVisitor<void>* visitor)
-{
-    v8::HandleScope scope;
-
-    Vector<DOMDataStore*>& list = V8PerIsolateData::current()->allStores();
-    for (size_t i = 0; i < list.size(); ++i) {
-        DOMDataStore* store = list[i];
-
-        store->activeDomObjectMap().visit(store, visitor);
-    }
-}
-
 } // namespace WebCore
index 7d231c4..6c2d933 100644 (file)
 
 namespace WebCore {
 
-    DOMWrapperMap<Node>& getDOMNodeMap(v8::Isolate* = 0);
+class NodeWrapperVisitor {
+public:
+    virtual ~NodeWrapperVisitor();
+    virtual void visitNodeWrapper(Node*, v8::Persistent<v8::Object> wrapper) = 0;
+};
 
-    class NodeWrapperVisitor {
-    public:
-        virtual ~NodeWrapperVisitor();
-        virtual void visitNodeWrapper(Node*, v8::Persistent<v8::Object> wrapper) = 0;
-    };
-    void visitAllDOMNodes(NodeWrapperVisitor*);
+DOMWrapperMap<Node>& getDOMNodeMap(v8::Isolate* = 0);
+void visitAllDOMNodes(NodeWrapperVisitor*);
 
-    // A map from a DOM object (non-node) to its JS wrapper. This map does not contain the DOM objects which can have pending activity (active dom objects).
-    DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* = 0);
-    void visitDOMObjects(DOMWrapperVisitor<void>*);
-
-    // A map from a DOM object to its JS wrapper for DOM objects which can have pending activity.
-    DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* = 0);
-    void visitActiveDOMObjects(DOMWrapperVisitor<void>*);
+DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* = 0);
+void visitDOMObjects(DOMWrapperVisitor<void>*);
 
 } // namespace WebCore
 
index 721be1a..cb5bc2b 100644 (file)
@@ -96,8 +96,6 @@ namespace WebCore {
 
         template<typename T>
         static v8::Persistent<v8::Object> setJSWrapperForDOMObject(PassRefPtr<T>, v8::Handle<v8::Object>, v8::Isolate* = 0);
-        template<typename T>
-        static v8::Persistent<v8::Object> setJSWrapperForActiveDOMObject(PassRefPtr<T>, v8::Handle<v8::Object>, v8::Isolate* = 0);
         static v8::Persistent<v8::Object> setJSWrapperForDOMNode(PassRefPtr<Node>, v8::Handle<v8::Object>, v8::Isolate* = 0);
 
         static bool isValidDOMObject(v8::Handle<v8::Value>);
@@ -138,15 +136,6 @@ namespace WebCore {
         return wrapperHandle;
     }
 
-    template<typename T>
-    v8::Persistent<v8::Object> V8DOMWrapper::setJSWrapperForActiveDOMObject(PassRefPtr<T> object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate)
-    {
-        v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
-        ASSERT(maybeDOMWrapper(wrapperHandle));
-        ASSERT(domWrapperType(wrapperHandle)->toActiveDOMObjectFunction);
-        getActiveDOMObjectMap(isolate).set(object.leakRef(), wrapperHandle);
-        return wrapperHandle;
-    }
 }
 
 #endif // V8DOMWrapper_h
index 6e77907..f56cca3 100644 (file)
@@ -233,7 +233,6 @@ void V8GCController::majorGCPrologue()
 
     ObjectVisitor objectVisitor(&liveObjects);
     visitDOMObjects(&objectVisitor);
-    visitActiveDOMObjects(&objectVisitor);
 
     v8::V8::AddObjectGroup(liveObjects.data(), liveObjects.size());
 
index 900a562..a5de9a4 100644 (file)
@@ -105,7 +105,7 @@ v8::Handle<v8::Value> V8WebSocket::constructorCallback(const v8::Arguments& args
 
     v8::Handle<v8::Object> wrapper = args.Holder();
     V8DOMWrapper::setDOMWrapper(wrapper, &info, webSocket.get());
-    V8DOMWrapper::setJSWrapperForActiveDOMObject(webSocket.release(), wrapper);
+    V8DOMWrapper::setJSWrapperForDOMObject(webSocket.release(), wrapper);
     return wrapper;
 }
 
index 6f3d6ee..0786a18 100644 (file)
@@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::constructorCallback(const v8::Arguments&
 
     v8::Handle<v8::Object> wrapper = args.Holder();
     V8DOMWrapper::setDOMWrapper(wrapper, &info, xmlHttpRequest.get());
-    V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.release(), wrapper);
+    V8DOMWrapper::setJSWrapperForDOMObject(xmlHttpRequest.release(), wrapper);
     return wrapper;
 }