Commit ed1d7c76 authored by msaboff@apple.com's avatar msaboff@apple.com

2010-09-27 Michael Saboff <msaboff@apple.com>

        Reviewed by Geoffrey Garen.

        Changed the initialization of JSArray objects to have space for
        3 elements for the constructor that takes a ArgList argument.
        This improves v8-deltablue performance by about 2.8% by reducing
        the number of realloc() calls.
        https://bugs.webkit.org/show_bug.cgi?id=46664

        * runtime/JSArray.cpp:
        (JSC::JSArray::JSArray):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 026746c5
2010-09-27 Michael Saboff <msaboff@apple.com>
Reviewed by Geoffrey Garen.
Changed the initialization of JSArray objects to have space for
3 elements for the constructor that takes a ArgList argument.
This improves v8-deltablue performance by about 2.8% by reducing
the number of realloc() calls.
https://bugs.webkit.org/show_bug.cgi?id=46664
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
2010-09-27 Gavin Barraclough <barraclough@apple.com>
Reviewed by Darin Adler.
......
......@@ -202,12 +202,20 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure, const ArgList& list)
: JSObject(structure)
{
unsigned initialCapacity = list.size();
m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
unsigned initialStorage;
// If the ArgList is empty, allocate space for 3 entries. This value empirically
// works well for benchmarks.
if (!initialCapacity)
initialStorage = 3;
else
initialStorage = initialCapacity;
m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialStorage)));
m_storage->m_allocBase = m_storage;
m_indexBias = 0;
m_storage->m_length = initialCapacity;
m_vectorLength = initialCapacity;
m_vectorLength = initialStorage;
m_storage->m_numValuesInVector = initialCapacity;
m_storage->m_sparseValueMap = 0;
m_storage->subclassData = 0;
......@@ -221,10 +229,12 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure, const ArgList& list)
ArgList::const_iterator end = list.end();
for (ArgList::const_iterator it = list.begin(); it != end; ++it, ++i)
vector[i] = *it;
for (; i < initialStorage; i++)
vector[i] = JSValue();
checkConsistency();
Heap::heap(this)->reportExtraMemoryCost(storageSize(initialCapacity));
Heap::heap(this)->reportExtraMemoryCost(storageSize(initialStorage));
}
JSArray::~JSArray()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment