Vector should consult allocator about ideal size when choosing capacity.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Feb 2013 13:37:41 +0000 (13:37 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Feb 2013 13:37:41 +0000 (13:37 +0000)
commit1c2c6a92cc47ff87b55acc9c5c523c663ca64baa
tree475e304e4b5fb52467476d2498559b1be8e945b1
parent8fca31bd8e2221acfb74ad3174399a6bb3974991
Vector should consult allocator about ideal size when choosing capacity.
<http://webkit.org/b/108410>
<rdar://problem/13124002>

Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Remove assertion about Vector capacity that won't hold anymore since capacity()
may not be what you passed to reserveCapacity().
Also export WTF::fastMallocGoodSize() for Windows builds.

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreExports.def:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):

Source/WTF:

Added WTF::fastMallocGoodSize(), a workalike/wrapper for OS X's malloc_good_size().
It returns the actual size of the block that will get allocated for a given byte size.

Vector's internal buffer now checks with the allocator if the resulting allocation
could actually house more objects and updates its capacity to make use of the space.

* wtf/Deque.h:
(WTF::::expandCapacity):
* wtf/FastMalloc.cpp:
(WTF::fastMallocGoodSize):
* wtf/FastMalloc.h:
* wtf/Vector.h:
(WTF::VectorBufferBase::allocateBuffer):
(WTF::VectorBufferBase::tryAllocateBuffer):
(WTF::VectorBufferBase::reallocateBuffer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141716 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreExports.def
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Deque.h
Source/WTF/wtf/FastMalloc.cpp
Source/WTF/wtf/FastMalloc.h
Source/WTF/wtf/Vector.h