Diff
Modified: trunk/Source/WebCore/ChangeLog (132446 => 132447)
--- trunk/Source/WebCore/ChangeLog 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/ChangeLog 2012-10-25 06:06:55 UTC (rev 132447)
@@ -1,3 +1,32 @@
+2012-10-24 Adam Barth <[email protected]>
+
+ [V8] DOMData is no longer needed
+ https://bugs.webkit.org/show_bug.cgi?id=100313
+
+ Reviewed by Eric Seidel.
+
+ This class serves no purpose anymore and can be deleted.
+
+ * WebCore.gypi:
+ * bindings/v8/DOMData.cpp: Removed.
+ * bindings/v8/DOMData.h: Removed.
+ * bindings/v8/DOMDataStore.cpp:
+ (WebCore::DOMDataStore::current):
+ * bindings/v8/DOMDataStore.h:
+ (WebCore):
+ (DOMDataStore):
+ * bindings/v8/SerializedScriptValue.cpp:
+ (WebCore::neuterBinding):
+ * bindings/v8/V8DOMMap.cpp:
+ (WebCore::getDOMNodeMap):
+ (WebCore::getActiveDOMNodeMap):
+ (WebCore::getDOMObjectMap):
+ (WebCore::getActiveDOMObjectMap):
+ (WebCore::removeAllDOMObjects):
+ (WebCore::visitActiveDOMNodes):
+ (WebCore::visitDOMObjects):
+ (WebCore::visitActiveDOMObjects):
+
2012-10-24 Kent Tamura <[email protected]>
Sort an Xcode project file.
Modified: trunk/Source/WebCore/WebCore.gypi (132446 => 132447)
--- trunk/Source/WebCore/WebCore.gypi 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/WebCore.gypi 2012-10-25 06:06:55 UTC (rev 132447)
@@ -2227,8 +2227,6 @@
'bindings/v8/ArrayValue.h',
'bindings/v8/BindingState.cpp',
'bindings/v8/BindingState.h',
- 'bindings/v8/DOMData.cpp',
- 'bindings/v8/DOMData.h',
'bindings/v8/DOMDataStore.cpp',
'bindings/v8/DOMDataStore.h',
'bindings/v8/DOMTransaction.cpp',
Deleted: trunk/Source/WebCore/bindings/v8/DOMData.cpp (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/DOMData.cpp 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/DOMData.cpp 2012-10-25 06:06:55 UTC (rev 132447)
@@ -1,54 +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 "DOMData.h"
-#include "V8Binding.h"
-#include "V8DOMWindowShell.h"
-#include "WebGLContextAttributes.h"
-#include "WebGLUniformLocation.h"
-
-namespace WebCore {
-
-DOMDataStore& DOMData::getCurrentStore(v8::Isolate* isolate)
-{
- DEFINE_STATIC_LOCAL(StaticDOMDataStore, defaultStore, ());
- if (UNLIKELY(!isolate))
- isolate = v8::Isolate::GetCurrent();
- V8PerIsolateData* data = ""
- if (UNLIKELY(data->domDataStore() != 0))
- return *data->domDataStore();
- V8DOMWindowShell* context = V8DOMWindowShell::getEntered();
- if (UNLIKELY(context != 0))
- return *context->world()->domDataStore();
- return defaultStore;
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/bindings/v8/DOMData.h (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/DOMData.h 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/DOMData.h 2012-10-25 06:06:55 UTC (rev 132447)
@@ -1,56 +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 DOMData_h
-#define DOMData_h
-
-#include "DOMDataStore.h"
-#include "StaticDOMDataStore.h"
-#include "V8DOMWrapper.h"
-
-namespace WebCore {
-
- // DOMData
- //
- // DOMData represents the all the DOM wrappers for a given thread. In
- // particular, DOMData holds wrappers for all the isolated worlds in the
- // thread. The DOMData for the main thread and the DOMData for child threads
- // use different subclasses.
- //
- class DOMData {
- public:
- static DOMDataStore& getCurrentStore(v8::Isolate* = 0);
- private:
- DOMData();
- };
-
-} // namespace WebCore
-
-#endif // DOMData_h
Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp 2012-10-25 06:06:55 UTC (rev 132447)
@@ -31,60 +31,13 @@
#include "config.h"
#include "DOMDataStore.h"
-#include "DOMData.h"
+#include "StaticDOMDataStore.h"
#include "V8Binding.h"
#include "WebCoreMemoryInstrumentation.h"
#include <wtf/MainThread.h>
namespace WebCore {
-// DOM binding algorithm:
-//
-// There are two kinds of DOM objects:
-// 1. DOM tree nodes, such as Document, HTMLElement, ...
-// there classes implement TreeShared<T> interface;
-// 2. Non-node DOM objects, such as CSSRule, Location, etc.
-// these classes implement a ref-counted scheme.
-//
-// A DOM object may have a JS wrapper object. If a tree node
-// is alive, its JS wrapper must be kept alive even it is not
-// reachable from JS roots.
-// However, JS wrappers of non-node objects can go away if
-// not reachable from other JS objects. It works like a cache.
-//
-// DOM objects are ref-counted, and JS objects are traced from
-// a set of root objects. They can create a cycle. To break
-// cycles, we do following:
-// Handles from DOM objects to JS wrappers are always weak,
-// so JS wrappers of non-node object cannot create a cycle.
-// Before starting a global GC, we create a virtual connection
-// between nodes in the same tree in the JS heap. If the wrapper
-// of one node in a tree is alive, wrappers of all nodes in
-// the same tree are considered alive. This is done by creating
-// object groups in GC prologue callbacks. The mark-compact
-// collector will remove these groups after each GC.
-//
-// DOM objects should be deref-ed from the owning thread, not the GC thread
-// that does not own them. In V8, GC can kick in from any thread. To ensure
-// that DOM objects are always deref-ed from the owning thread when running
-// V8 in multi-threading environment, we do following:
-// 1. Maintain a thread specific DOM wrapper map for each object map.
-// (We're using TLS support from WTF instead of base since V8Bindings
-// does not depend on base. We further assume that all child threads
-// running V8 instances are created by WTF and thus a destructor will
-// be called to clean up all thread specific data.)
-// 2. When GC happens:
-// 2.1. If the dead object is in GC thread's map, remove the JS reference
-// and deref the DOM object.
-// 2.2. Otherwise, go through all thread maps to find the owning thread.
-// Remove the JS reference from the owning thread's map and move the
-// DOM object to a delayed queue. Post a task to the owning thread
-// to have it deref-ed from the owning thread at later time.
-// 3. When a thread is tearing down, invoke a cleanup routine to go through
-// all objects in the delayed queue and the thread map and deref all of
-// them.
-
-
DOMDataStore::DOMDataStore()
: m_domNodeMap(0)
, m_activeDomNodeMap(0)
@@ -97,28 +50,18 @@
{
}
-DOMDataList& DOMDataStore::allStores()
+DOMDataStore* DOMDataStore::current(v8::Isolate* isolate)
{
- return V8PerIsolateData::current()->allStores();
+ DEFINE_STATIC_LOCAL(StaticDOMDataStore, defaultStore, ());
+ V8PerIsolateData* data = ""
+ if (UNLIKELY(!!data->domDataStore()))
+ return data->domDataStore();
+ V8DOMWindowShell* context = V8DOMWindowShell::getEntered();
+ if (UNLIKELY(!!context))
+ return context->world()->domDataStore();
+ return &defaultStore;
}
-void* DOMDataStore::getDOMWrapperMap(DOMWrapperMapType type)
-{
- switch (type) {
- case DOMNodeMap:
- return m_domNodeMap;
- case ActiveDOMNodeMap:
- return m_activeDomNodeMap;
- case DOMObjectMap:
- return m_domObjectMap;
- case ActiveDOMObjectMap:
- return m_activeDomObjectMap;
- }
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding);
Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.h (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/DOMDataStore.h 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.h 2012-10-25 06:06:55 UTC (rev 132447)
@@ -45,10 +45,9 @@
namespace WebCore {
- class DOMData;
class DOMDataStore;
- typedef WTF::Vector<DOMDataStore*> DOMDataList;
+ typedef Vector<DOMDataStore*> DOMDataList;
// DOMDataStore
//
@@ -62,21 +61,10 @@
class DOMDataStore {
WTF_MAKE_NONCOPYABLE(DOMDataStore);
public:
- enum DOMWrapperMapType {
- DOMNodeMap,
- ActiveDOMNodeMap,
- DOMObjectMap,
- ActiveDOMObjectMap,
- };
-
- DOMDataStore();
virtual ~DOMDataStore();
- // A list of all DOMDataStore objects in the current V8 isolate. Normally, each World has a DOMDataStore.
- static DOMDataList& allStores();
+ static DOMDataStore* current(v8::Isolate*);
- void* getDOMWrapperMap(DOMWrapperMapType);
-
DOMWrapperMap<Node>& domNodeMap() { return *m_domNodeMap; }
DOMWrapperMap<Node>& activeDomNodeMap() { return *m_activeDomNodeMap; }
DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; }
@@ -85,6 +73,8 @@
virtual void reportMemoryUsage(MemoryObjectInfo*) const;
protected:
+ DOMDataStore();
+
DOMWrapperMap<Node>* m_domNodeMap;
DOMWrapperMap<Node>* m_activeDomNodeMap;
DOMWrapperMap<void>* m_domObjectMap;
Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp 2012-10-25 06:06:55 UTC (rev 132447)
@@ -2208,7 +2208,7 @@
static void neuterBinding(void* domObject)
{
- DOMDataList& allStores = DOMDataStore::allStores();
+ DOMDataList& 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())
Modified: trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp (132446 => 132447)
--- trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp 2012-10-25 06:03:40 UTC (rev 132446)
+++ trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp 2012-10-25 06:06:55 UTC (rev 132447)
@@ -31,7 +31,6 @@
#include "config.h"
#include "V8DOMMap.h"
-#include "DOMData.h"
#include "DOMDataStore.h"
#include "ScopedDOMDataStore.h"
#include "V8Binding.h"
@@ -59,31 +58,39 @@
DOMWrapperMap<Node>& getDOMNodeMap(v8::Isolate* isolate)
{
- return DOMData::getCurrentStore(isolate).domNodeMap();
+ if (!isolate)
+ isolate = v8::Isolate::GetCurrent();
+ return DOMDataStore::current(isolate)->domNodeMap();
}
DOMWrapperMap<Node>& getActiveDOMNodeMap(v8::Isolate* isolate)
{
- return DOMData::getCurrentStore(isolate).activeDomNodeMap();
+ if (!isolate)
+ isolate = v8::Isolate::GetCurrent();
+ return DOMDataStore::current(isolate)->activeDomNodeMap();
}
DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* isolate)
{
- return DOMData::getCurrentStore(isolate).domObjectMap();
+ if (!isolate)
+ isolate = v8::Isolate::GetCurrent();
+ return DOMDataStore::current(isolate)->domObjectMap();
}
DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* isolate)
{
- return DOMData::getCurrentStore(isolate).activeDomObjectMap();
+ if (!isolate)
+ isolate = v8::Isolate::GetCurrent();
+ return DOMDataStore::current(isolate)->activeDomObjectMap();
}
void removeAllDOMObjects()
{
ASSERT(!isMainThread());
v8::HandleScope scope;
- DOMDataStore& store = DOMData::getCurrentStore();
- store.domObjectMap().clear();
- store.activeDomObjectMap().clear();
+ DOMDataStore* store = DOMDataStore::current(v8::Isolate::GetCurrent());
+ store->domObjectMap().clear();
+ store->activeDomObjectMap().clear();
}
void visitAllDOMNodes(NodeWrapperVisitor* visitor)
@@ -119,7 +126,7 @@
{
v8::HandleScope scope;
- DOMDataList& list = DOMDataStore::allStores();
+ DOMDataList& list = V8PerIsolateData::current()->allStores();
for (size_t i = 0; i < list.size(); ++i) {
DOMDataStore* store = list[i];
@@ -131,7 +138,7 @@
{
v8::HandleScope scope;
- DOMDataList& list = DOMDataStore::allStores();
+ DOMDataList& list = V8PerIsolateData::current()->allStores();
for (size_t i = 0; i < list.size(); ++i) {
DOMDataStore* store = list[i];
@@ -143,7 +150,7 @@
{
v8::HandleScope scope;
- DOMDataList& list = DOMDataStore::allStores();
+ DOMDataList& list = V8PerIsolateData::current()->allStores();
for (size_t i = 0; i < list.size(); ++i) {
DOMDataStore* store = list[i];