Changeset 87441 in webkit
- Timestamp:
- May 26, 2011 3:43:07 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r87440 r87441 1 2011-05-26 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Moved Heap-related functions out of JSCell.h and into respective header files 6 https://bugs.webkit.org/show_bug.cgi?id=61567 7 8 * heap/Heap.h: 9 (JSC::Heap::allocate): 10 (JSC::Heap::heap): 11 * heap/MarkedBlock.h: 12 (JSC::MarkedBlock::allocate): 13 * heap/MarkedSpace.h: 14 (JSC::MarkedSpace::sizeClassFor): 15 (JSC::MarkedSpace::allocate): 16 * runtime/JSCell.h: 17 (JSC::JSCell::destructor): 18 1 19 2011-05-26 Geoffrey Garen <ggaren@apple.com> 2 20 -
trunk/Source/JavaScriptCore/heap/Heap.h
r87434 r87441 194 194 } 195 195 196 inline void* Heap::allocate(size_t bytes) 197 { 198 ASSERT(isValidAllocation(bytes)); 199 200 m_operationInProgress = Allocation; 201 void* result = m_markedSpace.allocate(bytes); 202 m_operationInProgress = NoOperation; 203 if (result) 204 return result; 205 206 return allocateSlowCase(bytes); 207 } 208 209 inline Heap* Heap::heap(JSValue v) 210 { 211 if (!v.isCell()) 212 return 0; 213 return heap(v.asCell()); 214 } 215 216 inline Heap* Heap::heap(JSCell* c) 217 { 218 return MarkedSpace::heap(c); 219 } 220 196 221 } // namespace JSC 197 222 -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r87427 r87441 37 37 38 38 static const size_t KB = 1024; 39 40 void destructor(JSCell*); // Defined in JSCell.h. 39 41 40 42 class MarkedBlock : public DoublyLinkedListNode<MarkedBlock> { … … 198 200 } 199 201 202 inline void* MarkedBlock::allocate() 203 { 204 while (m_nextAtom < m_endAtom) { 205 if (!m_marks.testAndSet(m_nextAtom)) { 206 JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[m_nextAtom]); 207 m_nextAtom += m_atomsPerCell; 208 destructor(cell); 209 return cell; 210 } 211 m_nextAtom += m_atomsPerCell; 212 } 213 214 return 0; 215 } 216 200 217 } // namespace JSC 201 218 -
trunk/Source/JavaScriptCore/heap/MarkedSpace.h
r85533 r87441 173 173 } 174 174 175 inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes) 176 { 177 ASSERT(bytes && bytes < maxCellSize); 178 if (bytes < preciseCutoff) 179 return m_preciseSizeClasses[(bytes - 1) / preciseStep]; 180 return m_impreciseSizeClasses[(bytes - 1) / impreciseStep]; 181 } 182 183 inline void* MarkedSpace::allocate(size_t bytes) 184 { 185 SizeClass& sizeClass = sizeClassFor(bytes); 186 return allocateFromSizeClass(sizeClass); 187 } 188 175 189 inline MarkedSpace::SizeClass::SizeClass() 176 190 : nextBlock(0) -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r87434 r87441 73 73 friend class StructureChain; 74 74 friend class RegExp; 75 friend void destructor(JSCell*); 76 75 77 enum CreatingEarlyCellTag { CreatingEarlyCell }; 76 78 … … 346 348 } 347 349 348 inline Heap* Heap::heap(JSValue v)349 {350 if (!v.isCell())351 return 0;352 return heap(v.asCell());353 }354 355 inline Heap* Heap::heap(JSCell* c)356 {357 return MarkedSpace::heap(c);358 }359 360 350 #if ENABLE(JSC_ZOMBIES) 361 351 inline bool JSValue::isZombie() const … … 365 355 #endif 366 356 367 inline void* MarkedBlock::allocate() 368 { 369 while (m_nextAtom < m_endAtom) { 370 if (!m_marks.testAndSet(m_nextAtom)) { 371 JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[m_nextAtom]); 372 m_nextAtom += m_atomsPerCell; 373 cell->~JSCell(); 374 return cell; 375 } 376 m_nextAtom += m_atomsPerCell; 377 } 378 379 return 0; 357 inline void* JSCell::operator new(size_t size, JSGlobalData* globalData) 358 { 359 return globalData->heap.allocate(size); 360 } 361 362 inline void* JSCell::operator new(size_t size, ExecState* exec) 363 { 364 return exec->heap()->allocate(size); 380 365 } 381 366 382 inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes) 383 { 384 ASSERT(bytes && bytes < maxCellSize); 385 if (bytes < preciseCutoff) 386 return m_preciseSizeClasses[(bytes - 1) / preciseStep]; 387 return m_impreciseSizeClasses[(bytes - 1) / impreciseStep]; 388 } 389 390 inline void* MarkedSpace::allocate(size_t bytes) 391 { 392 SizeClass& sizeClass = sizeClassFor(bytes); 393 return allocateFromSizeClass(sizeClass); 394 } 395 396 inline void* Heap::allocate(size_t bytes) 397 { 398 ASSERT(isValidAllocation(bytes)); 399 400 m_operationInProgress = Allocation; 401 void* result = m_markedSpace.allocate(bytes); 402 m_operationInProgress = NoOperation; 403 if (result) 404 return result; 405 406 return allocateSlowCase(bytes); 407 } 408 409 inline void* JSCell::operator new(size_t size, JSGlobalData* globalData) 410 { 411 return globalData->heap.allocate(size); 412 } 413 414 inline void* JSCell::operator new(size_t size, ExecState* exec) 415 { 416 return exec->heap()->allocate(size); 367 inline void destructor(JSCell* cell) 368 { 369 cell->~JSCell(); 417 370 } 418 371
Note: See TracChangeset
for help on using the changeset viewer.