Title: [132454] trunk/Source/WebCore
Revision
132454
Author
[email protected]
Date
2012-10-25 00:14:23 -0700 (Thu, 25 Oct 2012)

Log Message

[V8] We can merge DOMDataStore, ScopedDOMDataStore, and StaticDOMDataStore into one class
https://bugs.webkit.org/show_bug.cgi?id=100316

Reviewed by Eric Seidel.

Prior to this patch, DOMDataStore had two subclasses,
ScopedDOMDataStore and StaticDOMDataStore, which used slighly different
wrapper map base classes and had different lifetimes. This patch
unifies all these classes into DOMDataStore itself. This makes this
code much more straightforward.

* WebCore.gypi:
* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::DOMDataStore):
(WebCore::DOMDataStore::~DOMDataStore):
(WebCore::DOMDataStore::current):
(WebCore::DOMDataStore::reportMemoryUsage):
* bindings/v8/DOMDataStore.h:
(DOMDataStore):
(WebCore::DOMDataStore::domNodeMap):
(WebCore::DOMDataStore::activeDomNodeMap):
(WebCore::DOMDataStore::domObjectMap):
(WebCore::DOMDataStore::activeDomObjectMap):
* bindings/v8/ScopedDOMDataStore.cpp: Removed.
* bindings/v8/ScopedDOMDataStore.h: Removed.
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::neuterBinding):
* bindings/v8/StaticDOMDataStore.cpp: Removed.
* bindings/v8/StaticDOMDataStore.h: Removed.
* bindings/v8/V8DOMMap.cpp:
(WebCore::DOMDataStoreHandle::DOMDataStoreHandle):
(WebCore::DOMDataStoreHandle::~DOMDataStoreHandle):
(WebCore::visitActiveDOMNodes):
(WebCore::visitDOMObjects):
(WebCore::visitActiveDOMObjects):
* bindings/v8/V8DOMMap.h:
(WebCore):
* bindings/v8/V8PerIsolateData.h:
(V8PerIsolateData):
* bindings/v8/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::WorkerScriptController):
(WebCore::WorkerScriptController::~WorkerScriptController):
* bindings/v8/WorkerScriptController.h:
(WorkerScriptController):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132453 => 132454)


--- trunk/Source/WebCore/ChangeLog	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/ChangeLog	2012-10-25 07:14:23 UTC (rev 132454)
@@ -1,3 +1,50 @@
+2012-10-25  Adam Barth  <[email protected]>
+
+        [V8] We can merge DOMDataStore, ScopedDOMDataStore, and StaticDOMDataStore into one class
+        https://bugs.webkit.org/show_bug.cgi?id=100316
+
+        Reviewed by Eric Seidel.
+
+        Prior to this patch, DOMDataStore had two subclasses,
+        ScopedDOMDataStore and StaticDOMDataStore, which used slighly different
+        wrapper map base classes and had different lifetimes. This patch
+        unifies all these classes into DOMDataStore itself. This makes this
+        code much more straightforward.
+
+        * WebCore.gypi:
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::DOMDataStore):
+        (WebCore::DOMDataStore::~DOMDataStore):
+        (WebCore::DOMDataStore::current):
+        (WebCore::DOMDataStore::reportMemoryUsage):
+        * bindings/v8/DOMDataStore.h:
+        (DOMDataStore):
+        (WebCore::DOMDataStore::domNodeMap):
+        (WebCore::DOMDataStore::activeDomNodeMap):
+        (WebCore::DOMDataStore::domObjectMap):
+        (WebCore::DOMDataStore::activeDomObjectMap):
+        * bindings/v8/ScopedDOMDataStore.cpp: Removed.
+        * bindings/v8/ScopedDOMDataStore.h: Removed.
+        * bindings/v8/SerializedScriptValue.cpp:
+        (WebCore::neuterBinding):
+        * bindings/v8/StaticDOMDataStore.cpp: Removed.
+        * bindings/v8/StaticDOMDataStore.h: Removed.
+        * bindings/v8/V8DOMMap.cpp:
+        (WebCore::DOMDataStoreHandle::DOMDataStoreHandle):
+        (WebCore::DOMDataStoreHandle::~DOMDataStoreHandle):
+        (WebCore::visitActiveDOMNodes):
+        (WebCore::visitDOMObjects):
+        (WebCore::visitActiveDOMObjects):
+        * bindings/v8/V8DOMMap.h:
+        (WebCore):
+        * bindings/v8/V8PerIsolateData.h:
+        (V8PerIsolateData):
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::WorkerScriptController):
+        (WebCore::WorkerScriptController::~WorkerScriptController):
+        * bindings/v8/WorkerScriptController.h:
+        (WorkerScriptController):
+
 2012-10-24  Kent Tamura  <[email protected]>
 
         Minimize CSS rulesets for multiple-fields input

