Changeset 147282 in webkit
- Timestamp:
- Mar 30, 2013 12:01:51 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r147252 r147282 1 2013-03-30 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Move Region into its own header 4 https://bugs.webkit.org/show_bug.cgi?id=113617 5 6 Reviewed by Geoffrey Garen. 7 8 BlockAllocator.h is getting a little crowded. We should move the Region class into its own 9 header, since it's pretty independent from the BlockAllocator. 10 11 * GNUmakefile.list.am: 12 * JavaScriptCore.gypi: 13 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 14 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 15 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * heap/BlockAllocator.h: 18 (JSC): 19 * heap/Region.h: Added. 20 (JSC): 21 (DeadBlock): 22 (JSC::DeadBlock::DeadBlock): 23 (Region): 24 (JSC::Region::blockSize): 25 (JSC::Region::isFull): 26 (JSC::Region::isEmpty): 27 (JSC::Region::isCustomSize): 28 (JSC::Region::create): 29 (JSC::Region::createCustomSize): 30 (JSC::Region::Region): 31 (JSC::Region::~Region): 32 (JSC::Region::reset): 33 (JSC::Region::allocate): 34 (JSC::Region::deallocate): 35 1 36 2013-03-29 Mark Hahnenberg <mhahnenberg@apple.com> 2 37 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r146734 r147282 357 357 Source/JavaScriptCore/heap/MarkedSpace.h \ 358 358 Source/JavaScriptCore/heap/PassWeak.h \ 359 Source/JavaScriptCore/heap/Region.h \ 359 360 Source/JavaScriptCore/heap/Strong.h \ 360 361 Source/JavaScriptCore/heap/StrongInlines.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r146734 r147282 394 394 'heap/MarkStackInlines.h', 395 395 'heap/PassWeak.h', 396 'heap/Region.h', 396 397 'heap/SlotVisitor.cpp', 397 398 'heap/SlotVisitor.h', -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r146734 r147282 2779 2779 </File> 2780 2780 <File 2781 RelativePath="..\..\heap\Region.h" 2782 > 2783 </File> 2784 <File 2781 2785 RelativePath="..\..\heap\SlotVisitor.cpp" 2782 2786 > -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r146734 r147282 531 531 <ClInclude Include="..\heap\MarkStackInlines.h" /> 532 532 <ClInclude Include="..\heap\PassWeak.h" /> 533 <ClInclude Include="..\heap\Region.h" /> 533 534 <ClInclude Include="..\heap\SlotVisitor.h" /> 534 535 <ClInclude Include="..\heap\SlotVisitorInlines.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r146734 r147282 1140 1140 <Filter>heap</Filter> 1141 1141 </ClInclude> 1142 <ClInclude Include="..\heap\Region.h"> 1143 <Filter>heap</Filter> 1144 </ClInclude> 1142 1145 <ClInclude Include="..\heap\SlotVisitor.h"> 1143 1146 <Filter>heap</Filter> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r146734 r147282 818 818 BCFD8C920EEB2EE700283848 /* JumpTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCFD8C900EEB2EE700283848 /* JumpTable.cpp */; }; 819 819 BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFD8C910EEB2EE700283848 /* JumpTable.h */; settings = {ATTRIBUTES = (Private, ); }; }; 820 C20B25991706536200C21F4E /* Region.h in Headers */ = {isa = PBXBuildFile; fileRef = C20B25981706536200C21F4E /* Region.h */; settings = {ATTRIBUTES = (Private, ); }; }; 820 821 C20BA92D16BB1C1500B3AEA2 /* StructureRareDataInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 821 822 C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C21122DE15DD9AB300790E3A /* GCThreadSharedData.cpp */; }; … … 1724 1725 BCFD8C900EEB2EE700283848 /* JumpTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JumpTable.cpp; sourceTree = "<group>"; }; 1725 1726 BCFD8C910EEB2EE700283848 /* JumpTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpTable.h; sourceTree = "<group>"; }; 1727 C20B25981706536200C21F4E /* Region.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Region.h; sourceTree = "<group>"; }; 1726 1728 C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureRareDataInlines.h; sourceTree = "<group>"; }; 1727 1729 C21122DE15DD9AB300790E3A /* GCThreadSharedData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCThreadSharedData.cpp; sourceTree = "<group>"; }; … … 2164 2166 C28318FF16FE4B7D00157BFD /* HandleBlock.h */, 2165 2167 C283190116FE533E00157BFD /* HandleBlockInlines.h */, 2168 C20B25981706536200C21F4E /* Region.h */, 2166 2169 ); 2167 2170 path = heap; … … 2963 2966 0F63945515D07057006A597C /* ArrayProfile.h in Headers */, 2964 2967 BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */, 2968 C20B25991706536200C21F4E /* Region.h in Headers */, 2965 2969 C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */, 2966 2970 BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */, -
trunk/Source/JavaScriptCore/heap/BlockAllocator.h
r146734 r147282 28 28 29 29 #include "HeapBlock.h" 30 #include "Region.h" 30 31 #include <wtf/DoublyLinkedList.h> 31 32 #include <wtf/Forward.h> … … 42 43 class MarkStackSegment; 43 44 class MarkedBlock; 44 class Region;45 45 class WeakBlock; 46 46 47 47 // Simple allocator to reduce VM cost by holding onto blocks of memory for 48 48 // short periods of time and then freeing them on a secondary thread. 49 50 class DeadBlock : public HeapBlock<DeadBlock> {51 public:52 DeadBlock(Region*);53 };54 55 inline DeadBlock::DeadBlock(Region* region)56 : HeapBlock<DeadBlock>(region)57 {58 }59 60 class Region : public DoublyLinkedListNode<Region> {61 friend CLASS_IF_GCC DoublyLinkedListNode<Region>;62 friend class BlockAllocator;63 public:64 ~Region();65 static Region* create(size_t blockSize);66 static Region* createCustomSize(size_t blockSize, size_t blockAlignment);67 Region* reset(size_t blockSize);68 69 size_t blockSize() const { return m_blockSize; }70 bool isFull() const { return m_blocksInUse == m_totalBlocks; }71 bool isEmpty() const { return !m_blocksInUse; }72 bool isCustomSize() const { return m_isCustomSize; }73 74 DeadBlock* allocate();75 void deallocate(void*);76 77 static const size_t s_regionSize = 64 * KB;78 79 private:80 Region(PageAllocationAligned&, size_t blockSize, size_t totalBlocks);81 82 PageAllocationAligned m_allocation;83 size_t m_totalBlocks;84 size_t m_blocksInUse;85 size_t m_blockSize;86 bool m_isCustomSize;87 Region* m_prev;88 Region* m_next;89 DoublyLinkedList<DeadBlock> m_deadBlocks;90 };91 92 inline Region* Region::create(size_t blockSize)93 {94 ASSERT(blockSize <= s_regionSize);95 ASSERT(!(s_regionSize % blockSize));96 PageAllocationAligned allocation = PageAllocationAligned::allocate(s_regionSize, s_regionSize, OSAllocator::JSGCHeapPages);97 RELEASE_ASSERT(static_cast<bool>(allocation));98 return new Region(allocation, blockSize, s_regionSize / blockSize);99 }100 101 inline Region* Region::createCustomSize(size_t blockSize, size_t blockAlignment)102 {103 PageAllocationAligned allocation = PageAllocationAligned::allocate(blockSize, blockAlignment, OSAllocator::JSGCHeapPages);104 RELEASE_ASSERT(static_cast<bool>(allocation));105 Region* region = new Region(allocation, blockSize, 1);106 region->m_isCustomSize = true;107 return region;108 }109 110 inline Region::Region(PageAllocationAligned& allocation, size_t blockSize, size_t totalBlocks)111 : DoublyLinkedListNode<Region>()112 , m_allocation(allocation)113 , m_totalBlocks(totalBlocks)114 , m_blocksInUse(0)115 , m_blockSize(blockSize)116 , m_isCustomSize(false)117 , m_prev(0)118 , m_next(0)119 {120 ASSERT(allocation);121 char* start = static_cast<char*>(m_allocation.base());122 char* end = start + m_allocation.size();123 for (char* current = start; current < end; current += blockSize)124 m_deadBlocks.append(new (NotNull, current) DeadBlock(this));125 }126 127 inline Region::~Region()128 {129 ASSERT(isEmpty());130 m_allocation.deallocate();131 }132 133 inline Region* Region::reset(size_t blockSize)134 {135 ASSERT(isEmpty());136 PageAllocationAligned allocation = m_allocation;137 return new (NotNull, this) Region(allocation, blockSize, s_regionSize / blockSize);138 }139 140 inline DeadBlock* Region::allocate()141 {142 ASSERT(!isFull());143 m_blocksInUse++;144 return m_deadBlocks.removeHead();145 }146 147 inline void Region::deallocate(void* base)148 {149 ASSERT(base);150 ASSERT(m_blocksInUse);151 ASSERT(base >= m_allocation.base() && base < static_cast<char*>(m_allocation.base()) + m_allocation.size());152 DeadBlock* block = new (NotNull, base) DeadBlock(this);153 m_deadBlocks.push(block);154 m_blocksInUse--;155 }156 49 157 50 class BlockAllocator {
Note: See TracChangeset
for help on using the changeset viewer.