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


Ignore:
Timestamp:
Sep 8, 2008, 11:55:39 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Split storage of properties out of the PropertyMap and into the JSObject
to allow sharing PropertyMap on the StructureID. In order to get this
function correctly, the StructureID's transition mappings were changed to
transition based on property name and attribute pairs, instead of just
property name.

  • Removes the single property optimization now that the PropertyMap is shared. This will be replaced by in-lining some values on the JSObject.

This is a wash on Sunspider and a 6.7% win on the v8 test suite.

  • JavaScriptCore.base.exp:
  • VM/CTI.cpp: (JSC::CTI::privateCompileGetByIdSelf): Get the storage directly off the JSObject. (JSC::CTI::privateCompileGetByIdProto): Ditto. (JSC::CTI::privateCompileGetByIdChain): Ditto. (JSC::CTI::privateCompilePutByIdReplace): Ditto.
  • kjs/JSObject.cpp: (JSC::JSObject::mark): Mark the PropertyStorage. (JSC::JSObject::put): Update to get the propertyMap of the StructureID. (JSC::JSObject::deleteProperty): Ditto. (JSC::JSObject::defineGetter): Return early if the property is already a getter/setter. (JSC::JSObject::defineSetter): Ditto. (JSC::JSObject::getPropertyAttributes): Update to get the propertyMap of the StructureID (JSC::JSObject::getPropertyNames): Ditto. (JSC::JSObject::removeDirect): Ditto.
  • kjs/JSObject.h: Remove PropertyMap and add PropertyStorage. (JSC::JSObject::propertyStorage): return the PropertyStorage. (JSC::JSObject::getDirect): Update to get the propertyMap of the StructureID. (JSC::JSObject::getDirectLocation): Ditto. (JSC::JSObject::offsetForLocation): Compute location directly. (JSC::JSObject::hasCustomProperties): Update to get the propertyMap of the StructureID. (JSC::JSObject::hasGetterSetterProperties): Ditto. (JSC::JSObject::getDirectOffset): Get by indexing into PropertyStorage. (JSC::JSObject::putDirectOffset): Put by indexing into PropertyStorage. (JSC::JSObject::getOwnPropertySlotForWrite): Update to get the propertyMap of the StructureID. (JSC::JSObject::getOwnPropertySlot): Ditto. (JSC::JSObject::putDirect): Move putting into the StructureID unless the property already exists.
  • kjs/PropertyMap.cpp: Use the propertyStorage as the storage for the JSValues. (JSC::PropertyMap::checkConsistency): (JSC::PropertyMap::operator=): (JSC::PropertyMap::~PropertyMap): (JSC::PropertyMap::get): (JSC::PropertyMap::getLocation): (JSC::PropertyMap::put): (JSC::PropertyMap::getOffset): (JSC::PropertyMap::insert): (JSC::PropertyMap::expand): (JSC::PropertyMap::rehash): (JSC::PropertyMap::createTable): (JSC::PropertyMap::resizePropertyStorage): Resize the storage to match the size of the map (JSC::PropertyMap::remove): (JSC::PropertyMap::getEnumerablePropertyNames):
  • kjs/PropertyMap.h: (JSC::PropertyMapEntry::PropertyMapEntry): (JSC::PropertyMap::isEmpty): (JSC::PropertyMap::size): (JSC::PropertyMap::makingCount): (JSC::PropertyMap::PropertyMap):
  • kjs/StructureID.cpp: (JSC::StructureID::addPropertyTransition): Transitions now are based off the property name and attributes. (JSC::StructureID::toDictionaryTransition): Copy the map. (JSC::StructureID::changePrototypeTransition): Copy the map. (JSC::StructureID::getterSetterTransition): Copy the map. (JSC::StructureID::~StructureID):
  • kjs/StructureID.h: (JSC::TransitionTableHash::hash): Custom hash for transition map. (JSC::TransitionTableHash::equal): Ditto. (JSC::TransitionTableHashTraits::emptyValue): Custom traits for transition map (JSC::TransitionTableHashTraits::constructDeletedValue): Ditto. (JSC::TransitionTableHashTraits::isDeletedValue): Ditto. (JSC::StructureID::propertyMap): Added.

JavaScriptGlue:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Add forwarding headers.

  • ForwardingHeaders/wtf/HashFunctions.h: Added.
  • ForwardingHeaders/wtf/HashTraits.h: Added.

WebCore:

2008-09-08 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak and Oliver Hunt.

Add forwarding headers.

  • ForwardingHeaders/wtf/HashFunctions.h: Added.
File:
1 edited

