Changeset 36847 in webkit


Ignore:
Timestamp:
Sep 24, 2008 1:11:35 AM (16 years ago)
Author:
mjs@apple.com
Message:

2008-09-24 Maciej Stachowiak <mjs@apple.com>

Reviewed by Oliver Hunt.


  • inline PropertyMap::getOffset to speed up polymorphic lookups


~1.5% speedup on v8 benchmark
no effect on SunSpider

  • JavaScriptCore.exp:
  • kjs/PropertyMap.cpp:
  • kjs/PropertyMap.h: (JSC::PropertyMap::getOffset):
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36846 r36847  
     12008-09-24  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4       
     5        - inline PropertyMap::getOffset to speed up polymorphic lookups
     6       
     7        ~1.5% speedup on v8 benchmark
     8        no effect on SunSpider
     9
     10        * JavaScriptCore.exp:
     11        * kjs/PropertyMap.cpp:
     12        * kjs/PropertyMap.h:
     13        (JSC::PropertyMap::getOffset):
     14
    1152008-09-24  Jan Michael Alonzo  <jmalonzo@webkit.org>
    216
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r36821 r36847  
    110110__ZN3JSC11ProgramNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm16EEEPNS_14SourceProviderEbbi
    111111__ZN3JSC11PropertyMap3putERKNS_10IdentifierEPNS_7JSValueEjbPNS_8JSObjectERNS_15PutPropertySlotERPS5_
    112 __ZN3JSC11PropertyMap9getOffsetERKNS_10IdentifierE
    113112__ZN3JSC11PropertyMap9getOffsetERKNS_10IdentifierERj
    114113__ZN3JSC11PropertyMapD1Ev
  • trunk/JavaScriptCore/kjs/PropertyMap.cpp

    r36701 r36847  
    3636#ifndef NDEBUG
    3737#define DO_PROPERTYMAP_CONSTENCY_CHECK 0
    38 #define DUMP_PROPERTYMAP_STATS 0
    3938#else
    4039#define DO_PROPERTYMAP_CONSTENCY_CHECK 0
    41 #define DUMP_PROPERTYMAP_STATS 0
    4240#endif
    4341
     
    7674#endif
    7775
    78 static const unsigned emptyEntryIndex = 0;
    7976static const unsigned deletedSentinelIndex = 1;
    8077
     
    271268}
    272269
    273 size_t PropertyMap::getOffset(const Identifier& propertyName)
    274 {
    275     ASSERT(!propertyName.isNull());
    276 
    277     if (!m_table)
    278         return WTF::notFound;
    279 
    280     UString::Rep* rep = propertyName._ustring.rep();
    281 
    282     unsigned i = rep->computedHash();
    283 
    284 #if DUMP_PROPERTYMAP_STATS
    285     ++numProbes;
    286 #endif
    287 
    288     unsigned entryIndex = m_table->entryIndices[i & m_table->sizeMask];
    289     if (entryIndex == emptyEntryIndex)
    290         return WTF::notFound;
    291 
    292     if (rep == m_table->entries()[entryIndex - 1].key)
    293         return entryIndex - 2;
    294 
    295 #if DUMP_PROPERTYMAP_STATS
    296     ++numCollisions;
    297 #endif
    298 
    299     unsigned k = 1 | doubleHash(rep->computedHash());
    300 
    301     while (1) {
    302         i += k;
    303 
    304 #if DUMP_PROPERTYMAP_STATS
    305         ++numRehashes;
    306 #endif
    307 
    308         entryIndex = m_table->entryIndices[i & m_table->sizeMask];
    309         if (entryIndex == emptyEntryIndex)
    310             return WTF::notFound;
    311 
    312         if (rep == m_table->entries()[entryIndex - 1].key)
    313             return entryIndex - 2;
    314     }
    315 }
    316 
    317270size_t PropertyMap::getOffset(const Identifier& propertyName, unsigned& attributes)
    318271{
  • trunk/JavaScriptCore/kjs/PropertyMap.h

    r36701 r36847  
    2626#include <wtf/OwnArrayPtr.h>
    2727#include <wtf/NotFound.h>
     28
     29#ifndef NDEBUG
     30#define DUMP_PROPERTYMAP_STATS 0
     31#else
     32#define DUMP_PROPERTYMAP_STATS 0
     33#endif
    2834
    2935namespace JSC {
     
    103109        unsigned storageSize() const { return m_table ? m_table->keyCount + m_table->deletedSentinelCount : 0; }
    104110
     111        static const unsigned emptyEntryIndex = 0;
     112
    105113    private:
    106114        typedef PropertyMapEntry Entry;
     
    126134    }
    127135
     136    inline size_t PropertyMap::getOffset(const Identifier& propertyName)
     137    {
     138        ASSERT(!propertyName.isNull());
     139
     140        if (!m_table)
     141            return WTF::notFound;
     142
     143        UString::Rep* rep = propertyName._ustring.rep();
     144
     145        unsigned i = rep->computedHash();
     146
     147#if DUMP_PROPERTYMAP_STATS
     148        ++numProbes;
     149#endif
     150
     151        unsigned entryIndex = m_table->entryIndices[i & m_table->sizeMask];
     152        if (entryIndex == emptyEntryIndex)
     153            return WTF::notFound;
     154
     155        if (rep == m_table->entries()[entryIndex - 1].key)
     156            return entryIndex - 2;
     157
     158#if DUMP_PROPERTYMAP_STATS
     159        ++numCollisions;
     160#endif
     161
     162        unsigned k = 1 | WTF::doubleHash(rep->computedHash());
     163
     164        while (1) {
     165            i += k;
     166
     167#if DUMP_PROPERTYMAP_STATS
     168            ++numRehashes;
     169#endif
     170
     171            entryIndex = m_table->entryIndices[i & m_table->sizeMask];
     172            if (entryIndex == emptyEntryIndex)
     173                return WTF::notFound;
     174
     175            if (rep == m_table->entries()[entryIndex - 1].key)
     176                return entryIndex - 2;
     177        }
     178    }
     179
    128180} // namespace JSC
    129181
Note: See TracChangeset for help on using the changeset viewer.