Modified: trunk/Source/WebCore/WebCore.gypi (132453 => 132454)


--- trunk/Source/WebCore/WebCore.gypi	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/WebCore.gypi	2012-10-25 07:14:23 UTC (rev 132454)
@@ -2254,8 +2254,6 @@
             'bindings/v8/RetainedObjectInfo.h',
             'bindings/v8/ScheduledAction.cpp',
             'bindings/v8/ScheduledAction.h',
-            'bindings/v8/ScopedDOMDataStore.cpp',
-            'bindings/v8/ScopedDOMDataStore.h',
             'bindings/v8/ScopedPersistent.h',
             'bindings/v8/ScriptCachedFrameData.cpp',
             'bindings/v8/ScriptCachedFrameData.h',
@@ -2297,8 +2295,6 @@
             'bindings/v8/SerializedScriptValue.cpp',
             'bindings/v8/SerializedScriptValue.h',
             'bindings/v8/SharedPersistent.h',
-            'bindings/v8/StaticDOMDataStore.cpp',
-            'bindings/v8/StaticDOMDataStore.h',
             'bindings/v8/V8AbstractEventListener.cpp',
             'bindings/v8/V8AbstractEventListener.h',
             'bindings/v8/V8Binding.cpp',

Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -31,28 +31,51 @@
 #include "config.h"
 #include "DOMDataStore.h"
 
-#include "StaticDOMDataStore.h"
+#include "DOMWrapperMap.h"
+#include "IntrusiveDOMWrapperMap.h"
 #include "V8Binding.h"
 #include "WebCoreMemoryInstrumentation.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
 
-DOMDataStore::DOMDataStore()
-    : m_domNodeMap(0)
-    , m_activeDomNodeMap(0)
-    , m_domObjectMap(0)
-    , m_activeDomObjectMap(0)
+DOMDataStore::DOMDataStore(Type type)
+    : m_type(type)
 {
+    if (type == MainWorld) {
+        m_domNodeMap = adoptPtr(new DOMNodeWrapperMap);
+        m_activeDomNodeMap = adoptPtr(new ActiveDOMNodeWrapperMap);
+    } else {
+        ASSERT(type == IsolatedWorld || type == Worker);
+        // FIXME: In principle, we shouldn't need to create these
+        // wrapper maps for workers because there are no Nodes on
+        // worker threads.
+        m_domNodeMap = adoptPtr(new DOMWrapperHashMap<Node>);
+        m_activeDomNodeMap = adoptPtr(new DOMWrapperHashMap<Node>);
+    }
+    m_domObjectMap = adoptPtr(new DOMWrapperHashMap<void>);
+    m_activeDomObjectMap = adoptPtr(new DOMWrapperHashMap<void>);
+
+    V8PerIsolateData::current()->registerDOMDataStore(this);
 }
 
 DOMDataStore::~DOMDataStore()
 {
+    ASSERT(m_type != MainWorld); // We never actually destruct the main world's DOMDataStore.
+
+    V8PerIsolateData::current()->unregisterDOMDataStore(this);
+
+    if (m_type == IsolatedWorld) {
+        m_domNodeMap->clear();
+        m_activeDomNodeMap->clear();
+    }
+    m_domObjectMap->clear();
+    m_activeDomObjectMap->clear();
 }
 
 DOMDataStore* DOMDataStore::current(v8::Isolate* isolate)
 {
-    DEFINE_STATIC_LOCAL(StaticDOMDataStore, defaultStore, ());
+    DEFINE_STATIC_LOCAL(DOMDataStore, defaultStore, (MainWorld));
     V8PerIsolateData* data = ""
     if (UNLIKELY(!!data->domDataStore()))
         return data->domDataStore();
@@ -65,10 +88,10 @@
 void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);
