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


Ignore:
Timestamp:
Oct 7, 2008, 1:49:36 PM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Cameron Zwarich.

Roll r37370 back in with bug fixes.

  • PropertyMap::storageSize() should reflect the number of keys + deletedOffsets and has nothing to do with the internal deletedSentinel count anymore.
File:
1 edited

Legend:

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

    r37381 r37388  
    123123        JSValue* getDirect(const Identifier& propertyName) const
    124124        {
    125             size_t offset = m_structureID->propertyMap().getOffset(propertyName);
     125            size_t offset = m_structureID->propertyMap().get(propertyName);
    126126            return offset != WTF::notFound ? m_propertyStorage[offset] : 0;
    127127        }
     
    129129        JSValue** getDirectLocation(const Identifier& propertyName)
    130130        {
    131             size_t offset = m_structureID->propertyMap().getOffset(propertyName);
     131            size_t offset = m_structureID->propertyMap().get(propertyName);
    132132            return offset != WTF::notFound ? locationForOffset(offset) : 0;
    133133        }
     
    135135        JSValue** getDirectLocation(const Identifier& propertyName, unsigned& attributes)
    136136        {
    137             size_t offset = m_structureID->propertyMap().getOffset(propertyName, attributes);
     137            size_t offset = m_structureID->propertyMap().get(propertyName, attributes);
    138138            return offset != WTF::notFound ? locationForOffset(offset) : 0;
    139139        }
     
    179179
    180180        static const size_t inlineStorageCapacity = 2;
     181        static const size_t nonInlineBaseStorageCapacity = 16;
    181182
    182183        static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(ObjectType)); }
     
    365366    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    366367
    367      if (m_structureID->isDictionary()) {
    368          unsigned currentAttributes;
    369          size_t offset = m_structureID->propertyMap().getOffset(propertyName, currentAttributes);
    370          if (offset != WTF::notFound) {
    371              if (checkReadOnly && currentAttributes & ReadOnly)
    372                  return;
    373              m_propertyStorage[offset] = value;
    374              slot.setExistingProperty(this, offset);
    375              return;
    376          }
    377 
    378          if (m_structureID->propertyMap().storageSize() == inlineStorageCapacity)
    379              allocatePropertyStorage(m_structureID->propertyMap().storageSize(), m_structureID->propertyMap().size());
    380          m_structureID->propertyMap().put(propertyName, value, attributes, checkReadOnly, this, slot, m_propertyStorage);
    381          m_structureID->clearEnumerationCache();
    382          return;
    383      }
     368    if (m_structureID->isDictionary()) {
     369        unsigned currentAttributes;
     370        size_t offset = m_structureID->propertyMap().get(propertyName, currentAttributes);
     371        if (offset != WTF::notFound) {
     372            if (checkReadOnly && currentAttributes & ReadOnly)
     373                return;
     374            m_propertyStorage[offset] = value;
     375            slot.setExistingProperty(this, offset);
     376            return;
     377        }
     378
     379        size_t currentCapacity = m_structureID->propertyStorageCapacity();
     380        offset = m_structureID->propertyMap().put(propertyName, attributes);
     381        if (m_structureID->propertyMap().storageSize() > m_structureID->propertyStorageCapacity()) {
     382            m_structureID->growPropertyStorageCapacity();
     383            allocatePropertyStorage(currentCapacity, m_structureID->propertyStorageCapacity());
     384        }
     385
     386        m_propertyStorage[offset] = value;
     387        slot.setNewProperty(this, offset);
     388        m_structureID->clearEnumerationCache();
     389        return;
     390    }
    384391
    385392    unsigned currentAttributes;
    386     size_t offset = m_structureID->propertyMap().getOffset(propertyName, currentAttributes);
     393    size_t offset = m_structureID->propertyMap().get(propertyName, currentAttributes);
    387394    if (offset != WTF::notFound) {
    388395        if (checkReadOnly && currentAttributes & ReadOnly)
     
    393400    }
    394401
    395      if (m_structureID->propertyMap().storageSize() == inlineStorageCapacity)
    396          allocatePropertyStorage(m_structureID->propertyMap().storageSize(), m_structureID->propertyMap().size());
    397 
    398      RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, value, attributes, this, slot, m_propertyStorage);
    399      slot.setWasTransition(true);
    400      setStructureID(structureID.release());
     402    size_t currentCapacity = m_structureID->propertyStorageCapacity();
     403    RefPtr<StructureID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, attributes, offset);
     404    if (currentCapacity != structureID->propertyStorageCapacity())
     405        allocatePropertyStorage(currentCapacity, structureID->propertyStorageCapacity());
     406
     407    ASSERT(offset < structureID->propertyStorageCapacity());
     408    m_propertyStorage[offset] = value;
     409    slot.setNewProperty(this, offset);
     410    slot.setWasTransition(true);
     411    setStructureID(structureID.release());
    401412}
    402413
    403414inline void JSObject::transitionTo(StructureID* newStructureID)
    404415{
    405     StructureID::transitionTo(m_structureID, newStructureID, this);
     416    if (m_structureID->propertyStorageCapacity() != newStructureID->propertyStorageCapacity())
     417        allocatePropertyStorage(m_structureID->propertyStorageCapacity(), newStructureID->propertyStorageCapacity());
    406418    setStructureID(newStructureID);
    407419}
Note: See TracChangeset for help on using the changeset viewer.