Ignore:
Timestamp:
Apr 14, 2005, 6:26:26 PM (20 years ago)
Author:
mjs
Message:

Reviewed by Richard.

<rdar://problem/4089734> JavaScript iBench can be sped up ~10% with custom allocator

  • use custom single-threaded malloc for all non-GC JavaScriptCore allocations, for a 9.1% speedup on JavaScript iBench
  • JavaScriptCore.pbproj/project.pbxproj:
  • kjs/collector.cpp: (KJS::Collector::allocate): Use dlmalloc to allocate the collector blocks. (KJS::Collector::collect): And dlfree to free it.
  • kjs/fast_malloc.cpp: Added, just the standard dlmalloc here.
  • kjs/fast_malloc.h: Added. Declarations for the functions. Also added a handy macro to give a class custom operator new/delete
  • kjs/identifier.cpp: (KJS::Identifier::add): Use dlmalloc/dlfree.
  • kjs/nodes.h: make nodes KJS_FAST_ALLOCATED.
  • kjs/property_map.cpp: (KJS::PropertyMap::~PropertyMap): Use dlmalloc/dlfree. (KJS::PropertyMap::rehash): ditto
  • kjs/scope_chain.h:
  • kjs/ustring.cpp: (KJS::UString::Rep::createCopying): New named constructor that copies a passed-in buffer, to hide allocation details from webcore. (KJS::UString::UString): use createCopying when appropriate. (KJS::UString::Rep::destroy): Use dlmalloc/dlfree. (KJS::UString::expandedSize): likewise (KJS::UString::expandCapacity): likewise (KJS::UString::expandPreCapacity): likewise (KJS::UString::spliceSubstringsWithSeparators): likewise (KJS::UString::append): likewise (KJS::UString::operator=): likewise (KJS::UString::detach): likewise
  • kjs/ustring.h: make UString and UString::Rep KJS_FAST_ALLOCATED.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/identifier.cpp

    r6360 r9009  
    3636#include "identifier.h"
    3737
     38#include "fast_malloc.h"
     39
    3840#define DUMP_STATISTICS 0
    3941
     
    123125    }
    124126   
    125     UChar *d = static_cast<UChar *>(malloc(sizeof(UChar) * length));
     127    UChar *d = static_cast<UChar *>(kjs_fast_malloc(sizeof(UChar) * length));
    126128    for (int j = 0; j != length; j++)
    127129        d[j] = c[j];
     
    162164    }
    163165   
    164     UChar *d = static_cast<UChar *>(malloc(sizeof(UChar) * length));
     166    UChar *d = static_cast<UChar *>(kjs_fast_malloc(sizeof(UChar) * length));
    165167    for (int j = 0; j != length; j++)
    166168        d[j] = s[j];
Note: See TracChangeset for help on using the changeset viewer.