Changeset 83011 in webkit
- Timestamp:
- Apr 5, 2011 8:44:48 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r82988 r83011 1 2011-04-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Introduced the concept of opaque roots, in preparation for marking the DOM with them 6 https://bugs.webkit.org/show_bug.cgi?id=57903 7 8 * JavaScriptCore.exp: Who likes export files? I do! 9 10 * collector/handles/HandleHeap.cpp: 11 (JSC::isValidWeakHandle): Factored out a helper function for ASSERTs. 12 13 (JSC::WeakHandleOwner::~WeakHandleOwner): Moved from header to avoid 14 weak linkage problems. 15 16 (JSC::WeakHandleOwner::isReachableFromOpaqueRoots): New callback. 17 Currently unused. 18 19 (JSC::WeakHandleOwner::finalize): Switched from pure virtual to a 20 default empty implementation, since not all clients necessarily want 21 or need non-trivial finalizers. 22 23 (JSC::HandleHeap::markWeakHandles): Split updateWeakHandles into two 24 passes. The first pass marks all reachable weak handles. The second pass 25 finalizes all unreachable weak handles. This must be two passes because 26 we don't know the set of finalizable weak handles until we're done 27 marking all weak handles. 28 29 (JSC::HandleHeap::finalizeWeakHandles): Use new helper function. 30 31 * collector/handles/HandleHeap.h: Ditto. 32 33 * runtime/Heap.cpp: 34 (JSC::Heap::destroy): 35 (JSC::Heap::markRoots): 36 (JSC::Heap::reset): Split out handle marking from handle finalization. 37 38 * runtime/MarkStack.cpp: 39 (JSC::MarkStack::reset): 40 * runtime/MarkStack.h: 41 (JSC::MarkStack::addOpaqueRoot): 42 (JSC::MarkStack::containsOpaqueRoot): 43 (JSC::MarkStack::opaqueRootCount): 44 (JSC::HeapRootMarker::markStack): New helper functions for managing the 45 set of opaque roots. 46 47 * runtime/WeakGCMap.h: 48 (JSC::WeakGCMap::finalize): Renamed to match parent class declaration. 49 1 50 2011-04-05 Balazs Kelemen <kbalazs@webkit.org> 2 51 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r82905 r83011 170 170 __ZN3JSC14throwTypeErrorEPNS_9ExecStateE 171 171 __ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE 172 __ZN3JSC15WeakHandleOwner26isReachableFromOpaqueRootsENS_6HandleINS_7UnknownEEEPvRNS_9MarkStackE 173 __ZN3JSC15WeakHandleOwnerD2Ev 172 174 __ZN3JSC15createTypeErrorEPNS_9ExecStateERKNS_7UStringE 173 175 __ZN3JSC16InternalFunction12vtableAnchorEv … … 385 387 __ZN3WTF12isMainThreadEv 386 388 __ZN3WTF12randomNumberEv 387 __ZN3WTF13StringBuilder15reserveCapacityEj388 389 __ZN3WTF13StringBuilder11reifyStringEv 389 390 __ZN3WTF13StringBuilder11shrinkToFitEv 391 __ZN3WTF13StringBuilder15reserveCapacityEj 390 392 __ZN3WTF13StringBuilder6appendEPKcj 391 393 __ZN3WTF13StringBuilder6appendEPKtj … … 597 599 __ZTVN3JSC14ScopeChainNodeE 598 600 __ZTVN3JSC15JSWrapperObjectE 601 __ZTVN3JSC15WeakHandleOwnerE 599 602 __ZTVN3JSC16InternalFunctionE 600 603 __ZTVN3JSC16JSVariableObjectE -
trunk/Source/JavaScriptCore/collector/handles/HandleHeap.cpp
r82875 r83011 25 25 26 26 #include "config.h" 27 28 27 #include "HandleHeap.h" 29 28 … … 31 30 32 31 namespace JSC { 32 33 #if !ASSERT_DISABLED 34 static inline bool isValidWeakHandle(HandleSlot handle) 35 { 36 JSValue value = *handle; 37 if (!value || !value.isCell()) 38 return false; 39 40 JSCell* cell = value.asCell(); 41 if (!cell || !cell->structure()) 42 return false; 43 44 #if ENABLE(JSC_ZOMBIES) 45 if (cell->isZombie()) 46 return false; 47 #endif 48 49 return true; 50 } 51 #endif 52 53 WeakHandleOwner::~WeakHandleOwner() 54 { 55 } 56 57 bool WeakHandleOwner::isReachableFromOpaqueRoots(Handle<Unknown>, void*, MarkStack&) 58 { 59 return false; 60 } 61 62 void WeakHandleOwner::finalize(Handle<Unknown>, void*) 63 { 64 } 33 65 34 66 HandleHeap::HandleHeap(JSGlobalData* globalData) … … 56 88 } 57 89 58 void HandleHeap::updateWeakHandles() 90 void HandleHeap::markWeakHandles(HeapRootMarker& heapRootMarker) 91 { 92 MarkStack& markStack = heapRootMarker.markStack(); 93 94 int oldCount; 95 do { 96 oldCount = markStack.opaqueRootCount(); 97 98 Node* end = m_weakList.end(); 99 for (Node* node = m_weakList.begin(); node != end; node = node->next()) { 100 ASSERT(isValidWeakHandle(node->slot())); 101 JSCell* cell = node->slot()->asCell(); 102 if (Heap::isMarked(cell)) 103 continue; 104 105 WeakHandleOwner* weakOwner = node->weakOwner(); 106 if (!weakOwner) 107 continue; 108 109 if (!weakOwner->isReachableFromOpaqueRoots(Handle<Unknown>::wrapSlot(node->slot()), node->weakOwnerContext(), markStack)) 110 continue; 111 112 heapRootMarker.mark(node->slot()); 113 } 114 } while (oldCount != markStack.opaqueRootCount()); // If the set of opaque roots has grown, more handles may have become reachable. 115 } 116 117 void HandleHeap::finalizeWeakHandles() 59 118 { 60 119 Node* end = m_weakList.end(); … … 62 121 m_nextToFinalize = node->next(); 63 122 64 JSValue value = *node->slot(); 65 ASSERT(value); 66 67 JSCell* cell = value.asCell(); 68 ASSERT(cell && cell->structure()); 69 #if ENABLE(JSC_ZOMBIES) 70 ASSERT(!cell->isZombie()); 71 #endif 72 123 ASSERT(isValidWeakHandle(node->slot())); 124 JSCell* cell = node->slot()->asCell(); 73 125 if (Heap::isMarked(cell)) 74 126 continue; -
trunk/Source/JavaScriptCore/collector/handles/HandleHeap.h
r82875 r83011 35 35 36 36 class HandleHeap; 37 class HeapRootMarker; 37 38 class JSGlobalData; 38 39 class JSValue; 39 class HeapRootMarker;40 class MarkStack; 40 41 41 42 class WeakHandleOwner { 42 43 public: 43 virtual void finalize(Handle<Unknown>, void*) = 0; 44 virtual ~WeakHandleOwner() {} 44 virtual ~WeakHandleOwner(); 45 virtual bool isReachableFromOpaqueRoots(Handle<Unknown>, void* context, MarkStack&); 46 virtual void finalize(Handle<Unknown>, void* context); 45 47 }; 46 48 … … 57 59 58 60 void markStrongHandles(HeapRootMarker&); 59 void updateWeakHandles(); 61 void markWeakHandles(HeapRootMarker&); 62 void finalizeWeakHandles(); 60 63 61 64 void writeBarrier(HandleSlot, const JSValue&); -
trunk/Source/JavaScriptCore/runtime/Heap.cpp
r82971 r83011 83 83 m_markListSet = 0; 84 84 m_markedSpace.clearMarks(); 85 m_handleHeap. updateWeakHandles();85 m_handleHeap.finalizeWeakHandles(); 86 86 m_markedSpace.destroy(); 87 87 … … 243 243 m_handleStack.mark(heapRootMarker); 244 244 245 m_handleHeap.markWeakHandles(heapRootMarker); 246 markStack.drain(); 247 245 248 // Mark the small strings cache last, since it will clear itself if nothing 246 249 // else has marked it. 247 250 m_globalData->smallStrings.markChildren(heapRootMarker); 248 249 markStack.drain(); 250 markStack.compact(); 251 252 m_handleHeap.updateWeakHandles(); 251 markStack.drain(); 252 253 markStack.reset(); 253 254 254 255 m_operationInProgress = NoOperation; … … 370 371 371 372 markRoots(); 373 m_handleHeap.finalizeWeakHandles(); 372 374 373 375 JAVASCRIPTCORE_GC_MARKED(); -
trunk/Source/JavaScriptCore/runtime/MarkStack.cpp
r81262 r83011 39 39 size_t MarkStack::s_pageSize = 0; 40 40 41 void MarkStack:: compact()41 void MarkStack::reset() 42 42 { 43 43 ASSERT(s_pageSize); 44 44 m_values.shrinkAllocation(s_pageSize); 45 45 m_markSets.shrinkAllocation(s_pageSize); 46 m_opaqueRoots.clear(); 46 47 } 47 48 -
trunk/Source/JavaScriptCore/runtime/MarkStack.h
r82849 r83011 30 30 #include "Register.h" 31 31 #include "WriteBarrier.h" 32 #include <wtf/HashSet.h> 32 33 #include <wtf/Vector.h> 33 34 #include <wtf/Noncopyable.h> … … 82 83 void append(ConservativeRoots&); 83 84 85 bool addOpaqueRoot(void* root) { return m_opaqueRoots.add(root).second; } 86 bool containsOpaqueRoot(void* root) { return m_opaqueRoots.contains(root); } 87 int opaqueRootCount() { return m_opaqueRoots.size(); } 88 84 89 void drain(); 85 void compact();90 void reset(); 86 91 87 92 private: … … 199 204 MarkStackArray<JSCell*> m_values; 200 205 static size_t s_pageSize; 206 HashSet<void*> m_opaqueRoots; // Handle-owning data structures not visible to the garbage collector. 201 207 202 208 #if !ASSERT_DISABLED … … 275 281 void mark(JSString**); 276 282 void mark(JSCell**); 283 284 MarkStack& markStack(); 277 285 278 286 private: … … 305 313 } 306 314 315 inline MarkStack& HeapRootMarker::markStack() 316 { 317 return m_markStack; 318 } 319 307 320 } // namespace JSC 308 321 -
trunk/Source/JavaScriptCore/runtime/WeakGCMap.h
r82866 r83011 123 123 124 124 private: 125 virtual void finalize(Handle<Unknown>, void* key)125 virtual void finalize(Handle<Unknown>, void* context) 126 126 { 127 HandleSlot slot = m_map.take(static_cast<KeyType>( key));127 HandleSlot slot = m_map.take(static_cast<KeyType>(context)); 128 128 ASSERT(slot); 129 129 HandleHeap::heapFor(slot)->deallocate(slot);
Note: See TracChangeset
for help on using the changeset viewer.