Legend:

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

    r36263 r36285  
    7575        StructureID* inheritorID();
    7676
     77        PropertyStorage& propertyStorage() { return m_propertyStorage; }
     78
    7779        virtual UString className() const;
    7880
     
    121123
    122124        // This get function only looks at the property map.
    123         JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); }
    124         JSValue** getDirectLocation(const Identifier& propertyName) { return m_propertyMap.getLocation(propertyName); }
    125         JSValue** getDirectLocation(const Identifier& propertyName, bool& isWriteable) { return m_propertyMap.getLocation(propertyName, isWriteable); }
    126         size_t offsetForLocation(JSValue** location) { return m_propertyMap.offsetForLocation(location); }
     125        JSValue* getDirect(const Identifier& propertyName) const
     126        {
     127            return m_structureID->propertyMap().get(propertyName, m_propertyStorage);
     128        }
     129
     130        JSValue** getDirectLocation(const Identifier& propertyName)
     131        {
     132            return m_structureID->propertyMap().getLocation(propertyName, m_propertyStorage);
     133        }
     134
     135        JSValue** getDirectLocation(const Identifier& propertyName, bool& isWriteable)
     136        {
     137            return m_structureID->propertyMap().getLocation(propertyName, isWriteable, m_propertyStorage);
     138        }
     139
     140        size_t offsetForLocation(JSValue** location)
     141        {
     142            return location - m_propertyStorage.get();
     143        }
     144
    127145        void removeDirect(const Identifier& propertyName);
    128         bool hasCustomProperties() { return !m_propertyMap.isEmpty(); }
    129         bool hasGetterSetterProperties() { return m_propertyMap.hasGetterSetterProperties(); }
     146        bool hasCustomProperties() { return !m_structureID->propertyMap().isEmpty(); }
     147        bool hasGetterSetterProperties() { return m_structureID->propertyMap().hasGetterSetterProperties(); }
    130148
    131149        void putDirect(const Identifier& propertyName, JSValue* value, unsigned attr = 0);
     
    134152
    135153        // Fast access to known property offsets.
    136         JSValue* getDirectOffset(size_t offset) { return m_propertyMap.getOffset(offset); }
    137         void putDirectOffset(size_t offset, JSValue* v) { m_propertyMap.putOffset(offset, v); }
     154        JSValue* getDirectOffset(size_t offset) { return m_propertyStorage[offset]; }
     155        void putDirectOffset(size_t offset, JSValue* value) { m_propertyStorage[offset] = value; }
    138156
    139157        void fillGetterPropertySlot(PropertySlot&, JSValue** location);
     
    159177        StructureID* createInheritorID();
    160178
    161         PropertyMap m_propertyMap;
     179        PropertyStorage m_propertyStorage;
    162180        RefPtr<StructureID> m_inheritorID;
    163181    };
     
    285303{
    286304    if (JSValue** location = getDirectLocation(propertyName, slotIsWriteable)) {
    287         if (m_propertyMap.hasGetterSetterProperties() && location[0]->isGetterSetter()) {
     305        if (m_structureID->propertyMap().hasGetterSetterProperties() && location[0]->isGetterSetter()) {
    288306            slotIsWriteable = false;
    289307            fillGetterPropertySlot(slot, location);
     
    309327{
    310328    if (JSValue** location = getDirectLocation(propertyName)) {
    311         if (m_propertyMap.hasGetterSetterProperties() && location[0]->isGetterSetter())
     329        if (m_structureID->propertyMap().hasGetterSetterProperties() && location[0]->isGetterSetter())
    312330            fillGetterPropertySlot(slot, location);
    313331        else
     
    331349}
    332350
    333 inline void JSObject::putDirect(const Identifier& propertyName, JSValue* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot)
     351inline void JSObject::putDirect(const Identifier& propertyName, JSValue* value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)
    334352{
    335353    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    336     m_propertyMap.put(propertyName, value, attr, checkReadOnly, this, slot);
    337     if (slot.type() == PutPropertySlot::NewProperty) {
    338         if (!m_structureID->isDictionary()) {
    339             RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName);
    340             setStructureID(structureID.release());
    341         }
    342     }
     354
     355     if (m_structureID->isDictionary()) {
     356         m_structureID->propertyMap().put(propertyName, value, attributes, checkReadOnly, this, slot, m_propertyStorage);
     357         return;
     358     }
     359 
     360     bool isWriteable;
     361     size_t offset = m_structureID->propertyMap().getOffset(propertyName, isWriteable);
     362     if (offset != WTF::notFound) {
     363         if (checkReadOnly && !isWriteable)
     364             return;
     365         m_propertyStorage[offset] = value;
     366         slot.setExistingProperty(this, offset);
     367         return;
     368     }
     369 
     370     RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, value, attributes, checkReadOnly, this, slot, m_propertyStorage);
     371     setStructureID(structureID.release());
    343372}
    344373
Note: See TracChangeset for help on using the changeset viewer.