Changeset 88221 in webkit
- Timestamp:
- Jun 6, 2011 11:19:10 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88220 r88221 1 2011-06-06 Dmitry Lomov <dslomov@google.com> 2 3 Reviewed by Adam Barth. 4 5 https://bugs.webkit.org/show_bug.cgi?id=62164 6 Remove "multi-threaded" logic in V8 DOMData, DOMDataStore and friends 7 This functionality is untested and unused: 8 This is an old code from Lockers-based implementation of WebWorkers in 9 V8 bindings, to make sure that DOM objects are released on the right thread 10 even though GC could have happened on any thread. It is currently unused (since 11 current model is one worker per process) and is being removed because new implementation 12 of WebWorkers will be using V8 isolates. 13 14 * WebCore.gypi: 15 * bindings/v8/ChildThreadDOMData.cpp: Removed. 16 * bindings/v8/ChildThreadDOMData.h: Removed. 17 * bindings/v8/DOMData.cpp: 18 (WebCore::DOMData::DOMData): 19 (WebCore::DOMData::getCurrent): 20 (WebCore::DOMData::getMainThreadStore): 21 * bindings/v8/DOMData.h: 22 (WebCore::DOMData::getStore): 23 (WebCore::DOMData::getCurrentMainThreadStore): 24 (WebCore::DOMData::handleWeakObject): 25 * bindings/v8/DOMDataStore.cpp: 26 (WebCore::DOMDataStore::DOMDataStore): 27 (WebCore::DOMDataStore::~DOMDataStore): 28 (WebCore::DOMDataStore::weakNodeCallback): 29 * bindings/v8/DOMDataStore.h: 30 * bindings/v8/MainThreadDOMData.cpp: Removed. 31 * bindings/v8/MainThreadDOMData.h: Removed. 32 * bindings/v8/V8DOMMap.cpp: 33 (WebCore::getDOMDataStore): 34 (WebCore::visitDOMNodes): 35 (WebCore::visitDOMObjects): 36 (WebCore::visitActiveDOMObjects): 37 (WebCore::visitDOMSVGElementInstances): 38 * bindings/v8/V8DOMMap.h: 39 * bindings/v8/V8GCController.cpp: 40 (WebCore::V8GCController::gcPrologue): 41 (WebCore::V8GCController::gcEpilogue): 42 * bindings/v8/WorkerScriptController.cpp: 43 (WebCore::WorkerScriptController::~WorkerScriptController): 44 1 45 2011-06-06 Nico Weber <thakis@chromium.org> 2 46 -
trunk/Source/WebCore/WebCore.gypi
r88192 r88221 1952 1952 'bindings/objc/PublicDOMInterfaces.h', 1953 1953 'bindings/objc/WebScriptObject.mm', 1954 'bindings/v8/ChildThreadDOMData.cpp',1955 'bindings/v8/ChildThreadDOMData.h',1956 1954 'bindings/v8/DOMData.cpp', 1957 1955 'bindings/v8/DOMData.h', … … 1969 1967 'bindings/v8/JavaScriptCallFrame.cpp', 1970 1968 'bindings/v8/JavaScriptCallFrame.h', 1971 'bindings/v8/MainThreadDOMData.cpp',1972 'bindings/v8/MainThreadDOMData.h',1973 1969 'bindings/v8/NPV8Object.cpp', 1974 1970 'bindings/v8/NPV8Object.h', -
trunk/Source/WebCore/bindings/v8/DOMData.cpp
r55882 r88221 31 31 #include "config.h" 32 32 #include "DOMData.h" 33 34 #include "ChildThreadDOMData.h" 35 #include "MainThreadDOMData.h" 33 #include "V8IsolatedContext.h" 36 34 #include "WebGLContextAttributes.h" 37 35 #include "WebGLUniformLocation.h" … … 40 38 41 39 DOMData::DOMData() 42 : m_ owningThread(WTF::currentThread())40 : m_defaultStore(this) 43 41 { 42 ASSERT(WTF::isMainThread()); 44 43 } 45 44 … … 50 49 DOMData* DOMData::getCurrent() 51 50 { 52 if (WTF::isMainThread()) 53 return MainThreadDOMData::getCurrent(); 51 ASSERT(WTF::isMainThread()); 52 DEFINE_STATIC_LOCAL(DOMData, mainThreadDOMData, ()); 53 return &mainThreadDOMData; 54 } 54 55 55 DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<ChildThreadDOMData>, childThreadDOMData, ()); 56 return childThreadDOMData; 56 DOMDataStore& DOMData::getMainThreadStore() 57 { 58 // This is broken out as a separate non-virtual method from getStore() 59 // so that it can be inlined by getCurrentMainThreadStore, which is 60 // a hot spot in Dromaeo DOM tests. 61 ASSERT(WTF::isMainThread()); 62 V8IsolatedContext* context = V8IsolatedContext::getEntered(); 63 if (UNLIKELY(context != 0)) 64 return *context->world()->domDataStore(); 65 return m_defaultStore; 57 66 } 58 67 … … 62 71 } 63 72 73 74 64 75 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/DOMData.h
r76248 r88221 33 33 34 34 #include "DOMDataStore.h" 35 #include "StaticDOMDataStore.h" 35 36 #include "V8DOMWrapper.h" 36 37 … … 51 52 52 53 static DOMData* getCurrent(); 53 virtual DOMDataStore& getStore() = 0;54 DOMDataStore& getStore() { return getMainThreadStore(); } 54 55 55 56 template<typename T> … … 59 60 static void removeObjectsFromWrapperMap(DOMDataStore* store, AbstractWeakReferenceMap<T, v8::Object>& domMap); 60 61 61 ThreadIdentifier owningThread() const { return m_owningThread; }62 static DOMDataStore& getCurrentMainThreadStore() { return getCurrent()->getMainThreadStore(); } 62 63 63 64 private: … … 75 76 }; 76 77 77 ThreadIdentifier m_owningThread; 78 DOMDataStore& getMainThreadStore(); 79 StaticDOMDataStore m_defaultStore; 78 80 }; 79 81 … … 81 83 void DOMData::handleWeakObject(DOMDataStore::DOMWrapperMapType mapType, v8::Persistent<v8::Object> v8Object, T* domObject) 82 84 { 85 ASSERT(WTF::isMainThread()); 83 86 WrapperTypeInfo* type = V8DOMWrapper::domWrapperType(v8Object); 84 87 DOMDataList& list = DOMDataStore::allStores(); … … 86 89 for (size_t i = 0; i < list.size(); ++i) { 87 90 DOMDataStore* store = list[i]; 88 ASSERT(store->domData()->owningThread() == WTF::currentThread());89 91 90 92 DOMWrapperMap<T>* domMap = static_cast<DOMWrapperMap<T>*>(store->getDOMWrapperMap(mapType)); -
trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp
r76541 r88221 62 62 // collector will remove these groups after each GC. 63 63 // 64 // DOM objects should be deref-ed from the owning thread, not the GC thread 65 // that does not own them. In V8, GC can kick in from any thread. To ensure 66 // that DOM objects are always deref-ed from the owning thread when running 67 // V8 in multi-threading environment, we do following: 68 // 1. Maintain a thread specific DOM wrapper map for each object map. 69 // (We're using TLS support from WTF instead of base since V8Bindings 70 // does not depend on base. We further assume that all child threads 71 // running V8 instances are created by WTF and thus a destructor will 72 // be called to clean up all thread specific data.) 73 // 2. When GC happens: 74 // 2.1. If the dead object is in GC thread's map, remove the JS reference 75 // and deref the DOM object. 76 // 2.2. Otherwise, go through all thread maps to find the owning thread. 77 // Remove the JS reference from the owning thread's map and move the 78 // DOM object to a delayed queue. Post a task to the owning thread 79 // to have it deref-ed from the owning thread at later time. 80 // 3. When a thread is tearing down, invoke a cleanup routine to go through 81 // all objects in the delayed queue and the thread map and deref all of 82 // them. 83 64 // DOM objects are accessed and deref-ed from the main thread. All V8 accesses 65 // to DOM objects happen on the main thread. 66 // When GC happens, we remove the JS reference and deref the DOM object. 84 67 85 68 DOMDataStore::DOMDataStore(DOMData* domData) … … 92 75 , m_domData(domData) 93 76 { 94 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());77 ASSERT(WTF::isMainThread()); 95 78 DOMDataStore::allStores().append(this); 96 79 } … … 98 81 DOMDataStore::~DOMDataStore() 99 82 { 100 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());83 ASSERT(WTF::isMainThread()); 101 84 DOMDataStore::allStores().remove(DOMDataStore::allStores().find(this)); 102 85 } … … 106 89 DEFINE_STATIC_LOCAL(DOMDataList, staticDOMDataList, ()); 107 90 return staticDOMDataList; 108 }109 110 WTF::Mutex& DOMDataStore::allStoresMutex()111 {112 DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMDataListMutex, ());113 return staticDOMDataListMutex;114 91 } 115 92 … … 157 134 v8::Persistent<v8::Object> v8Object = v8::Persistent<v8::Object>::Cast(value); 158 135 159 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());160 136 DOMDataList& list = DOMDataStore::allStores(); 161 137 for (size_t i = 0; i < list.size(); ++i) { 162 138 DOMDataStore* store = list[i]; 163 139 if (store->domNodeMap().removeIfPresent(node, v8Object)) { 164 ASSERT(store->domData()->owningThread() == WTF::currentThread());165 140 node->deref(); // Nobody overrides Node::deref so it's safe 166 141 return; // There might be at most one wrapper for the node in world's maps -
trunk/Source/WebCore/bindings/v8/DOMDataStore.h
r76541 r88221 78 78 // A list of all DOMDataStore objects in the current V8 instance (thread). Normally, each World has a DOMDataStore. 79 79 static DOMDataList& allStores(); 80 // Mutex to protect against concurrent access of DOMDataList.81 static WTF::Mutex& allStoresMutex();82 80 83 81 DOMData* domData() const { return m_domData; } -
trunk/Source/WebCore/bindings/v8/V8DOMMap.cpp
r84890 r88221 34 34 #include "DOMData.h" 35 35 #include "DOMDataStore.h" 36 #include "MainThreadDOMData.h"37 36 #include "ScopedDOMDataStore.h" 38 37 … … 52 51 static inline DOMDataStore& getDOMDataStore() 53 52 { 54 if (LIKELY(fasterDOMStoreAccess)) { 55 ASSERT(WTF::isMainThread()); 56 return MainThreadDOMData::getCurrentMainThreadStore(); 57 } 58 59 return DOMData::getCurrent()->getStore(); 53 ASSERT(WTF::isMainThread()); 54 return DOMData::getCurrentMainThreadStore(); 60 55 } 61 56 … … 113 108 } 114 109 115 void visitDOMNodes InCurrentThread(DOMWrapperMap<Node>::Visitor* visitor)110 void visitDOMNodes(DOMWrapperMap<Node>::Visitor* visitor) 116 111 { 117 112 v8::HandleScope scope; 118 113 119 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());114 ASSERT(WTF::isMainThread()); 120 115 DOMDataList& list = DOMDataStore::allStores(); 121 116 for (size_t i = 0; i < list.size(); ++i) { 122 117 DOMDataStore* store = list[i]; 123 if (!store->domData()->owningThread() == WTF::currentThread())124 continue;125 118 126 119 store->domNodeMap().visit(store, visitor); … … 128 121 } 129 122 130 void visitDOMObjects InCurrentThread(DOMWrapperMap<void>::Visitor* visitor)123 void visitDOMObjects(DOMWrapperMap<void>::Visitor* visitor) 131 124 { 132 125 v8::HandleScope scope; 133 126 134 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());127 ASSERT(WTF::isMainThread()); 135 128 DOMDataList& list = DOMDataStore::allStores(); 136 129 for (size_t i = 0; i < list.size(); ++i) { 137 130 DOMDataStore* store = list[i]; 138 if (!store->domData()->owningThread() == WTF::currentThread())139 continue;140 131 141 132 store->domObjectMap().visit(store, visitor); … … 143 134 } 144 135 145 void visitActiveDOMObjects InCurrentThread(DOMWrapperMap<void>::Visitor* visitor)136 void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor* visitor) 146 137 { 147 138 v8::HandleScope scope; 148 139 149 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());140 ASSERT(WTF::isMainThread()); 150 141 DOMDataList& list = DOMDataStore::allStores(); 151 142 for (size_t i = 0; i < list.size(); ++i) { 152 143 DOMDataStore* store = list[i]; 153 if (!store->domData()->owningThread() == WTF::currentThread())154 continue;155 144 156 145 store->activeDomObjectMap().visit(store, visitor); … … 160 149 #if ENABLE(SVG) 161 150 162 void visitDOMSVGElementInstances InCurrentThread(DOMWrapperMap<SVGElementInstance>::Visitor* visitor)151 void visitDOMSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor* visitor) 163 152 { 164 153 v8::HandleScope scope; 165 154 166 WTF::MutexLocker locker(DOMDataStore::allStoresMutex());155 ASSERT(WTF::isMainThread()); 167 156 DOMDataList& list = DOMDataStore::allStores(); 168 157 for (size_t i = 0; i < list.size(); ++i) { 169 158 DOMDataStore* store = list[i]; 170 if (!store->domData()->owningThread() == WTF::currentThread())171 continue;172 159 173 160 store->domSvgElementInstanceMap().visit(store, visitor); -
trunk/Source/WebCore/bindings/v8/V8DOMMap.h
r76104 r88221 159 159 // A map from DOM node to its JS wrapper. 160 160 DOMNodeMapping& getDOMNodeMap(); 161 void visitDOMNodes InCurrentThread(DOMWrapperMap<Node>::Visitor*);161 void visitDOMNodes(DOMWrapperMap<Node>::Visitor*); 162 162 163 163 // 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). 164 164 DOMWrapperMap<void>& getDOMObjectMap(); 165 void visitDOMObjects InCurrentThread(DOMWrapperMap<void>::Visitor*);165 void visitDOMObjects(DOMWrapperMap<void>::Visitor*); 166 166 167 167 // A map from a DOM object to its JS wrapper for DOM objects which can have pending activity. 168 168 DOMWrapperMap<void>& getActiveDOMObjectMap(); 169 void visitActiveDOMObjects InCurrentThread(DOMWrapperMap<void>::Visitor*);169 void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor*); 170 170 171 171 // This should be called to remove all DOM objects associated with the current thread when it is tearing down. 172 void removeAllDOMObjects InCurrentThread();172 void removeAllDOMObjects(); 173 173 174 174 #if ENABLE(SVG) 175 175 // A map for SVGElementInstances to its JS wrapper. 176 176 DOMWrapperMap<SVGElementInstance>& getDOMSVGElementInstanceMap(); 177 void visitSVGElementInstances InCurrentThread(DOMWrapperMap<SVGElementInstance>::Visitor*);177 void visitSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor*); 178 178 #endif 179 179 -
trunk/Source/WebCore/bindings/v8/V8GCController.cpp
r85673 r88221 459 459 // wrappers non weak if there is pending activity. 460 460 GCPrologueVisitor prologueVisitor; 461 visitActiveDOMObjects InCurrentThread(&prologueVisitor);461 visitActiveDOMObjects(&prologueVisitor); 462 462 463 463 // Create object groups. 464 464 GrouperVisitor grouperVisitor; 465 visitDOMNodes InCurrentThread(&grouperVisitor);466 visitDOMObjects InCurrentThread(&grouperVisitor);465 visitDOMNodes(&grouperVisitor); 466 visitDOMObjects(&grouperVisitor); 467 467 grouperVisitor.applyGrouping(); 468 468 … … 530 530 // again. 531 531 GCEpilogueVisitor epilogueVisitor; 532 visitActiveDOMObjects InCurrentThread(&epilogueVisitor);532 visitActiveDOMObjects(&epilogueVisitor); 533 533 534 534 workingSetEstimateMB = getActualMemoryUsageInMB(); … … 540 540 541 541 EnsureWeakDOMNodeVisitor weakDOMNodeVisitor; 542 visitDOMNodes InCurrentThread(&weakDOMNodeVisitor);542 visitDOMNodes(&weakDOMNodeVisitor); 543 543 544 544 enumerateGlobalHandles(); -
trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp
r84890 r88221 59 59 WorkerScriptController::~WorkerScriptController() 60 60 { 61 removeAllDOMObjects InCurrentThread();61 removeAllDOMObjects(); 62 62 } 63 63
Note: See TracChangeset
for help on using the changeset viewer.