-    info.addWeakPointer(m_domNodeMap);
-    info.addWeakPointer(m_activeDomNodeMap);
-    info.addWeakPointer(m_domObjectMap);
-    info.addWeakPointer(m_activeDomObjectMap);
+    info.addMember(m_domNodeMap);
+    info.addMember(m_activeDomNodeMap);
+    info.addMember(m_domObjectMap);
+    info.addMember(m_activeDomObjectMap);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/DOMDataStore.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -45,42 +45,35 @@
 
 namespace WebCore {
 
-    class DOMDataStore;
+class DOMDataStore {
+    WTF_MAKE_NONCOPYABLE(DOMDataStore);
+public:
+    enum Type {
+        MainWorld,
+        IsolatedWorld,
+        Worker,
+    };
 
-    typedef Vector<DOMDataStore*> DOMDataList;
+    explicit DOMDataStore(Type);
+    ~DOMDataStore();
 
-    // DOMDataStore
-    //
-    // DOMDataStore is the backing store that holds the maps between DOM objects
-    // and _javascript_ objects.  In general, each thread can have multiple backing
-    // stores, one per isolated world.
-    //
-    // This class doesn't manage the lifetime of the store.  The data store
-    // lifetime is managed by subclasses.
-    //
-    class DOMDataStore {
-        WTF_MAKE_NONCOPYABLE(DOMDataStore);
-    public:
-        virtual ~DOMDataStore();
+    static DOMDataStore* current(v8::Isolate*);
 
-        static DOMDataStore* current(v8::Isolate*);
+    DOMWrapperMap<Node>& domNodeMap() { return *m_domNodeMap; }
+    DOMWrapperMap<Node>& activeDomNodeMap() { return *m_activeDomNodeMap; }
+    DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; }
+    DOMWrapperMap<void>& activeDomObjectMap() { return *m_activeDomObjectMap; }
 
-        DOMWrapperMap<Node>& domNodeMap() { return *m_domNodeMap; }
-        DOMWrapperMap<Node>& activeDomNodeMap() { return *m_activeDomNodeMap; }
-        DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; }
-        DOMWrapperMap<void>& activeDomObjectMap() { return *m_activeDomObjectMap; }
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 
-        virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+protected:
+    Type m_type;
+    OwnPtr<DOMWrapperMap<Node> > m_domNodeMap;
+    OwnPtr<DOMWrapperMap<Node> > m_activeDomNodeMap;
+    OwnPtr<DOMWrapperMap<void> > m_domObjectMap;
+    OwnPtr<DOMWrapperMap<void> > m_activeDomObjectMap;
+};
 
-    protected:
-        DOMDataStore();
-
-        DOMWrapperMap<Node>* m_domNodeMap;
-        DOMWrapperMap<Node>* m_activeDomNodeMap;
-        DOMWrapperMap<void>* m_domObjectMap;
-        DOMWrapperMap<void>* m_activeDomObjectMap;
-    };
-
 } // namespace WebCore
 
 #endif // DOMDataStore_h

