Changeset 113508 in webkit for trunk/Source/JavaScriptCore/heap
- Timestamp:
- Apr 6, 2012, 3:35:55 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore/heap
- Files:
-
- 7 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/Handle.h
r113141 r113508 49 49 class HandleBase { 50 50 template <typename T> friend class Weak; 51 friend class Handle Heap;51 friend class HandleSet; 52 52 friend struct JSCallbackObjectData; 53 53 template <typename KeyType, typename MappedType, typename FinalizerCallback, typename HashArg, typename KeyTraitsArg> friend class WeakGCMap; … … 134 134 135 135 private: 136 friend class Handle Heap;136 friend class HandleSet; 137 137 friend class WeakBlock; 138 138 -
trunk/Source/JavaScriptCore/heap/HandleSet.cpp
r113502 r113508 25 25 26 26 #include "config.h" 27 #include "Handle Heap.h"27 #include "HandleSet.h" 28 28 29 29 #include "HeapRootVisitor.h" … … 32 32 namespace JSC { 33 33 34 Handle Heap::HandleHeap(JSGlobalData* globalData)34 HandleSet::HandleSet(JSGlobalData* globalData) 35 35 : m_globalData(globalData) 36 36 , m_nextToFinalize(0) … … 39 39 } 40 40 41 void Handle Heap::grow()41 void HandleSet::grow() 42 42 { 43 43 Node* block = m_blockStack.grow(); … … 49 49 } 50 50 51 void Handle Heap::visitStrongHandles(HeapRootVisitor& heapRootVisitor)51 void HandleSet::visitStrongHandles(HeapRootVisitor& heapRootVisitor) 52 52 { 53 53 Node* end = m_strongList.end(); … … 61 61 } 62 62 63 void Handle Heap::writeBarrier(HandleSlot slot, const JSValue& value)63 void HandleSet::writeBarrier(HandleSlot slot, const JSValue& value) 64 64 { 65 65 // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants. … … 89 89 } 90 90 91 unsigned Handle Heap::protectedGlobalObjectCount()91 unsigned HandleSet::protectedGlobalObjectCount() 92 92 { 93 93 unsigned count = 0; … … 102 102 103 103 #if ENABLE(GC_VALIDATION) || !ASSERT_DISABLED 104 bool Handle Heap::isLiveNode(Node* node)104 bool HandleSet::isLiveNode(Node* node) 105 105 { 106 106 if (node->prev()->next() != node) -
trunk/Source/JavaScriptCore/heap/HandleSet.h
r113502 r113508 24 24 */ 25 25 26 #ifndef Handle Heap_h27 #define Handle Heap_h26 #ifndef HandleSet_h 27 #define HandleSet_h 28 28 29 29 #include <wtf/BlockStack.h> … … 35 35 namespace JSC { 36 36 37 class Handle Heap;37 class HandleSet; 38 38 class HeapRootVisitor; 39 39 class JSGlobalData; … … 41 41 class SlotVisitor; 42 42 43 class Handle Heap{43 class HandleSet { 44 44 public: 45 static Handle Heap* heapFor(HandleSlot);46 47 Handle Heap(JSGlobalData*);45 static HandleSet* heapFor(HandleSlot); 46 47 HandleSet(JSGlobalData*); 48 48 49 49 JSGlobalData* globalData(); … … 64 64 public: 65 65 Node(WTF::SentinelTag); 66 Node(Handle Heap*);66 Node(HandleSet*); 67 67 68 68 HandleSlot slot(); 69 Handle Heap* handleHeap();69 HandleSet* handleSet(); 70 70 71 71 void setPrev(Node*); … … 77 77 private: 78 78 JSValue m_value; 79 Handle Heap* m_handleHeap;79 HandleSet* m_handleSet; 80 80 Node* m_prev; 81 81 Node* m_next; … … 100 100 }; 101 101 102 inline Handle Heap* HandleHeap::heapFor(HandleSlot handle)103 { 104 return toNode(handle)->handle Heap();105 } 106 107 inline JSGlobalData* Handle Heap::globalData()102 inline HandleSet* HandleSet::heapFor(HandleSlot handle) 103 { 104 return toNode(handle)->handleSet(); 105 } 106 107 inline JSGlobalData* HandleSet::globalData() 108 108 { 109 109 return m_globalData; 110 110 } 111 111 112 inline HandleSlot Handle Heap::toHandle(Node* node)112 inline HandleSlot HandleSet::toHandle(Node* node) 113 113 { 114 114 return reinterpret_cast<HandleSlot>(node); 115 115 } 116 116 117 inline Handle Heap::Node* HandleHeap::toNode(HandleSlot handle)117 inline HandleSet::Node* HandleSet::toNode(HandleSlot handle) 118 118 { 119 119 return reinterpret_cast<Node*>(handle); 120 120 } 121 121 122 inline HandleSlot Handle Heap::allocate()122 inline HandleSlot HandleSet::allocate() 123 123 { 124 124 // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants. … … 135 135 } 136 136 137 inline void Handle Heap::deallocate(HandleSlot handle)137 inline void HandleSet::deallocate(HandleSlot handle) 138 138 { 139 139 Node* node = toNode(handle); … … 147 147 } 148 148 149 inline Handle Heap::Node::Node(HandleHeap* handleHeap)150 : m_handle Heap(handleHeap)149 inline HandleSet::Node::Node(HandleSet* handleSet) 150 : m_handleSet(handleSet) 151 151 , m_prev(0) 152 152 , m_next(0) … … 154 154 } 155 155 156 inline Handle Heap::Node::Node(WTF::SentinelTag)157 : m_handle Heap(0)156 inline HandleSet::Node::Node(WTF::SentinelTag) 157 : m_handleSet(0) 158 158 , m_prev(0) 159 159 , m_next(0) … … 161 161 } 162 162 163 inline HandleSlot Handle Heap::Node::slot()163 inline HandleSlot HandleSet::Node::slot() 164 164 { 165 165 return &m_value; 166 166 } 167 167 168 inline Handle Heap* HandleHeap::Node::handleHeap()169 { 170 return m_handle Heap;171 } 172 173 inline void Handle Heap::Node::setPrev(Node* prev)168 inline HandleSet* HandleSet::Node::handleSet() 169 { 170 return m_handleSet; 171 } 172 173 inline void HandleSet::Node::setPrev(Node* prev) 174 174 { 175 175 m_prev = prev; 176 176 } 177 177 178 inline Handle Heap::Node* HandleHeap::Node::prev()178 inline HandleSet::Node* HandleSet::Node::prev() 179 179 { 180 180 return m_prev; 181 181 } 182 182 183 inline void Handle Heap::Node::setNext(Node* next)183 inline void HandleSet::Node::setNext(Node* next) 184 184 { 185 185 m_next = next; 186 186 } 187 187 188 inline Handle Heap::Node* HandleHeap::Node::next()188 inline HandleSet::Node* HandleSet::Node::next() 189 189 { 190 190 return m_next; 191 191 } 192 192 193 template<typename Functor> void Handle Heap::forEachStrongHandle(Functor& functor, const HashCountedSet<JSCell*>& skipSet)193 template<typename Functor> void HandleSet::forEachStrongHandle(Functor& functor, const HashCountedSet<JSCell*>& skipSet) 194 194 { 195 195 Node* end = m_strongList.end(); -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r113445 r113508 324 324 , m_sharedData(globalData) 325 325 , m_slotVisitor(m_sharedData) 326 , m_weak Heap(this)327 , m_handle Heap(globalData)326 , m_weakSet(this) 327 , m_handleSet(globalData) 328 328 , m_isSafeToCollect(false) 329 329 , m_globalData(globalData) … … 376 376 clearMarks(); 377 377 378 m_weak Heap.finalizeAll();378 m_weakSet.finalizeAll(); 379 379 m_globalData->smallStrings.finalizeSmallStrings(); 380 380 shrink(); … … 661 661 { 662 662 GCPHASE(VisitStrongHandles); 663 m_handle Heap.visitStrongHandles(heapRootVisitor);663 m_handleSet.visitStrongHandles(heapRootVisitor); 664 664 visitor.donateAndDrain(); 665 665 } … … 690 690 GCPHASE(VisitingLiveWeakHandles); 691 691 while (true) { 692 m_weak Heap.visitLiveWeakImpls(heapRootVisitor);692 m_weakSet.visitLiveWeakImpls(heapRootVisitor); 693 693 harvestWeakReferences(); 694 694 if (visitor.isEmpty()) … … 706 706 { 707 707 GCPHASE(VisitingDeadWeakHandles); 708 m_weak Heap.visitDeadWeakImpls(heapRootVisitor);708 m_weakSet.visitDeadWeakImpls(heapRootVisitor); 709 709 } 710 710 … … 819 819 { 820 820 GCPHASE(FinalizeWeakHandles); 821 m_weak Heap.sweep();821 m_weakSet.sweep(); 822 822 m_globalData->smallStrings.finalizeSmallStrings(); 823 823 } … … 867 867 { 868 868 m_objectSpace.resetAllocators(); 869 m_weak Heap.resetAllocator();869 m_weakSet.resetAllocator(); 870 870 } 871 871 … … 928 928 void Heap::addFinalizer(JSCell* cell, Finalizer finalizer) 929 929 { 930 weak Heap()->allocate(cell, &m_finalizerOwner, reinterpret_cast<void*>(finalizer)); // Balanced by FinalizerOwner::finalize().930 weakSet()->allocate(cell, &m_finalizerOwner, reinterpret_cast<void*>(finalizer)); // Balanced by FinalizerOwner::finalize(). 931 931 } 932 932 … … 936 936 Finalizer finalizer = reinterpret_cast<Finalizer>(context); 937 937 finalizer(slot->asCell()); 938 Weak Heap::deallocate(WeakImpl::asWeakImpl(slot));938 WeakSet::deallocate(WeakImpl::asWeakImpl(slot)); 939 939 } 940 940 -
trunk/Source/JavaScriptCore/heap/Heap.h
r113445 r113508 24 24 25 25 #include "DFGCodeBlocks.h" 26 #include "Handle Heap.h"26 #include "HandleSet.h" 27 27 #include "HandleStack.h" 28 28 #include "MarkedAllocator.h" … … 32 32 #include "SlotVisitor.h" 33 33 #include "WeakHandleOwner.h" 34 #include "Weak Heap.h"34 #include "WeakSet.h" 35 35 #include "WriteBarrierSupport.h" 36 36 #include <wtf/DoublyLinkedList.h> … … 139 139 template<typename Functor> typename Functor::ReturnType forEachProtectedCell(); 140 140 141 Weak Heap* weakHeap() { return &m_weakHeap; }142 Handle Heap* handleHeap() { return &m_handleHeap; }141 WeakSet* weakSet() { return &m_weakSet; } 142 HandleSet* handleSet() { return &m_handleSet; } 143 143 HandleStack* handleStack() { return &m_handleStack; } 144 144 … … 238 238 SlotVisitor m_slotVisitor; 239 239 240 Weak Heap m_weakHeap;241 Handle Heap m_handleHeap;240 WeakSet m_weakSet; 241 HandleSet m_handleSet; 242 242 HandleStack m_handleStack; 243 243 DFGCodeBlocks m_dfgCodeBlocks; … … 356 356 for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it) 357 357 functor(it->first); 358 m_handle Heap.forEachStrongHandle(functor, m_protectedValues);358 m_handleSet.forEachStrongHandle(functor, m_protectedValues); 359 359 360 360 return functor.returnValue(); -
trunk/Source/JavaScriptCore/heap/PassWeak.h
r113209 r113508 148 148 149 149 template<typename T> inline PassWeak<T>::PassWeak(JSGlobalData& globalData, typename PassWeak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context) 150 : m_impl(globalData.heap.weak Heap()->allocate(getType, weakOwner, context))150 : m_impl(globalData.heap.weakSet()->allocate(getType, weakOwner, context)) 151 151 { 152 152 } … … 166 166 if (!m_impl) 167 167 return; 168 Weak Heap::deallocate(m_impl);168 WeakSet::deallocate(m_impl); 169 169 } 170 170 -
trunk/Source/JavaScriptCore/heap/Strong.h
r113141 r113508 29 29 #include <wtf/Assertions.h> 30 30 #include "Handle.h" 31 #include "Handle Heap.h"31 #include "HandleSet.h" 32 32 33 33 namespace JSC { … … 57 57 if (!other.slot()) 58 58 return; 59 setSlot(Handle Heap::heapFor(other.slot())->allocate());59 setSlot(HandleSet::heapFor(other.slot())->allocate()); 60 60 set(other.get()); 61 61 } … … 66 66 if (!other.slot()) 67 67 return; 68 setSlot(Handle Heap::heapFor(other.slot())->allocate());68 setSlot(HandleSet::heapFor(other.slot())->allocate()); 69 69 set(other.get()); 70 70 } … … 104 104 } 105 105 106 set(*Handle Heap::heapFor(other.slot())->globalData(), other.get());106 set(*HandleSet::heapFor(other.slot())->globalData(), other.get()); 107 107 return *this; 108 108 } … … 115 115 } 116 116 117 set(*Handle Heap::heapFor(other.slot())->globalData(), other.get());117 set(*HandleSet::heapFor(other.slot())->globalData(), other.get()); 118 118 return *this; 119 119 } … … 123 123 if (!slot()) 124 124 return; 125 Handle Heap::heapFor(slot())->deallocate(slot());125 HandleSet::heapFor(slot())->deallocate(slot()); 126 126 setSlot(0); 127 127 } … … 134 134 ASSERT(slot()); 135 135 JSValue value = HandleTypes<T>::toJSValue(externalType); 136 Handle Heap::heapFor(slot())->writeBarrier(slot(), value);136 HandleSet::heapFor(slot())->writeBarrier(slot(), value); 137 137 *slot() = value; 138 138 } -
trunk/Source/JavaScriptCore/heap/StrongInlines.h
r96465 r113508 31 31 template <typename T> 32 32 inline Strong<T>::Strong(JSGlobalData& globalData, ExternalType value) 33 : Handle<T>(globalData.heap.handle Heap()->allocate())33 : Handle<T>(globalData.heap.handleSet()->allocate()) 34 34 { 35 35 set(value); … … 38 38 template <typename T> 39 39 inline Strong<T>::Strong(JSGlobalData& globalData, Handle<T> handle) 40 : Handle<T>(globalData.heap.handle Heap()->allocate())40 : Handle<T>(globalData.heap.handleSet()->allocate()) 41 41 { 42 42 set(handle.get()); … … 47 47 { 48 48 if (!slot()) 49 setSlot(globalData.heap.handle Heap()->allocate());49 setSlot(globalData.heap.handleSet()->allocate()); 50 50 set(value); 51 51 } -
trunk/Source/JavaScriptCore/heap/Weak.h
r113141 r113508 80 80 81 81 template<typename T> inline Weak<T>::Weak(JSGlobalData& globalData, typename Weak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context) 82 : m_impl(globalData.heap.weak Heap()->allocate(getType, weakOwner, context))82 : m_impl(globalData.heap.weakSet()->allocate(getType, weakOwner, context)) 83 83 { 84 84 } … … 142 142 if (!m_impl) 143 143 return; 144 Weak Heap::deallocate(m_impl);144 WeakSet::deallocate(m_impl); 145 145 m_impl = 0; 146 146 } -
trunk/Source/JavaScriptCore/heap/WeakSet.cpp
r113502 r113508 25 25 26 26 #include "config.h" 27 #include "Weak Heap.h"27 #include "WeakSet.h" 28 28 29 29 #include "Heap.h" … … 31 31 namespace JSC { 32 32 33 Weak Heap::~WeakHeap()33 WeakSet::~WeakSet() 34 34 { 35 35 WeakBlock* next = 0; … … 41 41 } 42 42 43 void Weak Heap::finalizeAll()43 void WeakSet::finalizeAll() 44 44 { 45 45 for (WeakBlock* block = static_cast<WeakBlock*>(m_blocks.head()); block; block = static_cast<WeakBlock*>(block->next())) … … 47 47 } 48 48 49 void Weak Heap::visitLiveWeakImpls(HeapRootVisitor& visitor)49 void WeakSet::visitLiveWeakImpls(HeapRootVisitor& visitor) 50 50 { 51 51 for (WeakBlock* block = static_cast<WeakBlock*>(m_blocks.head()); block; block = static_cast<WeakBlock*>(block->next())) … … 53 53 } 54 54 55 void Weak Heap::visitDeadWeakImpls(HeapRootVisitor& visitor)55 void WeakSet::visitDeadWeakImpls(HeapRootVisitor& visitor) 56 56 { 57 57 for (WeakBlock* block = static_cast<WeakBlock*>(m_blocks.head()); block; block = static_cast<WeakBlock*>(block->next())) … … 59 59 } 60 60 61 void Weak Heap::sweep()61 void WeakSet::sweep() 62 62 { 63 63 WeakBlock* next; … … 74 74 } 75 75 76 void Weak Heap::resetAllocator()76 void WeakSet::resetAllocator() 77 77 { 78 78 m_allocator = 0; … … 80 80 } 81 81 82 WeakBlock::FreeCell* Weak Heap::findAllocator()82 WeakBlock::FreeCell* WeakSet::findAllocator() 83 83 { 84 84 if (WeakBlock::FreeCell* allocator = tryFindAllocator()) … … 94 94 } 95 95 96 WeakBlock::FreeCell* Weak Heap::tryFindAllocator()96 WeakBlock::FreeCell* WeakSet::tryFindAllocator() 97 97 { 98 98 while (m_nextAllocator) { … … 109 109 } 110 110 111 WeakBlock::FreeCell* Weak Heap::addAllocator()111 WeakBlock::FreeCell* WeakSet::addAllocator() 112 112 { 113 113 WeakBlock* block = WeakBlock::create(); … … 118 118 } 119 119 120 void Weak Heap::removeAllocator(WeakBlock* block)120 void WeakSet::removeAllocator(WeakBlock* block) 121 121 { 122 122 m_blocks.remove(block); -
trunk/Source/JavaScriptCore/heap/WeakSet.h
r113502 r113508 24 24 */ 25 25 26 #ifndef Weak Heap_h27 #define Weak Heap_h26 #ifndef WeakSet_h 27 #define WeakSet_h 28 28 29 29 #include "WeakBlock.h" … … 34 34 class WeakImpl; 35 35 36 class Weak Heap{36 class WeakSet { 37 37 public: 38 Weak Heap(Heap*);38 WeakSet(Heap*); 39 39 void finalizeAll(); 40 ~Weak Heap();40 ~WeakSet(); 41 41 42 42 WeakImpl* allocate(JSValue, WeakHandleOwner* = 0, void* context = 0); … … 61 61 }; 62 62 63 inline Weak Heap::WeakHeap(Heap* heap)63 inline WeakSet::WeakSet(Heap* heap) 64 64 : m_allocator(0) 65 65 , m_nextAllocator(0) … … 68 68 } 69 69 70 inline WeakImpl* Weak Heap::allocate(JSValue jsValue, WeakHandleOwner* weakHandleOwner, void* context)70 inline WeakImpl* WeakSet::allocate(JSValue jsValue, WeakHandleOwner* weakHandleOwner, void* context) 71 71 { 72 72 WeakBlock::FreeCell* allocator = m_allocator; … … 79 79 } 80 80 81 inline void Weak Heap::deallocate(WeakImpl* weakImpl)81 inline void WeakSet::deallocate(WeakImpl* weakImpl) 82 82 { 83 83 WeakBlock::blockFor(weakImpl)->deallocate(weakImpl); … … 86 86 } // namespace JSC 87 87 88 #endif // Weak Heap_h88 #endif // WeakSet_h
Note:
See TracChangeset
for help on using the changeset viewer.