Changeset 141716 in webkit
- Timestamp:
- Feb 3, 2013 5:37:41 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r141702 r141716 1 2013-02-02 Andreas Kling <akling@apple.com> 2 3 Vector should consult allocator about ideal size when choosing capacity. 4 <http://webkit.org/b/108410> 5 <rdar://problem/13124002> 6 7 Reviewed by Benjamin Poulain. 8 9 Remove assertion about Vector capacity that won't hold anymore since capacity() 10 may not be what you passed to reserveCapacity(). 11 Also export WTF::fastMallocGoodSize() for Windows builds. 12 13 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreExports.def: 14 * bytecode/CodeBlock.cpp: 15 (JSC::CodeBlock::CodeBlock): 16 1 17 2013-02-02 Patrick Gansterer <paroga@webkit.org> 2 18 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreExports.def
r141521 r141716 207 207 ?fastFree@WTF@@YAXPAX@Z 208 208 ?fastMalloc@WTF@@YAPAXI@Z 209 ?fastMallocGoodSize@WTF@@YAII@Z 209 210 ?fastMallocMatchFailed@Internal@WTF@@YAXPAX@Z 210 211 ?fastMallocSize@WTF@@YAIPBX@Z -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r141504 r141716 1821 1821 m_resolveOperations.grow(size); 1822 1822 size_t putToBaseCount = unlinkedCodeBlock->numberOfPutToBaseOperations(); 1823 m_putToBaseOperations.reserve Capacity(putToBaseCount);1823 m_putToBaseOperations.reserveInitialCapacity(putToBaseCount); 1824 1824 for (size_t i = 0; i < putToBaseCount; ++i) 1825 m_putToBaseOperations.append(PutToBaseOperation(isStrictMode())); 1826 1827 ASSERT(m_putToBaseOperations.capacity() == putToBaseCount); 1825 m_putToBaseOperations.uncheckedAppend(PutToBaseOperation(isStrictMode())); 1828 1826 1829 1827 // Copy and translate the UnlinkedInstructions -
trunk/Source/WTF/ChangeLog
r141700 r141716 1 2013-02-02 Andreas Kling <akling@apple.com> 2 3 Vector should consult allocator about ideal size when choosing capacity. 4 <http://webkit.org/b/108410> 5 <rdar://problem/13124002> 6 7 Reviewed by Benjamin Poulain. 8 9 Added WTF::fastMallocGoodSize(), a workalike/wrapper for OS X's malloc_good_size(). 10 It returns the actual size of the block that will get allocated for a given byte size. 11 12 Vector's internal buffer now checks with the allocator if the resulting allocation 13 could actually house more objects and updates its capacity to make use of the space. 14 15 * wtf/Deque.h: 16 (WTF::::expandCapacity): 17 * wtf/FastMalloc.cpp: 18 (WTF::fastMallocGoodSize): 19 * wtf/FastMalloc.h: 20 * wtf/Vector.h: 21 (WTF::VectorBufferBase::allocateBuffer): 22 (WTF::VectorBufferBase::tryAllocateBuffer): 23 (WTF::VectorBufferBase::reallocateBuffer): 24 1 25 2013-02-02 Mark Rowe <mrowe@apple.com> 2 26 -
trunk/Source/WTF/wtf/Deque.h
r141504 r141716 384 384 checkValidity(); 385 385 size_t oldCapacity = m_buffer.capacity(); 386 size_t newCapacity = std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1);387 386 T* oldBuffer = m_buffer.buffer(); 388 m_buffer.allocateBuffer( newCapacity);387 m_buffer.allocateBuffer(std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1)); 389 388 if (m_start <= m_end) 390 389 TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffer.buffer() + m_start); 391 390 else { 392 391 TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer()); 393 size_t newStart = newCapacity- (oldCapacity - m_start);392 size_t newStart = m_buffer.capacity() - (oldCapacity - m_start); 394 393 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m_buffer.buffer() + newStart); 395 394 m_start = newStart; -
trunk/Source/WTF/wtf/FastMalloc.cpp
r141700 r141716 238 238 namespace WTF { 239 239 240 size_t fastMallocGoodSize(size_t bytes) 241 { 242 #if OS(DARWIN) 243 return malloc_good_size(bytes); 244 #else 245 return bytes; 246 #endif 247 } 248 240 249 TryMallocReturnValue tryFastMalloc(size_t n) 241 250 { … … 2557 2566 2558 2567 #define pageheap getPageHeap() 2568 2569 size_t fastMallocGoodSize(size_t bytes) 2570 { 2571 if (!phinited) 2572 TCMalloc_ThreadCache::InitModule(); 2573 return AllocationSize(bytes); 2574 } 2559 2575 2560 2576 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY -
trunk/Source/WTF/wtf/FastMalloc.h
r141504 r141716 36 36 WTF_EXPORT_PRIVATE char* fastStrDup(const char*); 37 37 WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*); 38 WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t); 38 39 39 40 struct TryMallocReturnValue { … … 224 225 using WTF::fastFree; 225 226 using WTF::fastMalloc; 227 using WTF::fastMallocGoodSize; 226 228 using WTF::fastMallocSize; 227 229 using WTF::fastRealloc; -
trunk/Source/WTF/wtf/Vector.h
r141504 r141716 253 253 { 254 254 ASSERT(newCapacity); 255 m_capacity = newCapacity;256 255 if (newCapacity > std::numeric_limits<size_t>::max() / sizeof(T)) 257 256 CRASH(); 258 m_buffer = static_cast<T*>(fastMalloc(newCapacity * sizeof(T))); 257 size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T)); 258 m_capacity = sizeToAllocate / sizeof(T); 259 m_buffer = static_cast<T*>(fastMalloc(sizeToAllocate)); 259 260 } 260 261 … … 265 266 return false; 266 267 268 size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T)); 267 269 T* newBuffer; 268 if (tryFastMalloc( newCapacity * sizeof(T)).getValue(newBuffer)) {269 m_capacity = newCapacity;270 if (tryFastMalloc(sizeToAllocate).getValue(newBuffer)) { 271 m_capacity = sizeToAllocate / sizeof(T); 270 272 m_buffer = newBuffer; 271 273 return true; … … 282 284 { 283 285 ASSERT(shouldReallocateBuffer(newCapacity)); 284 m_capacity = newCapacity;285 286 if (newCapacity > std::numeric_limits<size_t>::max() / sizeof(T)) 286 287 CRASH(); 287 m_buffer = static_cast<T*>(fastRealloc(m_buffer, newCapacity * sizeof(T))); 288 size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T)); 289 m_capacity = sizeToAllocate / sizeof(T); 290 m_buffer = static_cast<T*>(fastRealloc(m_buffer, sizeToAllocate)); 288 291 } 289 292
Note: See TracChangeset
for help on using the changeset viewer.