Commit aed0ae6d authored by oliver's avatar oliver

Add special fastZeroedMalloc function to replace a

number of fastCalloc calls where one argument was 1.

Reviewed by Darin.

This results in a 0.4% progression in SunSpider, more
than making up for the earlier regression caused by
additional overflow checks.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 390aaf4f
2007-11-11 Oliver Hunt <oliver@apple.com>
Reviewed by Darin.
Add special fastZeroedMalloc function to replace a
number of fastCalloc calls where one argument was 1.
This results in a 0.4% progression in SunSpider, more
than making up for the earlier regression caused by
additional overflow checks.
* JavaScriptCore.exp:
* kjs/array_instance.cpp:
* kjs/property_map.cpp:
* wtf/FastMalloc.cpp:
* wtf/FastMalloc.h:
* wtf/HashTable.h:
2007-11-11 Adam Roben <aroben@apple.com>
Fix <rdar://5578982> ASSERT in HashTable::checkTableConsistencyExceptSize beneath WebNotificationCenter
......
......@@ -230,6 +230,7 @@ __ZN3KJSeqERKNS_7UStringEPKc
__ZN3WTF10fastCallocEmm
__ZN3WTF10fastMallocEm
__ZN3WTF11fastReallocEPvm
__ZN3WTF16fastZeroedMallocEm
__ZN3WTF8fastFreeEPv
__ZNK3KJS11Interpreter12builtinArrayEv
__ZNK3KJS11Interpreter12globalObjectEv
......
......@@ -75,7 +75,7 @@ ArrayInstance::ArrayInstance(JSObject* prototype, unsigned initialLength)
m_length = initialLength;
m_vectorLength = initialCapacity;
m_storage = static_cast<ArrayStorage*>(fastCalloc(storageSize(initialCapacity), 1));
m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
Collector::reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
}
......
......@@ -509,7 +509,7 @@ void PropertyMap::createTable()
JSValue* oldSingleEntryValue = m_u.singleEntryValue;
#endif
m_u.table = static_cast<Table*>(fastCalloc(1, Table::allocationSize(newTableSize)));
m_u.table = static_cast<Table*>(fastZeroedMalloc(Table::allocationSize(newTableSize)));
m_u.table->size = newTableSize;
m_u.table->sizeMask = newTableSize - 1;
m_usingTable = true;
......@@ -534,7 +534,7 @@ void PropertyMap::rehash(unsigned newTableSize)
Table* oldTable = m_u.table;
m_u.table = static_cast<Table*>(fastCalloc(1, Table::allocationSize(newTableSize)));
m_u.table = static_cast<Table*>(fastZeroedMalloc(Table::allocationSize(newTableSize)));
m_u.table->size = newTableSize;
m_u.table->sizeMask = newTableSize - 1;
......
......@@ -127,6 +127,23 @@ void fastMallocAllow()
} // namespace WTF
#endif // NDEBUG
#include <string.h>
namespace WTF {
void *fastZeroedMalloc(size_t n)
{
void *result = fastMalloc(n);
if (!result)
return 0;
memset(result, 0, n);
#ifndef WTF_CHANGES
MallocHook::InvokeNewHook(result, n);
#endif
return result;
}
}
#if FORCE_SYSTEM_MALLOC
#include <stdlib.h>
......@@ -189,7 +206,6 @@ extern "C" const int jscore_fastmalloc_introspection = 0;
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#if COMPILER(MSVC)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
......
......@@ -30,6 +30,7 @@
namespace WTF {
void *fastMalloc(size_t n);
void *fastZeroedMalloc(size_t n);
void *fastCalloc(size_t n_elements, size_t element_size);
void fastFree(void* p);
void *fastRealloc(void* p, size_t n);
......
......@@ -826,7 +826,7 @@ namespace WTF {
// would use a template member function with explicit specializations here, but
// gcc doesn't appear to support that
if (Traits::emptyValueIsZero)
return static_cast<ValueType *>(fastCalloc(size, sizeof(ValueType)));
return static_cast<ValueType *>(fastZeroedMalloc(size * sizeof(ValueType)));
ValueType* result = static_cast<ValueType*>(fastMalloc(size * sizeof(ValueType)));
for (int i = 0; i < size; i++)
initializeBucket(result[i]);
......
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