Changeset 31061 in webkit for trunk/JavaScriptCore
- Timestamp:
- Mar 14, 2008, 12:05:28 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r31057 r31061 1 2008-03-14 Geoffrey Garen <[email protected]> 2 3 Reviewed by Beth Dakin. 4 5 Fixed a few problems with Vector::shrinkCapacity that I noticed in testing. 6 7 * wtf/Vector.h: 8 (WTF::VectorBufferBase::deallocateBuffer): Clear our m_buffer pointer 9 when we deallocate m_buffer, in case we're not asked to reallocate a new 10 buffer. (Otherwise, we would use a stale m_buffer if we were asked to 11 perform any operations after shrinkCapacity was called.) 12 13 (WTF::VectorBuffer::allocateBuffer): Made VectorBuffer with inline 14 capacity aware that calls to allocateBuffer might be shrinks, rather 15 than grows, so we shouldn't allocate a new buffer on the heap unless 16 our inline buffer is too small. 17 18 (WTF::::shrinkCapacity): Call resize() instead of just setting m_size, 19 so destructors run. Call resize before reallocating the buffer to make 20 sure that we still have access to the objects we need to destroy. Call 21 moveOverlapping instead of move, since a call to allocateBuffer on an 22 inline buffer may produce identical storage. 23 1 24 2008-03-14 Alexey Proskuryakov <[email protected]> 2 25 … … 223 246 * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: 224 247 225 2008-03-09 J ürg Billeter <[email protected]>248 2008-03-09 J¸rg Billeter <[email protected]> 226 249 227 250 Reviewed by Alp Toker. -
trunk/JavaScriptCore/wtf/Vector.h
r31032 r31061 254 254 void deallocateBuffer(T* bufferToDeallocate) 255 255 { 256 if (m_buffer == bufferToDeallocate) 257 m_buffer = 0; 256 258 fastFree(bufferToDeallocate); 257 259 } … … 344 346 : Base(inlineBuffer(), inlineCapacity) 345 347 { 346 if (capacity > inlineCapacity) 347 allocateBuffer(capacity); 348 allocateBuffer(capacity); 348 349 } 349 350 … … 353 354 } 354 355 355 using Base::allocateBuffer; 356 void allocateBuffer(size_t newCapacity) 357 { 358 if (newCapacity > inlineCapacity) 359 Base::allocateBuffer(newCapacity); 360 } 356 361 357 362 void deallocateBuffer(T* bufferToDeallocate) … … 666 671 return; 667 672 673 resize(min(m_size, newCapacity)); 674 668 675 T* oldBuffer = begin(); 669 676 if (newCapacity > 0) { 670 677 T* oldEnd = end(); 671 678 m_buffer.allocateBuffer(newCapacity); 672 TypeOperations::move (oldBuffer, oldEnd, begin());673 } 674 m_size = min(m_size, newCapacity); 679 TypeOperations::moveOverlapping(oldBuffer, oldEnd, begin()); 680 } 681 675 682 m_buffer.deallocateBuffer(oldBuffer); 676 683 }
Note:
See TracChangeset
for help on using the changeset viewer.