Changeset 27711 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 12, 2007, 12:00:29 AM (18 years ago)
Author:
oliver
Message:

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.

Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r27710 r27711  
     12007-11-11  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Add special fastZeroedMalloc function to replace a
     6        number of fastCalloc calls where one argument was 1.
     7       
     8        This results in a 0.4% progression in SunSpider, more
     9        than making up for the earlier regression caused by
     10        additional overflow checks.
     11
     12        * JavaScriptCore.exp:
     13        * kjs/array_instance.cpp:
     14        * kjs/property_map.cpp:
     15        * wtf/FastMalloc.cpp:
     16        * wtf/FastMalloc.h:
     17        * wtf/HashTable.h:
     18
    1192007-11-11  Adam Roben  <[email protected]>
    220
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r27695 r27711  
    231231__ZN3WTF10fastMallocEm
    232232__ZN3WTF11fastReallocEPvm
     233__ZN3WTF16fastZeroedMallocEm
    233234__ZN3WTF8fastFreeEPv
    234235__ZNK3KJS11Interpreter12builtinArrayEv
  • trunk/JavaScriptCore/kjs/array_instance.cpp

    r27448 r27711  
    7676    m_length = initialLength;
    7777    m_vectorLength = initialCapacity;
    78     m_storage = static_cast<ArrayStorage*>(fastCalloc(storageSize(initialCapacity), 1));
     78    m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
    7979
    8080    Collector::reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r27678 r27711  
    510510#endif
    511511
    512     m_u.table = static_cast<Table*>(fastCalloc(1, Table::allocationSize(newTableSize)));
     512    m_u.table = static_cast<Table*>(fastZeroedMalloc(Table::allocationSize(newTableSize)));
    513513    m_u.table->size = newTableSize;
    514514    m_u.table->sizeMask = newTableSize - 1;
     
    535535    Table* oldTable = m_u.table;
    536536   
    537     m_u.table = static_cast<Table*>(fastCalloc(1, Table::allocationSize(newTableSize)));
     537    m_u.table = static_cast<Table*>(fastZeroedMalloc(Table::allocationSize(newTableSize)));
    538538    m_u.table->size = newTableSize;
    539539    m_u.table->sizeMask = newTableSize - 1;
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r27698 r27711  
    128128#endif // NDEBUG
    129129
     130#include <string.h>
     131
     132namespace WTF {
     133void *fastZeroedMalloc(size_t n)
     134{
     135    void *result = fastMalloc(n);
     136    if (!result)
     137        return 0;
     138    memset(result, 0, n);
     139#ifndef WTF_CHANGES
     140    MallocHook::InvokeNewHook(result, n);
     141#endif
     142    return result;
     143}
     144   
     145}
     146
    130147#if FORCE_SYSTEM_MALLOC
    131148
     
    190207#include <stddef.h>
    191208#include <stdio.h>
    192 #include <string.h>
    193209#if COMPILER(MSVC)
    194210#define WIN32_LEAN_AND_MEAN
  • trunk/JavaScriptCore/wtf/FastMalloc.h

    r27297 r27711  
    3131
    3232    void *fastMalloc(size_t n);
     33    void *fastZeroedMalloc(size_t n);
    3334    void *fastCalloc(size_t n_elements, size_t element_size);
    3435    void fastFree(void* p);
  • trunk/JavaScriptCore/wtf/HashTable.h

    r27710 r27711  
    827827        // gcc doesn't appear to support that
    828828        if (Traits::emptyValueIsZero)
    829             return static_cast<ValueType *>(fastCalloc(size, sizeof(ValueType)));
     829            return static_cast<ValueType *>(fastZeroedMalloc(size * sizeof(ValueType)));
    830830        ValueType* result = static_cast<ValueType*>(fastMalloc(size * sizeof(ValueType)));
    831831        for (int i = 0; i < size; i++)
Note: See TracChangeset for help on using the changeset viewer.