Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: third_party/WebKit/WebCore/bindings/v8/V8DOMMap.cpp

Issue 67061: Fix ASSERTS in worker code in OSX.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/WebCore/bindings/v8/V8DOMMap.cpp
===================================================================
--- third_party/WebKit/WebCore/bindings/v8/V8DOMMap.cpp (revision 13509)
+++ third_party/WebKit/WebCore/bindings/v8/V8DOMMap.cpp (working copy)
@@ -40,6 +40,7 @@
#include <wtf/StdLibExtras.h>
#include <wtf/Threading.h>
#include <wtf/ThreadSpecific.h>
+#include <wtf/Vector.h>
namespace WebCore {
@@ -103,23 +104,21 @@
// The helper function will be scheduled by the GC thread to get called from the owning thread.
static void derefDelayedObjectsInCurrentThread(void*);
-// This should be called to remove all DOM objects associated with the current thread when it is tearing down.
-static void removeAllDOMObjectsInCurrentThread();
-
-// A map from a thread ID to thread's specific data.
+// A list of all ThreadSpecific DOM Data objects. Traversed during GC to find a thread-specific map that
+// contains the object - so we can schedule the object to be deleted on the thread which created it.
class ThreadSpecificDOMData;
-typedef WTF::HashMap<WTF::ThreadIdentifier, ThreadSpecificDOMData*> DOMThreadMap;
-static DOMThreadMap& domThreadMap()
+typedef WTF::Vector<ThreadSpecificDOMData*> DOMDataList;
+static DOMDataList& domDataList()
{
- DEFINE_STATIC_LOCAL(DOMThreadMap, staticDOMThreadMap, ());
- return staticDOMThreadMap;
+ DEFINE_STATIC_LOCAL(DOMDataList, staticDOMDataList, ());
+ return staticDOMDataList;
}
-// Mutex to protect against concurrent access of domThreadMap.
-static WTF::Mutex& domThreadMapMutex()
+// Mutex to protect against concurrent access of DOMDataList.
+static WTF::Mutex& domDataListMutex()
{
- DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMThreadMapMutex, ());
- return staticDOMThreadMapMutex;
+ DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMDataListMutex, ());
+ return staticDOMDataListMutex;
}
class ThreadSpecificDOMData : Noncopyable {
@@ -161,14 +160,14 @@
, m_delayedProcessingScheduled(false)
, m_isMainThread(WTF::isMainThread())
{
- WTF::MutexLocker locker(domThreadMapMutex());
- domThreadMap().set(WTF::currentThread(), this);
+ WTF::MutexLocker locker(domDataListMutex());
+ domDataList().append(this);
}
virtual ~ThreadSpecificDOMData()
{
- WTF::MutexLocker locker(domThreadMapMutex());
- domThreadMap().remove(WTF::currentThread());
+ WTF::MutexLocker locker(domDataListMutex());
+ domDataList().remove(domDataList().find(this));
}
void* getDOMWrapperMap(DOMWrapperMapType type)
@@ -241,8 +240,6 @@
// We assume that all child threads running V8 instances are created by WTF.
virtual ~NonMainThreadSpecificDOMData()
{
- removeAllDOMObjectsInCurrentThread();
-
delete m_domNodeMap;
delete m_domObjectMap;
delete m_activeDomObjectMap;
@@ -385,17 +382,11 @@
template<typename T>
static void handleWeakObjectInOwningThread(ThreadSpecificDOMData::DOMWrapperMapType mapType, V8ClassIndex::V8WrapperType objectType, T* object)
{
- WTF::MutexLocker locker(domThreadMapMutex());
- for (typename DOMThreadMap::iterator iter(domThreadMap().begin()); iter != domThreadMap().end(); ++iter) {
- WTF::ThreadIdentifier threadID = iter->first;
- ThreadSpecificDOMData* threadData = iter->second;
+ WTF::MutexLocker locker(domDataListMutex());
+ DOMDataList& list = domDataList();
+ for (size_t i = 0; i < list.size(); ++i) {
+ ThreadSpecificDOMData* threadData = list[i];
- // Skip the current thread that is GC thread.
- if (threadID == WTF::currentThread()) {
- ASSERT(!static_cast<DOMWrapperMap<T>*>(threadData->getDOMWrapperMap(mapType))->contains(object));
- continue;
- }
-
ThreadSpecificDOMData::InternalDOMWrapperMap<T>* domMap = static_cast<ThreadSpecificDOMData::InternalDOMWrapperMap<T>*>(threadData->getDOMWrapperMap(mapType));
if (domMap->contains(object)) {
// Clear the JS reference.
@@ -514,7 +505,7 @@
static void derefDelayedObjects()
{
- WTF::MutexLocker locker(domThreadMapMutex());
+ WTF::MutexLocker locker(domDataListMutex());
getThreadSpecificDOMData().setDelayedProcessingScheduled(false);
@@ -573,7 +564,7 @@
#endif
}
-static void removeAllDOMObjectsInCurrentThread()
+void removeAllDOMObjectsInCurrentThread()
{
// Use the locker only if it has already been invoked before, as by worker thread.
if (v8::Locker::IsActive()) {

Powered by Google App Engine
This is Rietveld 408576698