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


Ignore:
Timestamp:
Sep 10, 2008, 7:42:18 PM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Geoff Garen.

Add inline property storage for JSObject.

1.2% progression on Sunspider. .5% progression on the v8 test suite.

  • JavaScriptCore.exp:
  • VM/CTI.cpp: (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain):
  • kjs/JSObject.cpp: (JSC::JSObject::mark): There is no reason to check storageSize now that we start from 0. (JSC::JSObject::allocatePropertyStorage): Allocates/reallocates heap storage.
  • kjs/JSObject.h: (JSC::JSObject::offsetForLocation): m_propertyStorage is not an OwnArrayPtr now so there is no reason to .get() (JSC::JSObject::usingInlineStorage): (JSC::JSObject::JSObject): Start with m_propertyStorage pointing to the inline storage. (JSC::JSObject::~JSObject): Free the heap storage if not using the inline storage. (JSC::JSObject::putDirect): Switch to the heap storage only when we know we know that we are about to add a property that will overflow the inline storage.
  • kjs/PropertyMap.cpp: (JSC::PropertyMap::createTable): Don't allocate the propertyStorage, that is now handled by JSObject. (JSC::PropertyMap::rehash): PropertyStorage is not a OwnArrayPtr anymore.
  • kjs/PropertyMap.h: (JSC::PropertyMap::storageSize): Rename from markingCount.
  • kjs/StructureID.cpp: (JSC::StructureID::addPropertyTransition): Don't resize the property storage if we are using inline storage.
  • kjs/StructureID.h:
File:
1 edited

Legend:

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

    r36316 r36325  
    143143        size_t offsetForLocation(JSValue** location)
    144144        {
    145             return location - m_propertyStorage.get();
     145            return location - m_propertyStorage;
    146146        }
    147147
     
    176176        virtual bool isNotAnObjectErrorStub() const { return false; }
    177177
     178        void allocatePropertyStorage(size_t oldSize, size_t newSize);
     179        bool usingInlineStorage() const { return m_propertyStorage == m_inlineStorage; }
     180
    178181    protected:
    179182        bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable);
     
    185188        StructureID* createInheritorID();
    186189
    187         PropertyStorage m_propertyStorage;
     190        static const size_t inlineStorageCapacity = 2;
     191
    188192        RefPtr<StructureID> m_inheritorID;
     193
     194        PropertyStorage m_propertyStorage;       
     195        JSValue* m_inlineStorage[inlineStorageCapacity];
    189196    };
    190197
     
    193200inline JSObject::JSObject(JSObject* prototype)
    194201    : JSCell(prototype->inheritorID())
     202    , m_propertyStorage(m_inlineStorage)
    195203{
    196204    ASSERT(m_structureID);
     
    202210inline JSObject::JSObject(PassRefPtr<StructureID> structureID)
    203211    : JSCell(structureID.releaseRef()) // ~JSObject balances this ref()
     212    , m_propertyStorage(m_inlineStorage)
    204213{
    205214    ASSERT(m_structureID);
     
    209218{
    210219    ASSERT(m_structureID);
     220    if (m_propertyStorage != m_inlineStorage)
     221        delete [] m_propertyStorage;
    211222    m_structureID->deref();
    212223}
     
    365376
    366377     if (m_structureID->isDictionary()) {
     378         unsigned currentAttributes;
     379         size_t offset = m_structureID->propertyMap().getOffset(propertyName, currentAttributes);
     380         if (offset != WTF::notFound) {
     381             if (checkReadOnly && currentAttributes & ReadOnly)
     382                 return;
     383             m_propertyStorage[offset] = value;
     384             slot.setExistingProperty(this, offset);
     385             return;
     386         }
     387
     388         if (m_structureID->propertyMap().storageSize() == inlineStorageCapacity)
     389             allocatePropertyStorage(m_structureID->propertyMap().storageSize(), m_structureID->propertyMap().size());
    367390         m_structureID->propertyMap().put(propertyName, value, attributes, checkReadOnly, this, slot, m_propertyStorage);
    368391         return;
     
    379402     }
    380403
    381      RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, value, attributes, checkReadOnly, this, slot, m_propertyStorage);
     404     if (m_structureID->propertyMap().storageSize() == inlineStorageCapacity)
     405         allocatePropertyStorage(m_structureID->propertyMap().storageSize(), m_structureID->propertyMap().size());
     406
     407     RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, value, attributes, this, slot, m_propertyStorage);
    382408     setStructureID(structureID.release());
    383409}
Note: See TracChangeset for help on using the changeset viewer.