Changeset 37321 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Oct 5, 2008, 5:58:42 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-05 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak.

Avoid an extra lookup when transitioning to an existing StructureID
by caching the offset of property that caused the transition.

1% win on V8 suite. Wash on SunSpider.

  • kjs/PropertyMap.cpp: (JSC::PropertyMap::put):
  • kjs/PropertyMap.h:
  • kjs/StructureID.cpp: (JSC::StructureID::StructureID): (JSC::StructureID::addPropertyTransition):
  • kjs/StructureID.h: (JSC::StructureID::setCachedTransistionOffset): (JSC::StructureID::cachedTransistionOffset):
Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r37320 r37321  
     12008-10-05  Sam Weinig  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Avoid an extra lookup when transitioning to an existing StructureID
     6        by caching the offset of property that caused the transition.
     7
     8        1% win on V8 suite.  Wash on SunSpider.
     9
     10        * kjs/PropertyMap.cpp:
     11        (JSC::PropertyMap::put):
     12        * kjs/PropertyMap.h:
     13        * kjs/StructureID.cpp:
     14        (JSC::StructureID::StructureID):
     15        (JSC::StructureID::addPropertyTransition):
     16        * kjs/StructureID.h:
     17        (JSC::StructureID::setCachedTransistionOffset):
     18        (JSC::StructureID::cachedTransistionOffset):
     19
    1202008-10-05  Cameron Zwarich  <[email protected]>
    221
  • trunk/JavaScriptCore/kjs/PropertyMap.cpp

    r36847 r37321  
    115115}
    116116
    117 void PropertyMap::put(const Identifier& propertyName, JSValue* value, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot& slot, PropertyStorage& propertyStorage)
     117size_t PropertyMap::put(const Identifier& propertyName, JSValue* value, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot& slot, PropertyStorage& propertyStorage)
    118118{
    119119    ASSERT(!propertyName.isNull());
     
    145145        if (m_table->entries()[entryIndex - 1].key == rep) {
    146146            if (checkReadOnly && (m_table->entries()[entryIndex - 1].attributes & ReadOnly))
    147                 return;
     147                return WTF::notFound;
    148148            // Put a new value in an existing hash table entry.
    149149            propertyStorage[entryIndex - 2] = value;
    150150            // Attributes are intentionally not updated.
    151151            slot.setExistingProperty(slotBase, entryIndex - 2);
    152             return;
     152            return entryIndex - 2;
    153153        } else if (entryIndex == deletedSentinelIndex) {
    154154            // If we find a deleted-element sentinel, remember it for use later.
     
    203203    checkConsistency(propertyStorage);
    204204    slot.setNewProperty(slotBase, entryIndex - 2);
     205    return entryIndex - 2;
    205206}
    206207
  • trunk/JavaScriptCore/kjs/PropertyMap.h

    r36847 r37321  
    9595        bool isEmpty() { return !m_table; }
    9696
    97         void put(const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&, PropertyStorage&);
     97        size_t put(const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&, PropertyStorage&);
    9898        void remove(const Identifier& propertyName, PropertyStorage&);
    9999
  • trunk/JavaScriptCore/kjs/StructureID.cpp

    r37300 r37321  
    4545    , m_nameInPrevious(0)
    4646    , m_transitionCount(0)
     47    , m_cachedTransistionOffset(WTF::notFound)
    4748{
    4849    ASSERT(m_prototype);
     
    117118            slotBase->allocatePropertyStorage(structureID->m_propertyMap.size(), existingTransition->m_propertyMap.size());
    118119
    119         size_t offset = existingTransition->propertyMap().getOffset(propertyName);
     120        size_t offset = existingTransition->cachedTransistionOffset();
    120121        ASSERT(offset != WTF::notFound);
    121122        propertyStorage[offset] = value;
     
    139140    transition->m_propertyMap = structureID->m_propertyMap;
    140141
    141     transition->m_propertyMap.put(propertyName, value, attributes, false, slotBase, slot, propertyStorage);
     142    size_t offset = transition->m_propertyMap.put(propertyName, value, attributes, false, slotBase, slot, propertyStorage);
     143    transition->setCachedTransistionOffset(offset);
    142144
    143145    structureID->m_transitionTable.add(make_pair(propertyName.ustring().rep(), attributes), transition.get());
  • trunk/JavaScriptCore/kjs/StructureID.h

    r36789 r37321  
    116116        PropertyMap& propertyMap() { return m_propertyMap; }
    117117
     118        void setCachedTransistionOffset(size_t offset) { m_cachedTransistionOffset = offset; }
     119        size_t cachedTransistionOffset() const { return m_cachedTransistionOffset; }
     120
    118121        void getEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*);
    119122        void clearEnumerationCache();
     
    146149
    147150        PropertyMap m_propertyMap;
     151
     152        size_t m_cachedTransistionOffset;
    148153    };
    149154
Note: See TracChangeset for help on using the changeset viewer.