2010-02-04 Anton Muhin <antonm@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Feb 2010 12:57:15 +0000 (12:57 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Feb 2010 12:57:15 +0000 (12:57 +0000)
        Reviewed by Adam Barth.

        [v8] Remove clear method from DOM object maps
        https://bugs.webkit.org/show_bug.cgi?id=34530

        No new tests. Should be covered by existent testing infrastructure.

        * bindings/v8/DOMData.h:
        * bindings/v8/DOMDataStore.h:
        * bindings/v8/V8DOMMap.cpp:
        * bindings/v8/V8DOMMap.h:
        * bindings/v8/WorkerScriptController.cpp:
        (WebCore::WorkerScriptController::~WorkerScriptController):

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

WebCore/ChangeLog
WebCore/bindings/v8/DOMData.h
WebCore/bindings/v8/DOMDataStore.h
WebCore/bindings/v8/V8DOMMap.cpp
WebCore/bindings/v8/V8DOMMap.h
WebCore/bindings/v8/WorkerScriptController.cpp

index db4c515..c6fd172 100644 (file)
@@ -1,3 +1,19 @@
+2010-02-04  Anton Muhin  <antonm@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        [v8] Remove clear method from DOM object maps
+        https://bugs.webkit.org/show_bug.cgi?id=34530
+
+        No new tests. Should be covered by existent testing infrastructure.
+
+        * bindings/v8/DOMData.h:
+        * bindings/v8/DOMDataStore.h:
+        * bindings/v8/V8DOMMap.cpp:
+        * bindings/v8/V8DOMMap.h:
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::~WorkerScriptController):
+
 2010-02-04  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Reviewed by Xan Lopez.
index 7fa9e7d..6aee519 100644 (file)
@@ -112,14 +112,6 @@ namespace WebCore {
         }
     }
 
-    template<typename T>
-    void DOMData::removeObjectsFromWrapperMap(AbstractWeakReferenceMap<T, v8::Object>& domMap)
-    {
-        WrapperMapObjectRemover<T> remover;
-        domMap.visit(&remover);
-        domMap.clear();
-    }
-
 } // namespace WebCore
 
 #endif // DOMData_h
index 54a49e7..f175fbf 100644 (file)
@@ -84,27 +84,6 @@ namespace WebCore {
             ASSERT(!m_chunks || ((m_chunks->m_entries < m_current) && (m_current <= m_last)));
         }
 
