WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
ROLLOUT of r88221
bug-62197-20110607090936.patch (text/plain), 28.65 KB, created by
WebKit Review Bot
on 2011-06-07 02:10:59 PDT
(
hide
)
Description:
ROLLOUT of r88221
Filename:
MIME Type:
Creator:
WebKit Review Bot
Created:
2011-06-07 02:10:59 PDT
Size:
28.65 KB
patch
obsolete
>Subversion Revision: 88229 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7faa4091a4c19155ee3073632ae74533a5b5d0bf..3f4ab5ed70604c1c7df7b8263000246e9ae6bb7c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,49 @@ >+2011-06-07 Sheriff Bot <webkit.review.bot@gmail.com> >+ >+ Unreviewed, rolling out r88221. >+ http://trac.webkit.org/changeset/88221 >+ https://bugs.webkit.org/show_bug.cgi?id=62197 >+ >+ "Chromium debug compilation broken" (Requested by yurys on >+ #webkit). >+ >+ * WebCore.gypi: >+ * bindings/v8/ChildThreadDOMData.cpp: Copied from Source/WebCore/bindings/v8/DOMData.cpp. >+ (WebCore::ChildThreadDOMData::ChildThreadDOMData): >+ (WebCore::ChildThreadDOMData::getStore): >+ * bindings/v8/ChildThreadDOMData.h: Copied from Source/WebCore/bindings/v8/DOMData.cpp. >+ * bindings/v8/DOMData.cpp: >+ (WebCore::DOMData::DOMData): >+ (WebCore::DOMData::getCurrent): >+ * bindings/v8/DOMData.h: >+ (WebCore::DOMData::owningThread): >+ (WebCore::DOMData::handleWeakObject): >+ * bindings/v8/DOMDataStore.cpp: >+ (WebCore::DOMDataStore::DOMDataStore): >+ (WebCore::DOMDataStore::~DOMDataStore): >+ (WebCore::DOMDataStore::allStoresMutex): >+ (WebCore::DOMDataStore::weakNodeCallback): >+ * bindings/v8/DOMDataStore.h: >+ * bindings/v8/MainThreadDOMData.cpp: Copied from Source/WebCore/bindings/v8/DOMData.cpp. >+ (WebCore::MainThreadDOMData::MainThreadDOMData): >+ (WebCore::MainThreadDOMData::getCurrent): >+ (WebCore::MainThreadDOMData::getMainThreadStore): >+ (WebCore::MainThreadDOMData::getCurrentMainThreadStore): >+ * bindings/v8/MainThreadDOMData.h: Copied from Source/WebCore/bindings/v8/DOMData.cpp. >+ (WebCore::MainThreadDOMData::getStore): >+ * bindings/v8/V8DOMMap.cpp: >+ (WebCore::getDOMDataStore): >+ (WebCore::visitDOMNodesInCurrentThread): >+ (WebCore::visitDOMObjectsInCurrentThread): >+ (WebCore::visitActiveDOMObjectsInCurrentThread): >+ (WebCore::visitDOMSVGElementInstancesInCurrentThread): >+ * bindings/v8/V8DOMMap.h: >+ * bindings/v8/V8GCController.cpp: >+ (WebCore::V8GCController::gcPrologue): >+ (WebCore::V8GCController::gcEpilogue): >+ * bindings/v8/WorkerScriptController.cpp: >+ (WebCore::WorkerScriptController::~WorkerScriptController): >+ > 2011-06-07 MORITA Hajime <morrita@google.com> > > Unreviewed, rolling out r88212 and r88219. >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 784d0a9500d5856a93e82f265f5bb1f6d9a1d15c..a06e0d1116e2f5094519fc43f766839113f7ca60 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -1951,6 +1951,8 @@ > 'bindings/objc/ObjCNodeFilterCondition.mm', > 'bindings/objc/PublicDOMInterfaces.h', > 'bindings/objc/WebScriptObject.mm', >+ 'bindings/v8/ChildThreadDOMData.cpp', >+ 'bindings/v8/ChildThreadDOMData.h', > 'bindings/v8/DOMData.cpp', > 'bindings/v8/DOMData.h', > 'bindings/v8/DOMDataStore.cpp', >@@ -1966,6 +1968,8 @@ > 'bindings/v8/IsolatedWorld.h', > 'bindings/v8/JavaScriptCallFrame.cpp', > 'bindings/v8/JavaScriptCallFrame.h', >+ 'bindings/v8/MainThreadDOMData.cpp', >+ 'bindings/v8/MainThreadDOMData.h', > 'bindings/v8/NPV8Object.cpp', > 'bindings/v8/NPV8Object.h', > 'bindings/v8/OptionsObject.cpp', >diff --git a/Source/WebCore/bindings/v8/ChildThreadDOMData.cpp b/Source/WebCore/bindings/v8/ChildThreadDOMData.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..77ce0f47b8df00c98423492dc351c5304d654756 >--- /dev/null >+++ b/Source/WebCore/bindings/v8/ChildThreadDOMData.cpp >@@ -0,0 +1,48 @@ >+/* >+ * 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 "ChildThreadDOMData.h" >+ >+namespace WebCore { >+ >+ChildThreadDOMData::ChildThreadDOMData() >+ : m_defaultStore(this) >+{ >+} >+ >+DOMDataStore& ChildThreadDOMData::getStore() >+{ >+ ASSERT(!WTF::isMainThread()); >+ // Currently, child threads have only one world. >+ return m_defaultStore; >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/bindings/v8/ChildThreadDOMData.h b/Source/WebCore/bindings/v8/ChildThreadDOMData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5097c86bc929f760cf05594e886c35f5f5ae772e >--- /dev/null >+++ b/Source/WebCore/bindings/v8/ChildThreadDOMData.h >@@ -0,0 +1,50 @@ >+/* >+ * 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 ChildThreadDOMData_h >+#define ChildThreadDOMData_h >+ >+#include "DOMData.h" >+#include "ScopedDOMDataStore.h" >+ >+namespace WebCore { >+ >+ class ChildThreadDOMData : public DOMData { >+ public: >+ ChildThreadDOMData(); >+ DOMDataStore& getStore(); >+ >+ private: >+ ScopedDOMDataStore m_defaultStore; >+ }; >+ >+} // namespace WebCore >+ >+#endif // ChildThreadDOMData_h >diff --git a/Source/WebCore/bindings/v8/DOMData.cpp b/Source/WebCore/bindings/v8/DOMData.cpp >index 428463c95427d76c41640f7d10548c7e5c470ec6..568fc2c89f2ffa809de4cece46f40122dab59660 100644 >--- a/Source/WebCore/bindings/v8/DOMData.cpp >+++ b/Source/WebCore/bindings/v8/DOMData.cpp >@@ -30,16 +30,17 @@ > > #include "config.h" > #include "DOMData.h" >-#include "V8IsolatedContext.h" >+ >+#include "ChildThreadDOMData.h" >+#include "MainThreadDOMData.h" > #include "WebGLContextAttributes.h" > #include "WebGLUniformLocation.h" > > namespace WebCore { > > DOMData::DOMData() >- : m_defaultStore(this) >+ : m_owningThread(WTF::currentThread()) > { >- ASSERT(WTF::isMainThread()); > } > > DOMData::~DOMData() >@@ -48,21 +49,11 @@ DOMData::~DOMData() > > DOMData* DOMData::getCurrent() > { >- ASSERT(WTF::isMainThread()); >- DEFINE_STATIC_LOCAL(DOMData, mainThreadDOMData, ()); >- return &mainThreadDOMData; >-} >+ if (WTF::isMainThread()) >+ return MainThreadDOMData::getCurrent(); > >-DOMDataStore& DOMData::getMainThreadStore() >-{ >- // This is broken out as a separate non-virtual method from getStore() >- // so that it can be inlined by getCurrentMainThreadStore, which is >- // a hot spot in Dromaeo DOM tests. >- ASSERT(WTF::isMainThread()); >- V8IsolatedContext* context = V8IsolatedContext::getEntered(); >- if (UNLIKELY(context != 0)) >- return *context->world()->domDataStore(); >- return m_defaultStore; >+ DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<ChildThreadDOMData>, childThreadDOMData, ()); >+ return childThreadDOMData; > } > > void DOMData::derefObject(WrapperTypeInfo* type, void* domObject) >@@ -70,6 +61,4 @@ void DOMData::derefObject(WrapperTypeInfo* type, void* domObject) > type->derefObject(domObject); > } > >- >- > } // namespace WebCore >diff --git a/Source/WebCore/bindings/v8/DOMData.h b/Source/WebCore/bindings/v8/DOMData.h >index 7cdae71041f6ee6b34a6b519ad36b03580b07a59..b0426068e78b9e228b609c5d3dd5bf80a19716f1 100644 >--- a/Source/WebCore/bindings/v8/DOMData.h >+++ b/Source/WebCore/bindings/v8/DOMData.h >@@ -32,7 +32,6 @@ > #define DOMData_h > > #include "DOMDataStore.h" >-#include "StaticDOMDataStore.h" > #include "V8DOMWrapper.h" > > namespace WebCore { >@@ -51,7 +50,7 @@ namespace WebCore { > virtual ~DOMData(); > > static DOMData* getCurrent(); >- DOMDataStore& getStore() { return getMainThreadStore(); } >+ virtual DOMDataStore& getStore() = 0; > > template<typename T> > static void handleWeakObject(DOMDataStore::DOMWrapperMapType, v8::Persistent<v8::Object>, T* domObject); >@@ -59,7 +58,7 @@ namespace WebCore { > template<typename T> > static void removeObjectsFromWrapperMap(DOMDataStore* store, AbstractWeakReferenceMap<T, v8::Object>& domMap); > >- static DOMDataStore& getCurrentMainThreadStore() { return getCurrent()->getMainThreadStore(); } >+ ThreadIdentifier owningThread() const { return m_owningThread; } > > private: > static void derefObject(WrapperTypeInfo* type, void* domObject); >@@ -75,19 +74,18 @@ namespace WebCore { > } > }; > >- DOMDataStore& getMainThreadStore(); >- StaticDOMDataStore m_defaultStore; >+ ThreadIdentifier m_owningThread; > }; > > template<typename T> > void DOMData::handleWeakObject(DOMDataStore::DOMWrapperMapType mapType, v8::Persistent<v8::Object> v8Object, T* domObject) > { >- ASSERT(WTF::isMainThread()); > WrapperTypeInfo* type = V8DOMWrapper::domWrapperType(v8Object); > DOMDataList& list = DOMDataStore::allStores(); > bool found = false; > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; >+ ASSERT(store->domData()->owningThread() == WTF::currentThread()); > > DOMWrapperMap<T>* domMap = static_cast<DOMWrapperMap<T>*>(store->getDOMWrapperMap(mapType)); > if (domMap->removeIfPresent(domObject, v8Object)) { >diff --git a/Source/WebCore/bindings/v8/DOMDataStore.cpp b/Source/WebCore/bindings/v8/DOMDataStore.cpp >index 25c5fd4698e524328b94461d91cedd55fb5c7434..21b47a49caef448e8ca228d4359c426a72e43781 100644 >--- a/Source/WebCore/bindings/v8/DOMDataStore.cpp >+++ b/Source/WebCore/bindings/v8/DOMDataStore.cpp >@@ -61,9 +61,26 @@ namespace WebCore { > // object groups in GC prologue callbacks. The mark-compact > // collector will remove these groups after each GC. > // >-// DOM objects are accessed and deref-ed from the main thread. All V8 accesses >-// to DOM objects happen on the main thread. >-// When GC happens, we remove the JS reference and deref the DOM object. >+// 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(DOMData* domData) > : m_domNodeMap(0) >@@ -74,13 +91,13 @@ DOMDataStore::DOMDataStore(DOMData* domData) > #endif > , m_domData(domData) > { >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataStore::allStores().append(this); > } > > DOMDataStore::~DOMDataStore() > { >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataStore::allStores().remove(DOMDataStore::allStores().find(this)); > } > >@@ -90,6 +107,12 @@ DOMDataList& DOMDataStore::allStores() > return staticDOMDataList; > } > >+WTF::Mutex& DOMDataStore::allStoresMutex() >+{ >+ DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMDataListMutex, ()); >+ return staticDOMDataListMutex; >+} >+ > void* DOMDataStore::getDOMWrapperMap(DOMWrapperMapType type) > { > switch (type) { >@@ -133,10 +156,12 @@ void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> value, void* domOb > // Node wrappers must be JS objects. > v8::Persistent<v8::Object> v8Object = v8::Persistent<v8::Object>::Cast(value); > >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataList& list = DOMDataStore::allStores(); > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; > if (store->domNodeMap().removeIfPresent(node, v8Object)) { >+ ASSERT(store->domData()->owningThread() == WTF::currentThread()); > node->deref(); // Nobody overrides Node::deref so it's safe > return; // There might be at most one wrapper for the node in world's maps > } >diff --git a/Source/WebCore/bindings/v8/DOMDataStore.h b/Source/WebCore/bindings/v8/DOMDataStore.h >index 373d85e5cc8f7f52887dace0c9213329211f0235..ffb9df5ad6cf6d63a7465a392c1244c0cc7876c4 100644 >--- a/Source/WebCore/bindings/v8/DOMDataStore.h >+++ b/Source/WebCore/bindings/v8/DOMDataStore.h >@@ -77,6 +77,8 @@ namespace WebCore { > > // A list of all DOMDataStore objects in the current V8 instance (thread). Normally, each World has a DOMDataStore. > static DOMDataList& allStores(); >+ // Mutex to protect against concurrent access of DOMDataList. >+ static WTF::Mutex& allStoresMutex(); > > DOMData* domData() const { return m_domData; } > >diff --git a/Source/WebCore/bindings/v8/MainThreadDOMData.cpp b/Source/WebCore/bindings/v8/MainThreadDOMData.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d9c865c8f49cf26cb5e9d44a1a4461f229154faf >--- /dev/null >+++ b/Source/WebCore/bindings/v8/MainThreadDOMData.cpp >@@ -0,0 +1,68 @@ >+/* >+ * 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 "MainThreadDOMData.h" >+ >+#include "V8IsolatedContext.h" >+ >+namespace WebCore { >+ >+MainThreadDOMData::MainThreadDOMData() >+ : m_defaultStore(this) >+{ >+} >+ >+MainThreadDOMData* MainThreadDOMData::getCurrent() >+{ >+ ASSERT(WTF::isMainThread()); >+ DEFINE_STATIC_LOCAL(MainThreadDOMData, mainThreadDOMData, ()); >+ return &mainThreadDOMData; >+} >+ >+DOMDataStore& MainThreadDOMData::getMainThreadStore() >+{ >+ // This is broken out as a separate non-virtual method from getStore() >+ // so that it can be inlined by getCurrentMainThreadStore, which is >+ // a hot spot in Dromaeo DOM tests. >+ ASSERT(WTF::isMainThread()); >+ V8IsolatedContext* context = V8IsolatedContext::getEntered(); >+ if (UNLIKELY(context != 0)) >+ return *context->world()->domDataStore(); >+ return m_defaultStore; >+} >+ >+DOMDataStore& MainThreadDOMData::getCurrentMainThreadStore() >+{ >+ return getCurrent()->getMainThreadStore(); >+} >+ >+ >+} // namespace WebCore >diff --git a/Source/WebCore/bindings/v8/MainThreadDOMData.h b/Source/WebCore/bindings/v8/MainThreadDOMData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e8f99c9f0ae89173f0cff0d05da98e083388a1c4 >--- /dev/null >+++ b/Source/WebCore/bindings/v8/MainThreadDOMData.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 MainThreadDOMData_h >+#define MainThreadDOMData_h >+ >+#include "DOMData.h" >+#include "StaticDOMDataStore.h" >+ >+namespace WebCore { >+ >+ class MainThreadDOMData : public DOMData { >+ public: >+ static MainThreadDOMData* getCurrent(); // Caller must be on the main thread. >+ static DOMDataStore& getCurrentMainThreadStore(); >+ >+ virtual DOMDataStore& getStore() { return getMainThreadStore(); } >+ >+ >+ private: >+ MainThreadDOMData(); >+ DOMDataStore& getMainThreadStore(); >+ >+ StaticDOMDataStore m_defaultStore; >+ // Note: The DOMDataStores for isolated world are owned by the world object. >+ }; >+ >+} // namespace WebCore >+ >+#endif // MainThreadDOMData_h >diff --git a/Source/WebCore/bindings/v8/V8DOMMap.cpp b/Source/WebCore/bindings/v8/V8DOMMap.cpp >index acc1baba4feee009a5e30504351352b598673059..c4082166fb03f87bfaec2aa65278821bcf1e91d7 100644 >--- a/Source/WebCore/bindings/v8/V8DOMMap.cpp >+++ b/Source/WebCore/bindings/v8/V8DOMMap.cpp >@@ -33,6 +33,7 @@ > > #include "DOMData.h" > #include "DOMDataStore.h" >+#include "MainThreadDOMData.h" > #include "ScopedDOMDataStore.h" > > namespace WebCore { >@@ -50,8 +51,12 @@ static bool fasterDOMStoreAccess = false; > > static inline DOMDataStore& getDOMDataStore() > { >- ASSERT(WTF::isMainThread()); >- return DOMData::getCurrentMainThreadStore(); >+ if (LIKELY(fasterDOMStoreAccess)) { >+ ASSERT(WTF::isMainThread()); >+ return MainThreadDOMData::getCurrentMainThreadStore(); >+ } >+ >+ return DOMData::getCurrent()->getStore(); > } > > void enableFasterDOMStoreAccess() >@@ -107,40 +112,46 @@ void removeAllDOMObjects() > DOMData::removeObjectsFromWrapperMap<void>(&store, store.activeDomObjectMap()); > } > >-void visitDOMNodes(DOMWrapperMap<Node>::Visitor* visitor) >+void visitDOMNodesInCurrentThread(DOMWrapperMap<Node>::Visitor* visitor) > { > v8::HandleScope scope; > >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataList& list = DOMDataStore::allStores(); > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; >+ if (!store->domData()->owningThread() == WTF::currentThread()) >+ continue; > > store->domNodeMap().visit(store, visitor); > } > } > >-void visitDOMObjects(DOMWrapperMap<void>::Visitor* visitor) >+void visitDOMObjectsInCurrentThread(DOMWrapperMap<void>::Visitor* visitor) > { > v8::HandleScope scope; > >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataList& list = DOMDataStore::allStores(); > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; >+ if (!store->domData()->owningThread() == WTF::currentThread()) >+ continue; > > store->domObjectMap().visit(store, visitor); > } > } > >-void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor* visitor) >+void visitActiveDOMObjectsInCurrentThread(DOMWrapperMap<void>::Visitor* visitor) > { > v8::HandleScope scope; > >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataList& list = DOMDataStore::allStores(); > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; >+ if (!store->domData()->owningThread() == WTF::currentThread()) >+ continue; > > store->activeDomObjectMap().visit(store, visitor); > } >@@ -148,14 +159,16 @@ void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor* visitor) > > #if ENABLE(SVG) > >-void visitDOMSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor* visitor) >+void visitDOMSVGElementInstancesInCurrentThread(DOMWrapperMap<SVGElementInstance>::Visitor* visitor) > { > v8::HandleScope scope; > >- ASSERT(WTF::isMainThread()); >+ WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); > DOMDataList& list = DOMDataStore::allStores(); > for (size_t i = 0; i < list.size(); ++i) { > DOMDataStore* store = list[i]; >+ if (!store->domData()->owningThread() == WTF::currentThread()) >+ continue; > > store->domSvgElementInstanceMap().visit(store, visitor); > } >diff --git a/Source/WebCore/bindings/v8/V8DOMMap.h b/Source/WebCore/bindings/v8/V8DOMMap.h >index 84cf754658e9a06978e6d75a579099bcced78a5a..51d933a83fbd7864e7523042023f493cd79c7766 100644 >--- a/Source/WebCore/bindings/v8/V8DOMMap.h >+++ b/Source/WebCore/bindings/v8/V8DOMMap.h >@@ -158,23 +158,23 @@ namespace WebCore { > > // A map from DOM node to its JS wrapper. > DOMNodeMapping& getDOMNodeMap(); >- void visitDOMNodes(DOMWrapperMap<Node>::Visitor*); >+ void visitDOMNodesInCurrentThread(DOMWrapperMap<Node>::Visitor*); > > // 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(); >- void visitDOMObjects(DOMWrapperMap<void>::Visitor*); >+ void visitDOMObjectsInCurrentThread(DOMWrapperMap<void>::Visitor*); > > // A map from a DOM object to its JS wrapper for DOM objects which can have pending activity. > DOMWrapperMap<void>& getActiveDOMObjectMap(); >- void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor*); >+ 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 removeAllDOMObjects(); >+ void removeAllDOMObjectsInCurrentThread(); > > #if ENABLE(SVG) > // A map for SVGElementInstances to its JS wrapper. > DOMWrapperMap<SVGElementInstance>& getDOMSVGElementInstanceMap(); >- void visitSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor*); >+ void visitSVGElementInstancesInCurrentThread(DOMWrapperMap<SVGElementInstance>::Visitor*); > #endif > > void enableFasterDOMStoreAccess(); >diff --git a/Source/WebCore/bindings/v8/V8GCController.cpp b/Source/WebCore/bindings/v8/V8GCController.cpp >index d5b673b3c09513edf41e4fa3a9b0d70ad579e4f5..74c165932a156826b2b2488381a19acd10cb04a6 100644 >--- a/Source/WebCore/bindings/v8/V8GCController.cpp >+++ b/Source/WebCore/bindings/v8/V8GCController.cpp >@@ -458,12 +458,12 @@ void V8GCController::gcPrologue() > // Run through all objects with possible pending activity making their > // wrappers non weak if there is pending activity. > GCPrologueVisitor prologueVisitor; >- visitActiveDOMObjects(&prologueVisitor); >+ visitActiveDOMObjectsInCurrentThread(&prologueVisitor); > > // Create object groups. > GrouperVisitor grouperVisitor; >- visitDOMNodes(&grouperVisitor); >- visitDOMObjects(&grouperVisitor); >+ visitDOMNodesInCurrentThread(&grouperVisitor); >+ visitDOMObjectsInCurrentThread(&grouperVisitor); > grouperVisitor.applyGrouping(); > > // Clean single element cache for string conversions. >@@ -529,7 +529,7 @@ void V8GCController::gcEpilogue() > // Run through all objects with pending activity making their wrappers weak > // again. > GCEpilogueVisitor epilogueVisitor; >- visitActiveDOMObjects(&epilogueVisitor); >+ visitActiveDOMObjectsInCurrentThread(&epilogueVisitor); > > workingSetEstimateMB = getActualMemoryUsageInMB(); > >@@ -539,7 +539,7 @@ void V8GCController::gcEpilogue() > visitDOMObjectsInCurrentThread(&domObjectVisitor); > > EnsureWeakDOMNodeVisitor weakDOMNodeVisitor; >- visitDOMNodes(&weakDOMNodeVisitor); >+ visitDOMNodesInCurrentThread(&weakDOMNodeVisitor); > > enumerateGlobalHandles(); > #endif >diff --git a/Source/WebCore/bindings/v8/WorkerScriptController.cpp b/Source/WebCore/bindings/v8/WorkerScriptController.cpp >index bb85d154e25300bd35361242cd113eea04880491..d9c76d42669405b648d400e45383779dce15808b 100644 >--- a/Source/WebCore/bindings/v8/WorkerScriptController.cpp >+++ b/Source/WebCore/bindings/v8/WorkerScriptController.cpp >@@ -58,7 +58,7 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) > > WorkerScriptController::~WorkerScriptController() > { >- removeAllDOMObjects(); >+ removeAllDOMObjectsInCurrentThread(); > } > > ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
abecsi
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 62197
:
96219
|
96222