Deleted: trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScopedDOMDataStore.h"
-
-#include "Node.h"
-#include "WebCoreMemoryInstrumentation.h"
-
-namespace WebCore {
-
-ScopedDOMDataStore::ScopedDOMDataStore()
-    : DOMDataStore()
-{
-    m_domNodeMap = new DOMWrapperHashMap<Node>;
-    m_activeDomNodeMap = new DOMWrapperHashMap<Node>;
-    m_domObjectMap = new DOMWrapperHashMap<void>;
-    m_activeDomObjectMap = new DOMWrapperHashMap<void>;
-}
-
-ScopedDOMDataStore::~ScopedDOMDataStore()
-{
-    // FIXME: Consider moving these calls to clear()
-    // into the DOMWrapperHashMap destructor.
-    m_domNodeMap->clear();
-    m_activeDomNodeMap->clear();
-    m_domObjectMap->clear();
-    m_activeDomObjectMap->clear();
-
-    delete m_domNodeMap;
-    delete m_activeDomNodeMap;
-    delete m_domObjectMap;
-    delete m_activeDomObjectMap;
-}
-
-void ScopedDOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
-    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);
-    DOMDataStore::reportMemoryUsage(memoryObjectInfo);
-    info.addMember(m_domNodeMap);
-    info.addMember(m_activeDomNodeMap);
-    info.addMember(m_domObjectMap);
-    info.addMember(m_activeDomObjectMap);
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/ScopedDOMDataStore.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScopedDOMDataStore_h
-#define ScopedDOMDataStore_h
-
-#include "DOMDataStore.h"
-
-namespace WebCore {
-
-    // ScopedDOMDataStore
-    //
-    // ScopedDOMDataStore is a DOMDataStore that controls limits the lifetime of
-    // the store to the lifetime of the object itself.  In other words, when the
-    // ScopedDOMDataStore object is deallocated, the maps that belong to the store
-    // are deallocated as well.
-    //
-    class ScopedDOMDataStore : public DOMDataStore {
-    public:
-        ScopedDOMDataStore();
-
-        // This can be called when WTF thread is tearing down.
-        // We assume that all child threads running V8 instances are created by WTF.
-        virtual ~ScopedDOMDataStore();
-
-        virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-    };
-
-} // namespace WebCore
-
-#endif // ScopedDOMDataStore_h

Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -2208,7 +2208,7 @@
 
 static void neuterBinding(void* domObject) 
 {
-    DOMDataList& allStores = V8PerIsolateData::current()->allStores();
+    Vector<DOMDataStore*>& allStores = V8PerIsolateData::current()->allStores();
     for (size_t i = 0; i < allStores.size(); i++) {
         v8::Handle<v8::Object> obj = allStores[i]->domObjectMap().get(domObject);
         if (!obj.IsEmpty())

Deleted: trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StaticDOMDataStore.h"
-#include "V8Binding.h"
-#include "WebCoreMemoryInstrumentation.h"
-
-namespace WebCore {
-
-StaticDOMDataStore::StaticDOMDataStore()
-{
-    m_domNodeMap = &m_staticDomNodeMap;
-    m_activeDomNodeMap = &m_staticActiveDomNodeMap;
-    m_domObjectMap = &m_staticDomObjectMap;
-    m_activeDomObjectMap = &m_staticActiveDomObjectMap;
-    V8PerIsolateData::current()->registerDOMDataStore(this);
-}
-
-StaticDOMDataStore::~StaticDOMDataStore()
-{
-    V8PerIsolateData::current()->unregisterDOMDataStore(this);
-}
-
-void StaticDOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
-    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);
-    DOMDataStore::reportMemoryUsage(memoryObjectInfo);
-    info.addMember(m_staticDomNodeMap);
-    info.addMember(m_staticActiveDomNodeMap);
-    info.addMember(m_staticDomObjectMap);
-    info.addMember(m_staticActiveDomObjectMap);
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/StaticDOMDataStore.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StaticDOMDataStore_h
-#define StaticDOMDataStore_h
-
-#include "DOMDataStore.h"
-#include "IntrusiveDOMWrapperMap.h"
-
-namespace WebCore {
-
-// StaticDOMDataStore
-//
-// StaticDOMDataStore is a DOMDataStore that manages the lifetime of the store
-// statically.  This encapsulates thread-specific DOM data for the main
-// thread.  All the maps in it are static.  This is because we are unable to
-// rely on WTF::ThreadSpecificThreadExit to do the cleanup since the place that
-// tears down the main thread can not call any WTF functions.
-//
-class StaticDOMDataStore : public DOMDataStore {
-public:
-    StaticDOMDataStore();
-    virtual ~StaticDOMDataStore();
-
-    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-
-private:
-    DOMNodeWrapperMap m_staticDomNodeMap;
-    ActiveDOMNodeWrapperMap m_staticActiveDomNodeMap;
-    DOMWrapperHashMap<void> m_staticDomObjectMap;
-    DOMWrapperHashMap<void> m_staticActiveDomObjectMap;
-};
-
-} // namespace WebCore
-
-#endif // StaticDOMDataStore_h

Modified: trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -32,7 +32,6 @@
 #include "V8DOMMap.h"
 
 #include "DOMDataStore.h"
-#include "ScopedDOMDataStore.h"
 #include "V8Binding.h"
 #include "V8Node.h"
 #include <wtf/MainThread.h>
@@ -40,16 +39,13 @@
 namespace WebCore {
 
 DOMDataStoreHandle::DOMDataStoreHandle(bool initialize)
-    : m_store(adoptPtr(!initialize ? 0 : new ScopedDOMDataStore()))
 {
-    if (m_store)
-        V8PerIsolateData::current()->registerDOMDataStore(m_store.get());
+    if (initialize)
+        m_store = adoptPtr(new DOMDataStore(DOMDataStore::IsolatedWorld));
 }
 
 DOMDataStoreHandle::~DOMDataStoreHandle()
 {
-    if (m_store)
-        V8PerIsolateData::current()->unregisterDOMDataStore(m_store.get());
 }
 
 NodeWrapperVisitor::~NodeWrapperVisitor()
@@ -84,15 +80,6 @@
     return DOMDataStore::current(isolate)->activeDomObjectMap();
 }
 
-void removeAllDOMObjects()
-{
-    ASSERT(!isMainThread());
-    v8::HandleScope scope;
-    DOMDataStore* store = DOMDataStore::current(v8::Isolate::GetCurrent());
-    store->domObjectMap().clear();
-    store->activeDomObjectMap().clear();
-}
-
 void visitAllDOMNodes(NodeWrapperVisitor* visitor)
 {
     v8::HandleScope scope;
@@ -126,7 +113,7 @@
 {
     v8::HandleScope scope;
 
-    DOMDataList& list = V8PerIsolateData::current()->allStores();
+    Vector<DOMDataStore*>& list = V8PerIsolateData::current()->allStores();
     for (size_t i = 0; i < list.size(); ++i) {
         DOMDataStore* store = list[i];
 
@@ -138,7 +125,7 @@
 {
     v8::HandleScope scope;
 
-    DOMDataList& list = V8PerIsolateData::current()->allStores();
+    Vector<DOMDataStore*>& list = V8PerIsolateData::current()->allStores();
     for (size_t i = 0; i < list.size(); ++i) {
         DOMDataStore* store = list[i];
 
@@ -150,7 +137,7 @@
 {
     v8::HandleScope scope;
 
-    DOMDataList& list = V8PerIsolateData::current()->allStores();
+    Vector<DOMDataStore*>& list = V8PerIsolateData::current()->allStores();
     for (size_t i = 0; i < list.size(); ++i) {
         DOMDataStore* store = list[i];
 

Modified: trunk/Source/WebCore/bindings/v8/V8DOMMap.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -76,9 +76,6 @@
     DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* = 0);
     void visitActiveDOMObjects(DOMWrapperVisitor<void>*);
 
-    // This should be called to remove all DOM objects associated with the current thread when it is tearing down.
-    void removeAllDOMObjects();
-
 } // namespace WebCore
 
 #endif // V8DOMMap_h

Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -140,7 +140,7 @@
     OwnPtr<StringCache> m_stringCache;
     OwnPtr<IntegerCache> m_integerCache;
 
-    DOMDataList m_domDataList;
+    Vector<DOMDataStore*> m_domDataList;
     DOMDataStore* m_domDataStore;
 
     OwnPtr<V8HiddenPropertyName> m_hiddenPropertyName;

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-10-25 07:14:23 UTC (rev 132454)
@@ -60,15 +60,15 @@
     , m_executionScheduledToTerminate(false)
 {
     V8PerIsolateData* data = ""
-    data->allStores().append(&m_DOMDataStore);
-    data->setDOMDataStore(&m_DOMDataStore);
     m_isolate->Enter();
+    m_domDataStore = adoptPtr(new DOMDataStore(DOMDataStore::Worker));
+    data->setDOMDataStore(m_domDataStore.get());
     m_proxy = adoptPtr(new WorkerContextExecutionProxy(workerContext));
 }
 
 WorkerScriptController::~WorkerScriptController()
 {
-    removeAllDOMObjects();
+    m_domDataStore.clear();
 #if PLATFORM(CHROMIUM)
     // The corresponding call to didStartWorkerRunLoop is in
     // WorkerThread::workerThread().

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.h (132453 => 132454)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-10-25 06:54:23 UTC (rev 132453)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-10-25 07:14:23 UTC (rev 132454)
@@ -33,7 +33,6 @@
 
 #if ENABLE(WORKERS)
 
-#include "ScopedDOMDataStore.h"
 #include "V8Binding.h"
 
 #include <v8.h>
@@ -82,7 +81,7 @@
         WorkerContext* m_workerContext;
         OwnPtr<WorkerContextExecutionProxy> m_proxy;
         v8::Isolate* m_isolate;
-        ScopedDOMDataStore m_DOMDataStore;
+        OwnPtr<DOMDataStore> m_domDataStore;
         bool m_executionForbidden;
         bool m_executionScheduledToTerminate;
         mutable Mutex m_scheduledTerminationMutex;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to