Changeset 39593 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 4, 2009, 4:18:53 PM (16 years ago)
Author:
[email protected]
Message:

2009-01-04 Alice Liu <[email protected]>

<rdar://problem/6341776> Merge m_transitionCount and m_offset in Structure.

Reviewed by Darin Adler.

  • runtime/Structure.cpp: (JSC::Structure::Structure): Remove m_transitionCount (JSC::Structure::addPropertyTransitionToExistingStructure): No need to wait until after the assignment to offset to assert if it's notFound; move it up. (JSC::Structure::addPropertyTransition): Use method for transitionCount instead of m_transitionCount. Remove line that maintains the m_transitionCount. (JSC::Structure::changePrototypeTransition): Remove line that maintains the m_transitionCount. (JSC::Structure::getterSetterTransition): Remove line that maintains the m_transitionCount.
  • runtime/Structure.h: Changed s_maxTransitionLength and m_offset from size_t to signed char. m_offset will never become greater than 64 because the structure transitions to a dictionary at that time. (JSC::Structure::transitionCount): method to replace the data member
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r39585 r39593  
     12009-01-04  Alice Liu  <[email protected]>
     2
     3        <rdar://problem/6341776> Merge m_transitionCount and m_offset in Structure.
     4
     5        Reviewed by Darin Adler.
     6
     7        * runtime/Structure.cpp:
     8        (JSC::Structure::Structure): Remove m_transitionCount
     9        (JSC::Structure::addPropertyTransitionToExistingStructure): No need to wait until after the assignment to offset to assert if it's notFound; move it up.
     10        (JSC::Structure::addPropertyTransition): Use method for transitionCount instead of m_transitionCount. Remove line that maintains the m_transitionCount.
     11        (JSC::Structure::changePrototypeTransition): Remove line that maintains the m_transitionCount.
     12        (JSC::Structure::getterSetterTransition): Remove line that maintains the m_transitionCount.
     13        * runtime/Structure.h:
     14        Changed s_maxTransitionLength and m_offset from size_t to signed char.  m_offset will never become greater than 64
     15        because the structure transitions to a dictionary at that time.
     16        (JSC::Structure::transitionCount): method to replace the data member
     17
    1182009-01-04  Darin Adler  <[email protected]>
    219
  • trunk/JavaScriptCore/runtime/Structure.cpp

    r39505 r39593  
    4848
    4949using namespace std;
    50 using WTF::doubleHash;
     50using namespace WTF;
    5151
    5252namespace JSC {
     
    127127    , m_previous(0)
    128128    , m_nameInPrevious(0)
    129     , m_transitionCount(0)
    130129    , m_propertyTable(0)
    131130    , m_propertyStorageCapacity(JSObject::inlineStorageCapacity)
    132     , m_offset(WTF::notFound)
     131    , m_offset(noOffset)
    133132    , m_isDictionary(false)
    134133    , m_isPinnedPropertyTable(false)
     
    238237static unsigned sizeForKeyCount(size_t keyCount)
    239238{
    240     if (keyCount == WTF::notFound)
     239    if (keyCount == notFound)
    241240        return newTableSize;
    242241
     
    362361        Structure* existingTransition = structure->m_transitions.singleTransition;
    363362        if (existingTransition && existingTransition->m_nameInPrevious.get() == propertyName.ustring().rep() && existingTransition->m_attributesInPrevious == attributes) {
     363            ASSERT(structure->m_transitions.singleTransition->m_offset != noOffset);
    364364            offset = structure->m_transitions.singleTransition->m_offset;
    365             ASSERT(offset != WTF::notFound);
    366365            return existingTransition;
    367366        }
    368367    } else {
    369368        if (Structure* existingTransition = structure->m_transitions.table->get(make_pair(propertyName.ustring().rep(), attributes))) {
     369            ASSERT(existingTransition->m_offset != noOffset);
    370370            offset = existingTransition->m_offset;
    371             ASSERT(offset != WTF::notFound);
    372371            return existingTransition;
    373372        }
     
    383382    ASSERT(!Structure::addPropertyTransitionToExistingStructure(structure, propertyName, attributes, offset));
    384383
    385     if (structure->m_transitionCount > s_maxTransitionLength) {
     384    if (structure->transitionCount() > s_maxTransitionLength) {
    386385        RefPtr<Structure> transition = toDictionaryTransition(structure);
    387386        offset = transition->put(propertyName, attributes);
     
    396395    transition->m_nameInPrevious = propertyName.ustring().rep();
    397396    transition->m_attributesInPrevious = attributes;
    398     transition->m_transitionCount = structure->m_transitionCount + 1;
    399397    transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    400398    transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
     
    451449    RefPtr<Structure> transition = create(prototype, structure->typeInfo());
    452450
    453     transition->m_transitionCount = structure->m_transitionCount + 1;
    454451    transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    455452    transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
     
    467464{
    468465    RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo());
    469     transition->m_transitionCount = structure->m_transitionCount + 1;
    470466    transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    471467    transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties;
     
    615611    materializePropertyMapIfNecessary();
    616612    if (!m_propertyTable)
    617         return WTF::notFound;
     613        return notFound;
    618614
    619615    UString::Rep* rep = propertyName._ustring.rep();
     
    627623    unsigned entryIndex = m_propertyTable->entryIndices[i & m_propertyTable->sizeMask];
    628624    if (entryIndex == emptyEntryIndex)
    629         return WTF::notFound;
     625        return notFound;
    630626
    631627    if (rep == m_propertyTable->entries()[entryIndex - 1].key) {
     
    649645        entryIndex = m_propertyTable->entryIndices[i & m_propertyTable->sizeMask];
    650646        if (entryIndex == emptyEntryIndex)
    651             return WTF::notFound;
     647            return notFound;
    652648
    653649        if (rep == m_propertyTable->entries()[entryIndex - 1].key) {
     
    661657{
    662658    ASSERT(!propertyName.isNull());
    663     ASSERT(get(propertyName) == WTF::notFound);
     659    ASSERT(get(propertyName) == notFound);
    664660
    665661    checkConsistency();
     
    756752
    757753    if (!m_propertyTable)
    758         return WTF::notFound;
     754        return notFound;
    759755
    760756#if DUMP_PROPERTYMAP_STATS
     
    771767        entryIndex = m_propertyTable->entryIndices[i & m_propertyTable->sizeMask];
    772768        if (entryIndex == emptyEntryIndex)
    773             return WTF::notFound;
     769            return notFound;
    774770
    775771        key = m_propertyTable->entries()[entryIndex - 1].key;
  • trunk/JavaScriptCore/runtime/Structure.h

    r39502 r39593  
    107107        void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; }
    108108
    109         bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == WTF::notFound; }
     109        bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; }
    110110
    111111    private:
     
    140140        }
    141141
     142        signed char transitionCount() const
     143        {
     144            // Since the number of transitions is always the same as m_offset, we keep the size of Structure down by not storing both.
     145            return m_offset == noOffset ? 0 : m_offset + 1;
     146        }
     147
    142148        static const unsigned emptyEntryIndex = 0;
    143149   
    144         static const size_t s_maxTransitionLength = 64;
     150        static const signed char s_maxTransitionLength = 64;
     151
     152        static const signed char noOffset = -1;
    145153
    146154        TypeInfo m_typeInfo;
     
    152160        RefPtr<UString::Rep> m_nameInPrevious;
    153161
    154         size_t m_transitionCount;
    155162        union {
    156163            Structure* singleTransition;
     
    163170
    164171        size_t m_propertyStorageCapacity;
    165         size_t m_offset;
     172        signed char m_offset;
    166173
    167174        bool m_isDictionary : 1;
Note: See TracChangeset for help on using the changeset viewer.