Changeset 95559 in webkit
- Timestamp:
- Sep 20, 2011 11:31:37 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r95507 r95559 46 46 bytecompiler/NodesCodegen.cpp 47 47 48 heap/AllocationSpace.cpp 48 49 heap/Heap.cpp 49 50 heap/HandleHeap.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r95555 r95559 1 2011-09-19 Oliver Hunt <oliver@apple.com> 2 3 Refactor Heap allocation logic into separate AllocationSpace class 4 https://bugs.webkit.org/show_bug.cgi?id=68409 5 6 Reviewed by Gavin Barraclough. 7 8 This patch hoists direct manipulation of the MarkedSpace and related 9 data out of Heap and into a separate class. This will allow us to 10 have multiple allocation spaces in future, so easing the way towards 11 having GC'd backing stores for objects. 12 13 * CMakeLists.txt: 14 * GNUmakefile.list.am: 15 * JavaScriptCore.exp: 16 * JavaScriptCore.gypi: 17 * JavaScriptCore.pro: 18 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 19 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 20 * JavaScriptCore.xcodeproj/project.pbxproj: 21 * debugger/Debugger.cpp: 22 (JSC::Debugger::recompileAllJSFunctions): 23 * heap/AllocationSpace.cpp: Added. 24 (JSC::AllocationSpace::tryAllocate): 25 (JSC::AllocationSpace::allocateSlowCase): 26 (JSC::AllocationSpace::allocateBlock): 27 (JSC::AllocationSpace::freeBlocks): 28 (JSC::TakeIfEmpty::TakeIfEmpty): 29 (JSC::TakeIfEmpty::operator()): 30 (JSC::TakeIfEmpty::returnValue): 31 (JSC::AllocationSpace::shrink): 32 * heap/AllocationSpace.h: Added. 33 (JSC::AllocationSpace::AllocationSpace): 34 (JSC::AllocationSpace::blocks): 35 (JSC::AllocationSpace::sizeClassFor): 36 (JSC::AllocationSpace::setHighWaterMark): 37 (JSC::AllocationSpace::highWaterMark): 38 (JSC::AllocationSpace::canonicalizeBlocks): 39 (JSC::AllocationSpace::resetAllocator): 40 (JSC::AllocationSpace::forEachCell): 41 (JSC::AllocationSpace::forEachBlock): 42 (JSC::AllocationSpace::allocate): 43 * heap/Heap.cpp: 44 (JSC::Heap::Heap): 45 (JSC::Heap::reportExtraMemoryCostSlowCase): 46 (JSC::Heap::getConservativeRegisterRoots): 47 (JSC::Heap::markRoots): 48 (JSC::Heap::clearMarks): 49 (JSC::Heap::sweep): 50 (JSC::Heap::objectCount): 51 (JSC::Heap::size): 52 (JSC::Heap::capacity): 53 (JSC::Heap::globalObjectCount): 54 (JSC::Heap::objectTypeCounts): 55 (JSC::Heap::collect): 56 (JSC::Heap::canonicalizeBlocks): 57 (JSC::Heap::resetAllocator): 58 (JSC::Heap::freeBlocks): 59 (JSC::Heap::shrink): 60 * heap/Heap.h: 61 (JSC::Heap::objectSpace): 62 (JSC::Heap::sizeClassForObject): 63 (JSC::Heap::allocate): 64 * jit/JITInlineMethods.h: 65 (JSC::JIT::emitAllocateBasicJSObject): 66 * runtime/JSGlobalData.cpp: 67 (JSC::JSGlobalData::recompileAllJSFunctions): 68 (JSC::JSGlobalData::releaseExecutableMemory): 69 1 70 2011-09-19 Geoffrey Garen <ggaren@apple.com> 2 71 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r95507 r95559 134 134 Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp \ 135 135 Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h \ 136 Source/JavaScriptCore/heap/AllocationSpace.cpp \ 137 Source/JavaScriptCore/heap/AllocationSpace.h \ 136 138 Source/JavaScriptCore/heap/ConservativeRoots.cpp \ 137 139 Source/JavaScriptCore/heap/ConservativeRoots.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r95507 r95559 119 119 __ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE 120 120 __ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE 121 __ZN3JSC15AllocationSpace16allocateSlowCaseERNS_11MarkedSpace9SizeClassE 121 122 __ZN3JSC11ParserArena5resetEv 122 123 __ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE … … 234 235 __ZN3JSC4Heap11objectCountEv 235 236 __ZN3JSC4Heap16activityCallbackEv 236 __ZN3JSC4Heap16allocateSlowCaseERNS_11MarkedSpace9SizeClassE237 237 __ZN3JSC4Heap16objectTypeCountsEv 238 238 __ZN3JSC4Heap17collectAllGarbageEv -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r95507 r95559 28 28 'assembler/MacroAssemblerCodeRef.h', 29 29 'bytecode/Opcode.h', 30 'heap/AllocationSpace.h', 30 31 'heap/ConservativeRoots.h', 31 32 'heap/Handle.h', … … 325 326 'bytecompiler/NodesCodegen.cpp', 326 327 'bytecompiler/RegisterID.h', 328 'heap/AllocationSpace.cpp', 327 329 'heap/ConservativeRoots.cpp', 328 330 'heap/HandleHeap.cpp', -
trunk/Source/JavaScriptCore/JavaScriptCore.pro
r95507 r95559 73 73 bytecompiler/BytecodeGenerator.cpp \ 74 74 bytecompiler/NodesCodegen.cpp \ 75 heap/AllocationSpace.cpp \ 75 76 heap/ConservativeRoots.cpp \ 76 77 heap/HandleHeap.cpp \ -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r95516 r95559 60 60 ?addSlowCase@Identifier@JSC@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@WTF@@PAVExecState@2@PAVStringImpl@4@@Z 61 61 ?addStaticGlobals@JSGlobalObject@JSC@@IAEXPAUGlobalPropertyInfo@12@H@Z 62 ?allocate@Heap@JSC@@QAEPAXAAUSizeClass@MarkedSpace@2@@Z63 62 ?allocatePropertyStorage@JSObject@JSC@@QAEXAAVJSGlobalData@2@II@Z 64 ?allocateSlowCase@ Heap@JSC@@AAEPAXAAUSizeClass@MarkedSpace@2@@Z63 ?allocateSlowCase@AllocationSpace@JSC@@AAEPAXAAUSizeClass@MarkedSpace@2@@Z 65 64 ?append@StringBuilder@WTF@@QAEXPBDI@Z 66 65 ?append@StringBuilder@WTF@@QAEXPB_WI@Z -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r95507 r95559 1891 1891 > 1892 1892 <File 1893 RelativePath="..\..\heap\AllocationSpace.cpp" 1894 > 1895 </File> 1896 <File 1897 RelativePath="..\..\heap\AllocationSpace.h" 1898 > 1899 </File> 1900 <File 1893 1901 RelativePath="..\..\heap\ConservativeRoots.cpp" 1894 1902 > -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r95507 r95559 407 407 A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B4011C7B235007A5315 /* RegExpKey.h */; settings = {ATTRIBUTES = (Private, ); }; }; 408 408 A1D764521354448B00C5C7C0 /* Alignment.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D764511354448B00C5C7C0 /* Alignment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 409 A70456B01427FB910037DA68 /* AllocationSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = A70456AF1427FB150037DA68 /* AllocationSpace.h */; settings = {ATTRIBUTES = (Private, ); }; }; 410 A70456B11427FB950037DA68 /* AllocationSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70456AE1427FB030037DA68 /* AllocationSpace.cpp */; }; 409 411 A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */; }; 410 412 A72700900DAC6BBC00E548D7 /* JSNotAnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A72700780DAC605600E548D7 /* JSNotAnObject.cpp */; }; … … 1183 1185 A1712B4011C7B235007A5315 /* RegExpKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpKey.h; sourceTree = "<group>"; }; 1184 1186 A1D764511354448B00C5C7C0 /* Alignment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Alignment.h; sourceTree = "<group>"; }; 1187 A70456AE1427FB030037DA68 /* AllocationSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AllocationSpace.cpp; sourceTree = "<group>"; }; 1188 A70456AF1427FB150037DA68 /* AllocationSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllocationSpace.h; sourceTree = "<group>"; }; 1185 1189 A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITOpcodes32_64.cpp; sourceTree = "<group>"; }; 1186 1190 A718F61A11754A21002465A7 /* RegExpJitTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpJitTables.h; sourceTree = "<group>"; }; … … 1618 1622 isa = PBXGroup; 1619 1623 children = ( 1624 A70456AF1427FB150037DA68 /* AllocationSpace.h */, 1625 A70456AE1427FB030037DA68 /* AllocationSpace.cpp */, 1620 1626 0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */, 1621 1627 0FC815141405118D00CFA603 /* VTableSpectrum.h */, … … 2794 2800 A781E359141970C700094D90 /* StorageBarrier.h in Headers */, 2795 2801 1A08277A142168D70090CCAC /* BinarySemaphore.h in Headers */, 2802 A70456B01427FB910037DA68 /* AllocationSpace.h in Headers */, 2796 2803 ); 2797 2804 runOnlyForDeploymentPostprocessing = 0; … … 3299 3306 C22C531313FAF6EF00B7DC0D /* strtod.cc in Sources */, 3300 3307 1A082779142168D70090CCAC /* BinarySemaphore.cpp in Sources */, 3308 A70456B11427FB950037DA68 /* AllocationSpace.cpp in Sources */, 3301 3309 ); 3302 3310 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/debugger/Debugger.cpp
r95507 r95559 119 119 120 120 Recompiler recompiler(this); 121 globalData->heap. forEachCell(recompiler);121 globalData->heap.objectSpace().forEachCell(recompiler); 122 122 } 123 123 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r95512 r95559 34 34 #include <algorithm> 35 35 36 #define COLLECT_ON_EVERY_ALLOCATION 037 36 38 37 using namespace std; … … 176 175 } 177 176 178 class TakeIfEmpty {179 public:180 typedef MarkedBlock* ReturnType;181 182 TakeIfEmpty(MarkedSpace*);183 void operator()(MarkedBlock*);184 ReturnType returnValue();185 186 private:187 MarkedSpace* m_markedSpace;188 DoublyLinkedList<MarkedBlock> m_empties;189 };190 191 inline TakeIfEmpty::TakeIfEmpty(MarkedSpace* newSpace)192 : m_markedSpace(newSpace)193 {194 }195 196 inline void TakeIfEmpty::operator()(MarkedBlock* block)197 {198 if (!block->isEmpty())199 return;200 201 m_markedSpace->removeBlock(block);202 m_empties.append(block);203 }204 205 inline TakeIfEmpty::ReturnType TakeIfEmpty::returnValue()206 {207 return m_empties.head();208 }209 210 177 class RecordType { 211 178 public: … … 250 217 , m_minBytesPerCycle(heapSizeForHint(heapSize)) 251 218 , m_operationInProgress(NoOperation) 252 , m_ markedSpace(this)219 , m_objectSpace(this) 253 220 , m_extraCost(0) 254 221 , m_markListSet(0) … … 260 227 , m_globalData(globalData) 261 228 { 262 m_ markedSpace.setHighWaterMark(m_minBytesPerCycle);229 m_objectSpace.setHighWaterMark(m_minBytesPerCycle); 263 230 (*m_activityCallback)(); 264 231 m_numberOfFreeBlocks = 0; … … 394 361 // collecting more frequently as long as it stays alive. 395 362 396 if (m_extraCost > maxExtraCost && m_extraCost > m_ markedSpace.highWaterMark() / 2)363 if (m_extraCost > maxExtraCost && m_extraCost > m_objectSpace.highWaterMark() / 2) 397 364 collectAllGarbage(); 398 365 m_extraCost += cost; 399 }400 401 inline void* Heap::tryAllocate(MarkedSpace::SizeClass& sizeClass)402 {403 m_operationInProgress = Allocation;404 void* result = m_markedSpace.allocate(sizeClass);405 m_operationInProgress = NoOperation;406 return result;407 }408 409 void* Heap::allocateSlowCase(MarkedSpace::SizeClass& sizeClass)410 {411 #if COLLECT_ON_EVERY_ALLOCATION412 collectAllGarbage();413 ASSERT(m_operationInProgress == NoOperation);414 #endif415 416 void* result = tryAllocate(sizeClass);417 418 if (LIKELY(result != 0))419 return result;420 421 AllocationEffort allocationEffort;422 423 if (m_markedSpace.waterMark() < m_markedSpace.highWaterMark() || !m_isSafeToCollect)424 allocationEffort = AllocationMustSucceed;425 else426 allocationEffort = AllocationCanFail;427 428 MarkedBlock* block = allocateBlock(sizeClass.cellSize, allocationEffort);429 if (block) {430 m_markedSpace.addBlock(sizeClass, block);431 void* result = tryAllocate(sizeClass);432 ASSERT(result);433 return result;434 }435 436 collect(DoNotSweep);437 438 result = tryAllocate(sizeClass);439 440 if (result)441 return result;442 443 ASSERT(m_markedSpace.waterMark() < m_markedSpace.highWaterMark());444 445 m_markedSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize, AllocationMustSucceed));446 447 result = tryAllocate(sizeClass);448 ASSERT(result);449 return result;450 366 } 451 367 … … 522 438 CRASH(); 523 439 m_operationInProgress = Collection; 524 ConservativeRoots registerFileRoots(&m_ blocks);440 ConservativeRoots registerFileRoots(&m_objectSpace.blocks()); 525 441 registerFile().gatherConservativeRoots(registerFileRoots); 526 442 size_t registerFileRootCount = registerFileRoots.size(); … … 544 460 // We gather conservative roots before clearing mark bits because conservative 545 461 // gathering uses the mark bits to determine whether a reference is valid. 546 ConservativeRoots machineThreadRoots(&m_ blocks);462 ConservativeRoots machineThreadRoots(&m_objectSpace.blocks()); 547 463 m_machineThreads.gatherConservativeRoots(machineThreadRoots, &dummy); 548 464 549 ConservativeRoots registerFileRoots(&m_ blocks);465 ConservativeRoots registerFileRoots(&m_objectSpace.blocks()); 550 466 registerFile().gatherConservativeRoots(registerFileRoots); 551 467 … … 600 516 void Heap::clearMarks() 601 517 { 602 forEachBlock<ClearMarks>();518 m_objectSpace.forEachBlock<ClearMarks>(); 603 519 } 604 520 605 521 void Heap::sweep() 606 522 { 607 forEachBlock<Sweep>();523 m_objectSpace.forEachBlock<Sweep>(); 608 524 } 609 525 610 526 size_t Heap::objectCount() 611 527 { 612 return forEachBlock<MarkCount>();528 return m_objectSpace.forEachBlock<MarkCount>(); 613 529 } 614 530 615 531 size_t Heap::size() 616 532 { 617 return forEachBlock<Size>();533 return m_objectSpace.forEachBlock<Size>(); 618 534 } 619 535 620 536 size_t Heap::capacity() 621 537 { 622 return forEachBlock<Capacity>();538 return m_objectSpace.forEachBlock<Capacity>(); 623 539 } 624 540 … … 630 546 size_t Heap::globalObjectCount() 631 547 { 632 return forEachCell<CountIfGlobalObject>();548 return m_objectSpace.forEachCell<CountIfGlobalObject>(); 633 549 } 634 550 … … 645 561 PassOwnPtr<TypeCountSet> Heap::objectTypeCounts() 646 562 { 647 return forEachCell<RecordType>();563 return m_objectSpace.forEachCell<RecordType>(); 648 564 } 649 565 … … 684 600 // new bytes allocated) proportion, and seems to work well in benchmarks. 685 601 size_t proportionalBytes = 2 * size(); 686 m_ markedSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));602 m_objectSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle)); 687 603 JAVASCRIPTCORE_GC_END(); 688 604 … … 692 608 void Heap::canonicalizeBlocks() 693 609 { 694 m_ markedSpace.canonicalizeBlocks();610 m_objectSpace.canonicalizeBlocks(); 695 611 } 696 612 … … 698 614 { 699 615 m_extraCost = 0; 700 m_ markedSpace.resetAllocator();616 m_objectSpace.resetAllocator(); 701 617 } 702 618 … … 725 641 } 726 642 727 MarkedBlock* Heap::allocateBlock(size_t cellSize, Heap::AllocationEffort allocationEffort)728 {729 MarkedBlock* block;730 731 {732 MutexLocker locker(m_freeBlockLock);733 if (m_numberOfFreeBlocks) {734 block = m_freeBlocks.removeHead();735 ASSERT(block);736 m_numberOfFreeBlocks--;737 } else738 block = 0;739 }740 if (block)741 block->initForCellSize(cellSize);742 else if (allocationEffort == AllocationCanFail)743 return 0;744 else745 block = MarkedBlock::create(this, cellSize);746 747 m_blocks.add(block);748 749 return block;750 }751 752 643 void Heap::freeBlocks(MarkedBlock* head) 753 644 { 754 MarkedBlock* next; 755 for (MarkedBlock* block = head; block; block = next) { 756 next = block->next(); 757 758 m_blocks.remove(block); 759 block->reset(); 760 MutexLocker locker(m_freeBlockLock); 761 m_freeBlocks.append(block); 762 m_numberOfFreeBlocks++; 763 } 645 m_objectSpace.freeBlocks(head); 764 646 } 765 647 766 648 void Heap::shrink() 767 649 { 768 // We record a temporary list of empties to avoid modifying m_blocks while iterating it. 769 TakeIfEmpty takeIfEmpty(&m_markedSpace); 770 freeBlocks(forEachBlock(takeIfEmpty)); 650 m_objectSpace.shrink(); 771 651 } 772 652 -
trunk/Source/JavaScriptCore/heap/Heap.h
r95512 r95559 23 23 #define Heap_h 24 24 25 #include "AllocationSpace.h" 25 26 #include "HandleHeap.h" 26 27 #include "HandleStack.h" … … 38 39 class GCActivityCallback; 39 40 class GlobalCodeBlock; 41 class Heap; 40 42 class HeapRootVisitor; 41 43 class JSCell; … … 57 59 // Heap size hint. 58 60 enum HeapSize { SmallHeap, LargeHeap }; 59 61 60 62 class Heap { 61 63 WTF_MAKE_NONCOPYABLE(Heap); 62 64 public: 65 friend class JIT; 63 66 static Heap* heap(JSValue); // 0 for immediate values 64 67 static Heap* heap(JSCell*); … … 77 80 78 81 JSGlobalData* globalData() const { return m_globalData; } 79 MarkedSpace& markedSpace() { return m_markedSpace; }82 AllocationSpace& objectSpace() { return m_objectSpace; } 80 83 MachineThreads& machineThreads() { return m_machineThreads; } 81 84 … … 85 88 // true if an allocation or collection is in progress 86 89 inline bool isBusy(); 87 90 91 MarkedSpace::SizeClass& sizeClassForObject(size_t bytes) { return m_objectSpace.sizeClassFor(bytes); } 88 92 void* allocate(size_t); 89 MarkedSpace::SizeClass& sizeClassFor(size_t); 90 void* allocate(MarkedSpace::SizeClass&); 93 91 94 void notifyIsSafeToCollect() { m_isSafeToCollect = true; } 92 95 void collectAllGarbage(); … … 113 116 template<typename Functor> typename Functor::ReturnType forEachProtectedCell(Functor&); 114 117 template<typename Functor> typename Functor::ReturnType forEachProtectedCell(); 115 template<typename Functor> typename Functor::ReturnType forEachCell(Functor&);116 template<typename Functor> typename Functor::ReturnType forEachCell();117 template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);118 template<typename Functor> typename Functor::ReturnType forEachBlock();119 118 120 119 HandleSlot allocateGlobalHandle() { return m_handleHeap.allocate(); } … … 126 125 private: 127 126 friend class MarkedBlock; 128 129 typedef HashSet<MarkedBlock*>::iterator BlockIterator; 127 friend class AllocationSpace; 130 128 131 129 static const size_t minExtraCost = 256; 132 130 static const size_t maxExtraCost = 1024 * 1024; 133 134 enum AllocationEffort { AllocationMustSucceed, AllocationCanFail };135 131 136 132 #if ENABLE(GGC) … … 143 139 void resetAllocator(); 144 140 145 MarkedBlock* allocateBlock(size_t cellSize, AllocationEffort);146 141 void freeBlocks(MarkedBlock*); 147 142 … … 151 146 void markTempSortVectors(HeapRootVisitor&); 152 147 void harvestWeakReferences(); 153 154 void* tryAllocate(MarkedSpace::SizeClass&);155 void* allocateSlowCase(MarkedSpace::SizeClass&);156 148 157 149 enum SweepToggle { DoNotSweep, DoSweep }; … … 174 166 175 167 OperationInProgress m_operationInProgress; 176 MarkedSpace m_markedSpace; 177 MarkedBlockSet m_blocks; 168 AllocationSpace m_objectSpace; 178 169 179 170 DoublyLinkedList<MarkedBlock> m_freeBlocks; … … 303 294 } 304 295 305 template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell(Functor& functor)306 {307 canonicalizeBlocks();308 BlockIterator end = m_blocks.set().end();309 for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)310 (*it)->forEachCell(functor);311 return functor.returnValue();312 }313 314 template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell()315 {316 Functor functor;317 return forEachCell(functor);318 }319 320 template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock(Functor& functor)321 {322 canonicalizeBlocks();323 BlockIterator end = m_blocks.set().end();324 for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)325 functor(*it);326 return functor.returnValue();327 }328 329 template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock()330 {331 Functor functor;332 return forEachBlock(functor);333 }334 335 inline MarkedSpace::SizeClass& Heap::sizeClassFor(size_t bytes)336 {337 return m_markedSpace.sizeClassFor(bytes);338 }339 340 inline void* Heap::allocate(MarkedSpace::SizeClass& sizeClass)341 {342 // This is a light-weight fast path to cover the most common case.343 MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;344 if (UNLIKELY(!firstFreeCell))345 return allocateSlowCase(sizeClass);346 347 sizeClass.firstFreeCell = firstFreeCell->next;348 return firstFreeCell;349 }350 351 296 inline void* Heap::allocate(size_t bytes) 352 297 { 353 298 ASSERT(isValidAllocation(bytes)); 354 MarkedSpace::SizeClass& sizeClass = sizeClassFor(bytes); 355 return allocate(sizeClass); 299 return m_objectSpace.allocate(bytes); 356 300 } 357 301 -
trunk/Source/JavaScriptCore/jit/JITInlineMethods.h
r95507 r95559 395 395 template <typename ClassType, typename StructureType> inline void JIT::emitAllocateBasicJSObject(StructureType structure, void* vtable, RegisterID result, RegisterID storagePtr) 396 396 { 397 MarkedSpace::SizeClass* sizeClass = &m_globalData->heap.sizeClassFor (sizeof(ClassType));397 MarkedSpace::SizeClass* sizeClass = &m_globalData->heap.sizeClassForObject(sizeof(ClassType)); 398 398 loadPtr(&sizeClass->firstFreeCell, result); 399 399 addSlowCase(branchTestPtr(Zero, result)); -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp
r95510 r95559 448 448 ASSERT(!dynamicGlobalObject); 449 449 450 heap. forEachCell<Recompiler>();450 heap.objectSpace().forEachCell<Recompiler>(); 451 451 } 452 452 … … 489 489 490 490 } 491 heap. forEachCell<StackPreservingRecompiler>(recompiler);491 heap.objectSpace().forEachCell<StackPreservingRecompiler>(recompiler); 492 492 } 493 493 m_regExpCache->invalidateCode(); -
trunk/Source/WebCore/ChangeLog
r95558 r95559 1 2011-09-19 Oliver Hunt <oliver@apple.com> 2 3 Refactor Heap allocation logic into separate AllocationSpace class 4 https://bugs.webkit.org/show_bug.cgi?id=68409 5 6 Reviewed by Gavin Barraclough. 7 8 Adding a forwarding header. 9 10 * ForwardingHeaders/heap/AllocationSpace.h: Added. 11 1 12 2011-09-20 Geoffrey Garen <ggaren@apple.com> 2 13
Note: See TracChangeset
for help on using the changeset viewer.