Changeset 90865 in webkit
- Timestamp:
- Jul 12, 2011 3:35:39 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r90854 r90865 1 2011-07-12 Filip Pizlo <fpizlo@apple.com> 2 3 COLLECT_ON_EVERY_ALLOCATION no longer works. 4 https://bugs.webkit.org/show_bug.cgi?id=64388 5 6 Reviewed by Oliver Hunt. 7 8 Added a flag to Heap that determines if it's safe to collect (which for now means that 9 JSGlobalObject has actually been initialized, but it should work for other things, too). 10 This allows JSGlobalObject to allocate even if the allocator wants to GC; instead of 11 GCing it just grows the heap, if necessary. 12 13 Then changed Heap::allocate() to not recurse ad infinitum when 14 COLLECT_ON_EVERY_ALLOCATION is set. This also makes the allocator generally more 15 resilient against bugs; this change allowed me to put in handy assertions, such as that 16 an allocation must succeed after either a collection or after a new block was added. 17 18 * heap/Heap.cpp: 19 (JSC::Heap::Heap): 20 (JSC::Heap::tryAllocate): 21 (JSC::Heap::allocate): 22 (JSC::Heap::collectAllGarbage): 23 (JSC::Heap::collect): 24 * heap/Heap.h: 25 (JSC::Heap::notifyIsSafeToCollect): 26 * runtime/JSGlobalData.cpp: 27 (JSC::JSGlobalData::JSGlobalData): 28 1 29 2011-07-12 Filip Pizlo <fpizlo@apple.com> 2 30 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r90415 r90865 249 249 , m_slotVisitor(globalData->jsArrayVPtr) 250 250 , m_handleHeap(globalData) 251 , m_isSafeToCollect(false) 251 252 , m_globalData(globalData) 252 253 { … … 312 313 } 313 314 315 inline void* Heap::tryAllocate(NewSpace::SizeClass& sizeClass) 316 { 317 m_operationInProgress = Allocation; 318 void* result = m_newSpace.allocate(sizeClass); 319 m_operationInProgress = NoOperation; 320 return result; 321 } 322 314 323 void* Heap::allocate(NewSpace::SizeClass& sizeClass) 315 324 { … … 319 328 #endif 320 329 321 m_operationInProgress = Allocation; 322 void* result = m_newSpace.allocate(sizeClass); 323 m_operationInProgress = NoOperation; 324 330 void* result = tryAllocate(sizeClass); 331 332 if (LIKELY(result != 0)) 333 return result; 334 335 if (m_newSpace.waterMark() < m_newSpace.highWaterMark() || !m_isSafeToCollect) { 336 m_newSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize)); 337 void* result = tryAllocate(sizeClass); 338 ASSERT(result); 339 return result; 340 } 341 342 collect(DoNotSweep); 343 344 result = tryAllocate(sizeClass); 345 325 346 if (result) 326 347 return result; 327 328 if (m_newSpace.waterMark() < m_newSpace.highWaterMark()) {329 m_newSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize));330 return allocate(sizeClass);331 }332 333 collect(DoNotSweep);334 return allocate(sizeClass);348 349 ASSERT(m_newSpace.waterMark() < m_newSpace.highWaterMark()); 350 351 m_newSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize)); 352 353 result = tryAllocate(sizeClass); 354 ASSERT(result); 355 return result; 335 356 } 336 357 … … 526 547 void Heap::collectAllGarbage() 527 548 { 549 if (!m_isSafeToCollect) 550 return; 528 551 m_slotVisitor.setShouldUnlinkCalls(true); 529 552 collect(DoSweep); … … 534 557 { 535 558 ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable()); 559 ASSERT(m_isSafeToCollect); 536 560 JAVASCRIPTCORE_GC_BEGIN(); 537 561 -
trunk/Source/JavaScriptCore/heap/Heap.h
r89885 r90865 83 83 void* allocate(size_t); 84 84 void* allocate(NewSpace::SizeClass&); 85 void notifyIsSafeToCollect() { m_isSafeToCollect = true; } 85 86 void collectAllGarbage(); 86 87 … … 136 137 void markTempSortVectors(HeapRootVisitor&); 137 138 139 void* tryAllocate(NewSpace::SizeClass&); 140 138 141 enum SweepToggle { DoNotSweep, DoSweep }; 139 142 void collect(SweepToggle); … … 161 164 HandleHeap m_handleHeap; 162 165 HandleStack m_handleStack; 166 167 bool m_isSafeToCollect; 163 168 164 169 JSGlobalData* m_globalData; -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp
r90415 r90865 262 262 jitStubs = adoptPtr(new JITThunks(this)); 263 263 #endif 264 265 heap.notifyIsSafeToCollect(); 264 266 } 265 267
Note: See TracChangeset
for help on using the changeset viewer.