-        void clear()
-        {
-            if (!m_chunks)
-                return;
-
-            clearEntries(m_chunks->m_entries, m_current);
-            Chunk* last = m_chunks;
-            while (true) {
-                Chunk* previous = last->m_previous;
-                if (!previous)
-                    break;
-                delete last;
-                clearEntries(previous->m_entries, previous->m_entries + CHUNK_SIZE);
-                last = previous;
-            }
-
-            m_chunks = last;
-            m_current = m_chunks->m_entries;
-            m_last = m_current + CHUNK_SIZE;
-        }
-
         void visit(typename Traits::Visitor* visitor)
         {
             if (!m_chunks)
@@ -122,12 +101,6 @@ namespace WebCore {
             T m_entries[CHUNK_SIZE];
         };
 
-        static void clearEntries(T* first, T* last)
-        {
-            for (T* entry = first; entry < last; entry++)
-                Traits::clear(entry);
-        }
-
         static void visitEntries(T* first, T* last, typename Traits::Visitor* visitor)
         {
             for (T* entry = first; entry < last; entry++)
@@ -208,11 +181,6 @@ namespace WebCore {
 
             virtual bool removeIfPresent(Node* key, v8::Persistent<v8::Data> value);
 
-            virtual void clear()
-            {
-                m_table.clear();
-            }
-
         private:
             static int const numberOfEntries = (1 << 10) - 1;
 
@@ -227,15 +195,6 @@ namespace WebCore {
                     node->setWrapper(target);
                 }
 
-                static void clear(v8::Persistent<v8::Object>* entry)
-                {
-                    Node* node = V8Node::toNative(*entry);
-                    ASSERT(node->wrapper() == entry);
-
-                    node->clearWrapper();
-                    entry->Dispose();
-                }
-
                 static void visit(v8::Persistent<v8::Object>* entry, Visitor* visitor)
                 {
                     Node* node = V8Node::toNative(*entry);
index fa2fba3..81372fb 100644 (file)
@@ -95,45 +95,6 @@ DOMWrapperMap<void>& getDOMSVGObjectWithContextMap()
 
 #endif // ENABLE(SVG)
 
-static void removeAllDOMObjectsInCurrentThreadHelper()
-{
-    v8::HandleScope scope;
-
-    // Deref all objects in the delayed queue.
-    DOMData::getCurrent()->derefDelayedObjects();
-
-    // The DOM objects with the following types only exist on the main thread.
-    if (WTF::isMainThread()) {
-        // Remove all DOM nodes.
-        DOMData::removeObjectsFromWrapperMap<Node>(getDOMNodeMap());
-
-#if ENABLE(SVG)
-        // Remove all SVG element instances in the wrapper map.
-        DOMData::removeObjectsFromWrapperMap<SVGElementInstance>(getDOMSVGElementInstanceMap());
-
-        // Remove all SVG objects with context in the wrapper map.
-        DOMData::removeObjectsFromWrapperMap<void>(getDOMSVGObjectWithContextMap());
-#endif
-    }
-
-    // Remove all DOM objects in the wrapper map.
-    DOMData::removeObjectsFromWrapperMap<void>(getDOMObjectMap());
-
-    // Remove all active DOM objects in the wrapper map.
-    DOMData::removeObjectsFromWrapperMap<void>(getActiveDOMObjectMap());
-}
-
-void removeAllDOMObjectsInCurrentThread()
-{
-    // Use the locker only if it has already been invoked before, as by worker thread.
-    if (v8::Locker::IsActive()) {
-        v8::Locker locker;
-        removeAllDOMObjectsInCurrentThreadHelper();
-    } else
-        removeAllDOMObjectsInCurrentThreadHelper();
-}
-
-
 void visitDOMNodesInCurrentThread(DOMWrapperMap<Node>::Visitor* visitor)
 {
     v8::HandleScope scope;
index a7e03a0..6ecb488 100644 (file)
@@ -58,7 +58,6 @@ namespace WebCore {
         virtual bool contains(KeyType* obj) = 0;
         virtual void visit(Visitor* visitor) = 0;
         virtual bool removeIfPresent(KeyType* key, v8::Persistent<v8::Data> value) = 0;
-        virtual void clear() = 0;
 
         v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; }
     private:
@@ -119,11 +118,6 @@ namespace WebCore {
             return true;
         }
 
-        void clear()
-        {
-            m_map.clear();
-        }
-
         bool contains(KeyType* obj) { return m_map.contains(obj); }
 
         virtual void visit(typename Parent::Visitor* visitor)
@@ -170,9 +164,6 @@ namespace WebCore {
     DOMWrapperMap<void>& getActiveDOMObjectMap();
     void visitActiveDOMObjectsInCurrentThread(DOMWrapperMap<void>::Visitor*);
 
-    // This should be called to remove all DOM objects associated with the current thread when it is tearing down.
-    void removeAllDOMObjectsInCurrentThread();
-
 #if ENABLE(SVG)
     // A map for SVGElementInstances to its JS wrapper.
     DOMWrapperMap<SVGElementInstance>& getDOMSVGElementInstanceMap();
index f2311bf..d10705a 100644 (file)
@@ -57,7 +57,6 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
 
 WorkerScriptController::~WorkerScriptController()
 {
-    removeAllDOMObjectsInCurrentThread();
 }
 
 ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)