Changeset 146734 in webkit
- Timestamp:
- Mar 24, 2013 3:45:36 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r146712 r146734 1 2013-03-23 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 HandleSet should use HeapBlocks for storing handles 4 https://bugs.webkit.org/show_bug.cgi?id=113145 5 6 Reviewed by Geoffrey Garen. 7 8 * GNUmakefile.list.am: Build project changes. 9 * JavaScriptCore.gypi: Ditto. 10 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto. 11 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: Ditto. 12 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: Ditto. 13 * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. 14 * heap/BlockAllocator.cpp: Rename the RegionSet to m_fourKBBlockRegionSet because there are 15 too many block types to include them all in the name now. 16 (JSC::BlockAllocator::BlockAllocator): 17 * heap/BlockAllocator.h: 18 (BlockAllocator): Add the appropriate override for regionSetFor. 19 (JSC::WeakBlock): 20 (JSC::MarkStackSegment): 21 (JSC::HandleBlock): 22 * heap/HandleBlock.h: Added. 23 (HandleBlock): New class for HandleBlocks. 24 (JSC::HandleBlock::blockFor): Static method to get the block of the given HandleNode pointer. Allows 25 us to quickly figure out which HandleSet the HandleNode belongs to without storing the pointer to it 26 in the HandleNode. 27 (JSC::HandleBlock::handleSet): Getter. 28 * heap/HandleBlockInlines.h: Added. 29 (JSC::HandleBlock::create): 30 (JSC::HandleBlock::HandleBlock): 31 (JSC::HandleBlock::payloadEnd): 32 (JSC::HandleBlock::payload): 33 (JSC::HandleBlock::nodes): 34 (JSC::HandleBlock::nodeAtIndex): 35 (JSC::HandleBlock::nodeCapacity): 36 * heap/HandleSet.cpp: 37 (JSC::HandleSet::~HandleSet): 38 (JSC::HandleSet::grow): 39 * heap/HandleSet.h: 40 (HandleNode): Move the internal Node class from HandleSet to be its own public class so it can be 41 used by HandleBlock. 42 (HandleSet): Add a typedef so that Node refers to the new HandleNode class. 43 (JSC::HandleSet::toHandle): 44 (JSC::HandleSet::toNode): 45 (JSC::HandleSet::allocate): 46 (JSC::HandleSet::deallocate): 47 (JSC::HandleNode::HandleNode): 48 (JSC::HandleNode::slot): 49 (JSC::HandleNode::handleSet): Use the new blockFor static function to get the right HandleBlock and lookup 50 the HandleSet. 51 (JSC::HandleNode::setPrev): 52 (JSC::HandleNode::prev): 53 (JSC::HandleNode::setNext): 54 (JSC::HandleNode::next): 55 (JSC::HandleSet::forEachStrongHandle): 56 * heap/Heap.h: Friend HandleSet so that it can access the BlockAllocator when allocating HandleBlocks. 57 1 58 2013-03-22 David Kilzer <ddkilzer@apple.com> 2 59 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r146494 r146734 312 312 Source/JavaScriptCore/heap/GCAssertions.h \ 313 313 Source/JavaScriptCore/heap/Handle.h \ 314 Source/JavaScriptCore/heap/HandleBlock.h \ 315 Source/JavaScriptCore/heap/HandleBlockInlines.h \ 314 316 Source/JavaScriptCore/heap/HandleSet.cpp \ 315 317 Source/JavaScriptCore/heap/HandleSet.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r146494 r146734 359 359 'heap/GCThreadSharedData.h', 360 360 'heap/Handle.h', 361 'heap/HandleBlock.h', 362 'heap/HandleBlockInlines.h', 361 363 'heap/HandleSet.cpp', 362 364 'heap/HandleSet.h', -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r146494 r146734 2655 2655 </File> 2656 2656 <File 2657 RelativePath="..\..\heap\HandleBlock.h" 2658 > 2659 </File> 2660 <File 2661 RelativePath="..\..\heap\HandleBlockInlines.h" 2662 > 2663 </File> 2664 <File 2657 2665 RelativePath="..\..\heap\HandleSet.cpp" 2658 2666 > -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r146530 r146734 508 508 <ClInclude Include="..\heap\GCThreadSharedData.h" /> 509 509 <ClInclude Include="..\heap\Handle.h" /> 510 <ClInclude Include="..\heap\HandleBlock.h" /> 511 <ClInclude Include="..\heap\HandleBlockInlines.h" /> 510 512 <ClInclude Include="..\heap\HandleSet.h" /> 511 513 <ClInclude Include="..\heap\HandleStack.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r146494 r146734 1071 1071 <Filter>heap</Filter> 1072 1072 </ClInclude> 1073 <ClInclude Include="..\heap\HandleBlock.h"> 1074 <Filter>heap</Filter> 1075 </ClInclude> 1076 <ClInclude Include="..\heap\HandleBlockInlines.h"> 1077 <Filter>heap</Filter> 1078 </ClInclude> 1073 1079 <ClInclude Include="..\heap\HandleSet.h"> 1074 1080 <Filter>heap</Filter> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r146682 r146734 838 838 C25F8BCD157544A900245B71 /* IncrementalSweeper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C25F8BCB157544A900245B71 /* IncrementalSweeper.cpp */; }; 839 839 C25F8BCE157544A900245B71 /* IncrementalSweeper.h in Headers */ = {isa = PBXBuildFile; fileRef = C25F8BCC157544A900245B71 /* IncrementalSweeper.h */; settings = {ATTRIBUTES = (Private, ); }; }; 840 C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C28318FF16FE4B7D00157BFD /* HandleBlock.h */; settings = {ATTRIBUTES = (Private, ); }; }; 841 C283190216FE533E00157BFD /* HandleBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C283190116FE533E00157BFD /* HandleBlockInlines.h */; }; 840 842 C2A7F688160432D400F76B98 /* JSDestructibleObject.h in Headers */ = {isa = PBXBuildFile; fileRef = C2A7F687160432D400F76B98 /* JSDestructibleObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 841 843 C2B916C214DA014E00CBAC86 /* MarkedAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1740 1742 C25F8BCB157544A900245B71 /* IncrementalSweeper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IncrementalSweeper.cpp; sourceTree = "<group>"; }; 1741 1743 C25F8BCC157544A900245B71 /* IncrementalSweeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncrementalSweeper.h; sourceTree = "<group>"; }; 1744 C28318FF16FE4B7D00157BFD /* HandleBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlock.h; sourceTree = "<group>"; }; 1745 C283190116FE533E00157BFD /* HandleBlockInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlockInlines.h; sourceTree = "<group>"; }; 1742 1746 C2A7F687160432D400F76B98 /* JSDestructibleObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDestructibleObject.h; sourceTree = "<group>"; }; 1743 1747 C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedAllocator.h; sourceTree = "<group>"; }; … … 2158 2162 0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */, 2159 2163 0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */, 2164 C28318FF16FE4B7D00157BFD /* HandleBlock.h */, 2165 C283190116FE533E00157BFD /* HandleBlockInlines.h */, 2160 2166 ); 2161 2167 path = heap; … … 2957 2963 0F63945515D07057006A597C /* ArrayProfile.h in Headers */, 2958 2964 BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */, 2965 C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */, 2959 2966 BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */, 2960 2967 86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */, … … 3374 3381 0F5F08CF146C7633000472A9 /* UnconditionalFinalizer.h in Headers */, 3375 3382 A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */, 3383 C283190216FE533E00157BFD /* HandleBlockInlines.h in Headers */, 3376 3384 0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */, 3377 3385 0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */, -
trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp
r140619 r146734 38 38 : m_copiedRegionSet(CopiedBlock::blockSize) 39 39 , m_markedRegionSet(MarkedBlock::blockSize) 40 , m_ weakAndMarkStackRegionSet(WeakBlock::blockSize)40 , m_fourKBBlockRegionSet(WeakBlock::blockSize) 41 41 , m_workListRegionSet(CopyWorkListSegment::blockSize) 42 42 , m_numberOfEmptyRegions(0) -
trunk/Source/JavaScriptCore/heap/BlockAllocator.h
r140594 r146734 39 39 class CopiedBlock; 40 40 class CopyWorkListSegment; 41 class HandleBlock; 41 42 class MarkStackSegment; 42 43 class MarkedBlock; … … 192 193 RegionSet m_markedRegionSet; 193 194 // WeakBlocks and MarkStackSegments use the same RegionSet since they're the same size. 194 RegionSet m_ weakAndMarkStackRegionSet;195 RegionSet m_fourKBBlockRegionSet; 195 196 RegionSet m_workListRegionSet; 196 197 … … 324 325 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<WeakBlock>() 325 326 { 326 return m_ weakAndMarkStackRegionSet;327 return m_fourKBBlockRegionSet; 327 328 } 328 329 … … 330 331 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<MarkStackSegment>() 331 332 { 332 return m_ weakAndMarkStackRegionSet;333 return m_fourKBBlockRegionSet; 333 334 } 334 335 … … 340 341 341 342 template <> 343 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HandleBlock>() 344 { 345 return m_fourKBBlockRegionSet; 346 } 347 348 template <> 342 349 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopiedBlock> >() 343 350 { … … 354 361 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<WeakBlock> >() 355 362 { 356 return m_ weakAndMarkStackRegionSet;363 return m_fourKBBlockRegionSet; 357 364 } 358 365 … … 360 367 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<MarkStackSegment> >() 361 368 { 362 return m_ weakAndMarkStackRegionSet;369 return m_fourKBBlockRegionSet; 363 370 } 364 371 … … 367 374 { 368 375 return m_workListRegionSet; 376 } 377 378 template <> 379 inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<HandleBlock> >() 380 { 381 return m_fourKBBlockRegionSet; 369 382 } 370 383 -
trunk/Source/JavaScriptCore/heap/HandleSet.cpp
r140584 r146734 27 27 #include "HandleSet.h" 28 28 29 #include "HandleBlock.h" 30 #include "HandleBlockInlines.h" 29 31 #include "HeapRootVisitor.h" 30 32 #include "JSObject.h" 31 33 #include "Operations.h" 34 #include <wtf/DataLog.h> 32 35 33 36 namespace JSC { … … 40 43 } 41 44 45 HandleSet::~HandleSet() 46 { 47 while (!m_blockList.isEmpty()) 48 m_globalData->heap.blockAllocator().deallocate(HandleBlock::destroy(m_blockList.removeHead())); 49 } 50 42 51 void HandleSet::grow() 43 52 { 44 Node* block = m_blockStack.grow(); 45 for (int i = m_blockStack.blockLength - 1; i >= 0; --i) { 46 Node* node = &block[i]; 47 new (NotNull, node) Node(this); 53 HandleBlock* newBlock = HandleBlock::create(m_globalData->heap.blockAllocator().allocate<HandleBlock>(), this); 54 m_blockList.append(newBlock); 55 56 for (int i = newBlock->nodeCapacity() - 1; i >= 0; --i) { 57 Node* node = newBlock->nodeAtIndex(i); 58 new (NotNull, node) Node; 48 59 m_freeList.push(node); 49 60 } -
trunk/Source/JavaScriptCore/heap/HandleSet.h
r140584 r146734 27 27 #define HandleSet_h 28 28 29 #include <wtf/BlockStack.h>30 29 #include "Handle.h" 30 #include "HandleBlock.h" 31 #include <wtf/DoublyLinkedList.h> 31 32 #include <wtf/HashCountedSet.h> 32 33 #include <wtf/SentinelLinkedList.h> … … 35 36 namespace JSC { 36 37 38 class HandleBlock; 37 39 class HandleSet; 38 40 class HeapRootVisitor; … … 41 43 class SlotVisitor; 42 44 45 class HandleNode { 46 public: 47 HandleNode(WTF::SentinelTag); 48 HandleNode(); 49 50 HandleSlot slot(); 51 HandleSet* handleSet(); 52 53 void setPrev(HandleNode*); 54 HandleNode* prev(); 55 56 void setNext(HandleNode*); 57 HandleNode* next(); 58 59 private: 60 JSValue m_value; 61 HandleNode* m_prev; 62 HandleNode* m_next; 63 }; 64 43 65 class HandleSet { 66 friend class HandleBlock; 44 67 public: 45 68 static HandleSet* heapFor(HandleSlot); 46 69 47 70 HandleSet(JSGlobalData*); 48 71 ~HandleSet(); 72 49 73 JSGlobalData* globalData(); 50 74 … … 61 85 62 86 private: 63 class Node { 64 public: 65 Node(WTF::SentinelTag); 66 Node(HandleSet*); 67 68 HandleSlot slot(); 69 HandleSet* handleSet(); 70 71 void setPrev(Node*); 72 Node* prev(); 73 74 void setNext(Node*); 75 Node* next(); 76 77 private: 78 JSValue m_value; 79 HandleSet* m_handleSet; 80 Node* m_prev; 81 Node* m_next; 82 }; 83 87 typedef HandleNode Node; 84 88 static HandleSlot toHandle(Node*); 85 89 static Node* toNode(HandleSlot); … … 92 96 93 97 JSGlobalData* m_globalData; 94 BlockStack<Node> m_blockStack;98 DoublyLinkedList<HandleBlock> m_blockList; 95 99 96 100 SentinelLinkedList<Node> m_strongList; … … 110 114 } 111 115 112 inline HandleSlot HandleSet::toHandle( Node* node)116 inline HandleSlot HandleSet::toHandle(HandleSet::Node* node) 113 117 { 114 118 return reinterpret_cast<HandleSlot>(node); … … 117 121 inline HandleSet::Node* HandleSet::toNode(HandleSlot handle) 118 122 { 119 return reinterpret_cast< Node*>(handle);123 return reinterpret_cast<HandleSet::Node*>(handle); 120 124 } 121 125 … … 129 133 grow(); 130 134 131 Node* node = m_freeList.pop();132 new (NotNull, node) Node(this);135 HandleSet::Node* node = m_freeList.pop(); 136 new (NotNull, node) HandleSet::Node(); 133 137 m_immediateList.push(node); 134 138 return toHandle(node); … … 137 141 inline void HandleSet::deallocate(HandleSlot handle) 138 142 { 139 Node* node = toNode(handle);143 HandleSet::Node* node = toNode(handle); 140 144 if (node == m_nextToFinalize) { 141 145 ASSERT(m_nextToFinalize->next()); … … 143 147 } 144 148 145 SentinelLinkedList< Node>::remove(node);149 SentinelLinkedList<HandleSet::Node>::remove(node); 146 150 m_freeList.push(node); 147 151 } 148 152 149 inline HandleSet::Node::Node(HandleSet* handleSet) 150 : m_handleSet(handleSet) 151 , m_prev(0) 153 inline HandleNode::HandleNode() 154 : m_prev(0) 152 155 , m_next(0) 153 156 { 154 157 } 155 158 156 inline HandleSet::Node::Node(WTF::SentinelTag) 157 : m_handleSet(0) 158 , m_prev(0) 159 inline HandleNode::HandleNode(WTF::SentinelTag) 160 : m_prev(0) 159 161 , m_next(0) 160 162 { 161 163 } 162 164 163 inline HandleSlot Handle Set::Node::slot()165 inline HandleSlot HandleNode::slot() 164 166 { 165 167 return &m_value; 166 168 } 167 169 168 inline HandleSet* Handle Set::Node::handleSet()169 { 170 return m_handleSet;171 } 172 173 inline void Handle Set::Node::setPrev(Node* prev)170 inline HandleSet* HandleNode::handleSet() 171 { 172 return HandleBlock::blockFor(this)->handleSet(); 173 } 174 175 inline void HandleNode::setPrev(HandleNode* prev) 174 176 { 175 177 m_prev = prev; 176 178 } 177 179 178 inline Handle Set::Node* HandleSet::Node::prev()180 inline HandleNode* HandleNode::prev() 179 181 { 180 182 return m_prev; 181 183 } 182 184 183 inline void Handle Set::Node::setNext(Node* next)185 inline void HandleNode::setNext(HandleNode* next) 184 186 { 185 187 m_next = next; 186 188 } 187 189 188 inline Handle Set::Node* HandleSet::Node::next()190 inline HandleNode* HandleNode::next() 189 191 { 190 192 return m_next; … … 193 195 template<typename Functor> void HandleSet::forEachStrongHandle(Functor& functor, const HashCountedSet<JSCell*>& skipSet) 194 196 { 195 Node* end = m_strongList.end();196 for ( Node* node = m_strongList.begin(); node != end; node = node->next()) {197 HandleSet::Node* end = m_strongList.end(); 198 for (HandleSet::Node* node = m_strongList.begin(); node != end; node = node->next()) { 197 199 JSValue value = *node->slot(); 198 200 if (!value || !value.isCell()) -
trunk/Source/JavaScriptCore/heap/Heap.h
r141192 r146734 181 181 friend class CopiedBlock; 182 182 friend class GCAwareJITStubRoutine; 183 friend class HandleSet; 183 184 friend class JITStubRoutine; 184 185 friend class LLIntOffsetsExtractor;
Note: See TracChangeset
for help on using the changeset viewer.