Changeset 36401 in webkit for trunk/JavaScriptCore/kjs/JSObject.h


Ignore:
Timestamp:
Sep 14, 2008, 1:18:49 AM (17 years ago)
Author:
[email protected]
Message:

Bug 20821: Cache property transitions to speed up object initialization
https://bugs.webkit.org/show_bug.cgi?id=20821

Reviewed by Cameron Zwarich.

Implement a transition cache to improve the performance of new properties
being added to objects. This is extremely beneficial in constructors and
shows up as a 34% improvement on access-binary-trees in SunSpider (0.8%
overall)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSObject.h

    r36368 r36401  
    151151        }
    152152
     153        void transitionTo(StructureID*);
     154
    153155        void removeDirect(const Identifier& propertyName);
    154156        bool hasCustomProperties() { return !m_structureID->propertyMap().isEmpty(); }
     
    179181        bool usingInlineStorage() const { return m_propertyStorage == m_inlineStorage; }
    180182
     183        static const size_t inlineStorageCapacity = 2;
     184
    181185    protected:
    182186        bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable);
     
    185189        const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
    186190        StructureID* createInheritorID();
    187 
    188         static const size_t inlineStorageCapacity = 2;
    189191
    190192        RefPtr<StructureID> m_inheritorID;
     
    390392     }
    391393
    392      unsigned currentAttributes;
    393      size_t offset = m_structureID->propertyMap().getOffset(propertyName, currentAttributes);
    394      if (offset != WTF::notFound) {
    395          if (checkReadOnly && currentAttributes & ReadOnly)
    396              return;
    397          m_propertyStorage[offset] = value;
    398          slot.setExistingProperty(this, offset);
    399          return;
    400      }
     394    unsigned currentAttributes;
     395    size_t offset = m_structureID->propertyMap().getOffset(propertyName, currentAttributes);
     396    if (offset != WTF::notFound) {
     397        if (checkReadOnly && currentAttributes & ReadOnly)
     398            return;
     399        m_propertyStorage[offset] = value;
     400        slot.setExistingProperty(this, offset);
     401        return;
     402    }
    401403
    402404     if (m_structureID->propertyMap().storageSize() == inlineStorageCapacity)
     
    404406
    405407     RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, value, attributes, this, slot, m_propertyStorage);
     408     slot.setWasTransition(true);
    406409     setStructureID(structureID.release());
     410}
     411
     412inline void JSObject::transitionTo(StructureID* newStructureID)
     413{
     414    StructureID::transitionTo(m_structureID, newStructureID, this);
     415    setStructureID(newStructureID);
    407416}
    408417
Note: See TracChangeset for help on using the changeset viewer.