Changeset 144074 in webkit


Ignore:
Timestamp:
Feb 26, 2013 10:43:24 AM (11 years ago)
Author:
akling@apple.com
Message:

Unused Structure property tables waste 14MB on Membuster.
<http://webkit.org/b/110854>
<rdar://problem/13292104>

Reviewed by Filip Pizlo.

Turn PropertyTable into a GC object and have Structure drop unpinned tables when marking.
14 MB progression on Membuster3.

Added PropertyTable.cpp.

  • runtime/PropertyTable.cpp: Added.

(JSC::PropertyTable::create):
(JSC::PropertyTable::clone):
(JSC::PropertyTable::PropertyTable):
(JSC::PropertyTable::destroy):
(JSC::PropertyTable::~PropertyTable):
(JSC::PropertyTable::visitChildren):

Moved marking of property table values here from Structure::visitChildren().

  • runtime/StructureInlines.h:

(JSC::Structure::putWillGrowOutOfLineStorage):
(JSC::Structure::checkOffsetConsistency):

Moved these to StructureInlines.h to break header dependency cycle between Structure/PropertyTable.

  • runtime/Structure.cpp:

(JSC::Structure::visitChildren):

Null out m_propertyTable if the table is unpinned. This'll cause the table to get GC'd.

(JSC::Structure::materializePropertyMap):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::changePrototypeTransition):
(JSC::Structure::despecifyFunctionTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::toDictionaryTransition):
(JSC::Structure::preventExtensionsTransition):
(JSC::Structure::nonPropertyTransition):
(JSC::Structure::copyPropertyTable):
(JSC::Structure::copyPropertyTableForPinning):
(JSC::Structure::putSpecificValue):
(JSC::Structure::createPropertyMap):

  • runtime/Structure.h:

(Structure):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:

(JSGlobalData):

  • runtime/PropertyMapHashTable.h:

(PropertyTable):
(JSC::PropertyTable::createStructure):
(JSC::PropertyTable::copy):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r144056 r144074  
    281281    runtime/PropertyNameArray.cpp
    282282    runtime/PropertySlot.cpp
     283    runtime/PropertyTable.cpp
    283284    runtime/PrototypeMap.cpp
    284285    runtime/RegExp.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r144056 r144074  
     12013-02-26  Andreas Kling  <akling@apple.com>
     2
     3        Unused Structure property tables waste 14MB on Membuster.
     4        <http://webkit.org/b/110854>
     5        <rdar://problem/13292104>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        Turn PropertyTable into a GC object and have Structure drop unpinned tables when marking.
     10        14 MB progression on Membuster3.
     11
     12        * CMakeLists.txt:
     13        * GNUmakefile.list.am:
     14        * JavaScriptCore.gypi:
     15        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     16        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * Target.pri:
     19
     20            Added PropertyTable.cpp.
     21
     22        * runtime/PropertyTable.cpp: Added.
     23        (JSC::PropertyTable::create):
     24        (JSC::PropertyTable::clone):
     25        (JSC::PropertyTable::PropertyTable):
     26        (JSC::PropertyTable::destroy):
     27        (JSC::PropertyTable::~PropertyTable):
     28        (JSC::PropertyTable::visitChildren):
     29
     30            Moved marking of property table values here from Structure::visitChildren().
     31
     32        * runtime/StructureInlines.h:
     33        (JSC::Structure::putWillGrowOutOfLineStorage):
     34        (JSC::Structure::checkOffsetConsistency):
     35
     36            Moved these to StructureInlines.h to break header dependency cycle between Structure/PropertyTable.
     37
     38        * runtime/Structure.cpp:
     39        (JSC::Structure::visitChildren):
     40
     41            Null out m_propertyTable if the table is unpinned. This'll cause the table to get GC'd.
     42
     43        (JSC::Structure::materializePropertyMap):
     44        (JSC::Structure::addPropertyTransition):
     45        (JSC::Structure::changePrototypeTransition):
     46        (JSC::Structure::despecifyFunctionTransition):
     47        (JSC::Structure::attributeChangeTransition):
     48        (JSC::Structure::toDictionaryTransition):
     49        (JSC::Structure::preventExtensionsTransition):
     50        (JSC::Structure::nonPropertyTransition):
     51        (JSC::Structure::copyPropertyTable):
     52        (JSC::Structure::copyPropertyTableForPinning):
     53        (JSC::Structure::putSpecificValue):
     54        (JSC::Structure::createPropertyMap):
     55        * runtime/Structure.h:
     56        (Structure):
     57        * runtime/JSGlobalData.cpp:
     58        (JSC::JSGlobalData::JSGlobalData):
     59        * runtime/JSGlobalData.h:
     60        (JSGlobalData):
     61        * runtime/PropertyMapHashTable.h:
     62        (PropertyTable):
     63        (JSC::PropertyTable::createStructure):
     64        (JSC::PropertyTable::copy):
     65
    1662013-02-26  Andreas Kling  <akling@apple.com>
    267
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r144056 r144074  
    723723        Source/JavaScriptCore/runtime/PropertySlot.cpp \
    724724        Source/JavaScriptCore/runtime/PropertySlot.h \
     725        Source/JavaScriptCore/runtime/PropertyTable.cpp \
    725726        Source/JavaScriptCore/runtime/PrototypeMap.cpp \
    726727        Source/JavaScriptCore/runtime/PrototypeMap.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.gypi

    r144056 r144074  
    760760            'runtime/PropertySlot.cpp',
    761761            'runtime/PropertySlot.h',
     762            'runtime/PropertyTable.cpp',
    762763            'runtime/PropertyStorage.h',
    763764            'runtime/Protect.h',
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r144056 r144074  
    11751175                        </File>
    11761176                        <File
     1177                                RelativePath="..\..\runtime\PropertyTable.cpp"
     1178                                >
     1179                        </File>
     1180                        <File
    11771181                                RelativePath="..\..\runtime\PrototypeMap.cpp"
    11781182                                >
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r144056 r144074  
    306306    <ClCompile Include="..\runtime\PropertyNameArray.cpp" />
    307307    <ClCompile Include="..\runtime\PropertySlot.cpp" />
     308    <ClCompile Include="..\runtime\PropertyTable.cpp" />
    308309    <ClCompile Include="..\runtime\PrototypeMap.cpp" />
    309310    <ClCompile Include="..\runtime\RegExp.cpp" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r144056 r144074  
    706706                A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
    707707                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
     708                ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
    708709                BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
    709710                BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    16231624                A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
    16241625                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
     1626                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
    16251627                BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ToolExecutable.xcconfig; sourceTree = "<group>"; };
    16261628                BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorConstructor.cpp; sourceTree = "<group>"; };
     
    25132515                                65621E6C089E859700760F35 /* PropertySlot.h */,
    25142516                                0FB7F39015ED8E3800F167B2 /* PropertyStorage.h */,
     2517                                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */,
    25152518                                65C02FBB0637462A003E7EE6 /* Protect.h */,
    25162519                                14D844A216AA2C7000A65AF0 /* PrototypeMap.cpp */,
     
    40324035                                0FBE0F7616C1DB0F0082C5E8 /* DFGUnificationPhase.cpp in Sources */,
    40334036                                0F493AFA16D0CAD30084508B /* SourceProvider.cpp in Sources */,
     4037                                ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */,
    40344038                        );
    40354039                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/Target.pri

    r144056 r144074  
    299299    runtime/PropertyNameArray.cpp \
    300300    runtime/PropertySlot.cpp \
     301    runtime/PropertyTable.cpp \
    301302    runtime/PrototypeMap.cpp \
    302303    runtime/RegExpConstructor.cpp \
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r144056 r144074  
    233233    unlinkedEvalCodeBlockStructure.set(*this, UnlinkedEvalCodeBlock::createStructure(*this, 0, jsNull()));
    234234    unlinkedFunctionCodeBlockStructure.set(*this, UnlinkedFunctionCodeBlock::createStructure(*this, 0, jsNull()));
     235    propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull()));
    235236    smallStrings.initializeCommonStrings(*this);
    236237
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r144056 r144074  
    257257        Strong<Structure> unlinkedEvalCodeBlockStructure;
    258258        Strong<Structure> unlinkedFunctionCodeBlockStructure;
     259        Strong<Structure> propertyTableStructure;
    259260
    260261        IdentifierTable* identifierTable;
  • trunk/Source/JavaScriptCore/runtime/PropertyMapHashTable.h

    r144056 r144074  
    2323
    2424#include "PropertyOffset.h"
     25#include "Structure.h"
    2526#include "WriteBarrier.h"
    2627#include <wtf/HashTable.h>
     
    8687};
    8788
    88 class PropertyTable {
    89     WTF_MAKE_FAST_ALLOCATED;
     89class PropertyTable : public JSCell {
    9090
    9191    // This is the implementation for 'iterator' and 'const_iterator',
     
    130130
    131131public:
     132    static const bool needsDestruction = true;
     133    static const bool hasImmortalStructure = true;
     134    static void destroy(JSCell*);
     135
     136    static JS_EXPORTDATA const ClassInfo s_info;
     137
     138    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
     139    {
     140        return Structure::create(globalData, globalObject, prototype, TypeInfo(CompoundType, OverridesVisitChildren), &s_info);
     141    }
     142
     143    static void visitChildren(JSCell*, SlotVisitor&);
     144
    132145    typedef StringImpl* KeyType;
    133146    typedef PropertyMapEntry ValueType;
     
    143156
    144157    // Constructor is passed an initial capacity, a PropertyTable to copy, or both.
    145     explicit PropertyTable(unsigned initialCapacity);
    146     PropertyTable(JSGlobalData&, JSCell*, const PropertyTable&);
    147     PropertyTable(JSGlobalData&, JSCell*, unsigned initialCapacity, const PropertyTable&);
     158    static PropertyTable* create(JSGlobalData&, unsigned initialCapacity);
     159    static PropertyTable* clone(JSGlobalData&, JSCell* owner, const PropertyTable&);
     160    static PropertyTable* clone(JSGlobalData&, JSCell* owner, unsigned initialCapacity, const PropertyTable&);
    148161    ~PropertyTable();
    149162
     
    182195
    183196    // Copy this PropertyTable, ensuring the copy has at least the capacity provided.
    184     PassOwnPtr<PropertyTable> copy(JSGlobalData&, JSCell* owner, unsigned newCapacity);
     197    PropertyTable* copy(JSGlobalData&, JSCell* owner, unsigned newCapacity);
    185198
    186199#ifndef NDEBUG
     
    190203
    191204private:
     205    PropertyTable(JSGlobalData&, unsigned initialCapacity);
     206    PropertyTable(JSGlobalData&, JSCell*, const PropertyTable&);
     207    PropertyTable(JSGlobalData&, JSCell*, unsigned initialCapacity, const PropertyTable&);
     208
    192209    PropertyTable(const PropertyTable&);
    193210    // Used to insert a value known not to be in the table, and where we know capacity to be available.
     
    240257};
    241258
    242 inline PropertyTable::PropertyTable(unsigned initialCapacity)
    243     : m_indexSize(sizeForCapacity(initialCapacity))
    244     , m_indexMask(m_indexSize - 1)
    245     , m_index(static_cast<unsigned*>(fastZeroedMalloc(dataSize())))
    246     , m_keyCount(0)
    247     , m_deletedCount(0)
    248 {
    249     ASSERT(isPowerOf2(m_indexSize));
    250 }
    251 
    252 inline PropertyTable::PropertyTable(JSGlobalData&, JSCell* owner, const PropertyTable& other)
    253     : m_indexSize(other.m_indexSize)
    254     , m_indexMask(other.m_indexMask)
    255     , m_index(static_cast<unsigned*>(fastMalloc(dataSize())))
    256     , m_keyCount(other.m_keyCount)
    257     , m_deletedCount(other.m_deletedCount)
    258 {
    259     ASSERT(isPowerOf2(m_indexSize));
    260 
    261     memcpy(m_index, other.m_index, dataSize());
    262 
    263     iterator end = this->end();
    264     for (iterator iter = begin(); iter != end; ++iter) {
    265         iter->key->ref();
    266         Heap::writeBarrier(owner, iter->specificValue.get());
    267     }
    268 
    269     // Copy the m_deletedOffsets vector.
    270     Vector<PropertyOffset>* otherDeletedOffsets = other.m_deletedOffsets.get();
    271     if (otherDeletedOffsets)
    272         m_deletedOffsets = adoptPtr(new Vector<PropertyOffset>(*otherDeletedOffsets));
    273 }
    274 
    275 inline PropertyTable::PropertyTable(JSGlobalData&, JSCell* owner, unsigned initialCapacity, const PropertyTable& other)
    276     : m_indexSize(sizeForCapacity(initialCapacity))
    277     , m_indexMask(m_indexSize - 1)
    278     , m_index(static_cast<unsigned*>(fastZeroedMalloc(dataSize())))
    279     , m_keyCount(0)
    280     , m_deletedCount(0)
    281 {
    282     ASSERT(isPowerOf2(m_indexSize));
    283     ASSERT(initialCapacity >= other.m_keyCount);
    284 
    285     const_iterator end = other.end();
    286     for (const_iterator iter = other.begin(); iter != end; ++iter) {
    287         ASSERT(canInsert());
    288         reinsert(*iter);
    289         iter->key->ref();
    290         Heap::writeBarrier(owner, iter->specificValue.get());
    291     }
    292 
    293     // Copy the m_deletedOffsets vector.
    294     Vector<PropertyOffset>* otherDeletedOffsets = other.m_deletedOffsets.get();
    295     if (otherDeletedOffsets)
    296         m_deletedOffsets = adoptPtr(new Vector<PropertyOffset>(*otherDeletedOffsets));
    297 }
    298 
    299 inline PropertyTable::~PropertyTable()
    300 {
    301     iterator end = this->end();
    302     for (iterator iter = begin(); iter != end; ++iter)
    303         iter->key->deref();
    304 
    305     fastFree(m_index);
    306 }
    307 
    308259inline PropertyTable::iterator PropertyTable::begin()
    309260{
     
    503454}
    504455
    505 inline PassOwnPtr<PropertyTable> PropertyTable::copy(JSGlobalData& globalData, JSCell* owner, unsigned newCapacity)
     456inline PropertyTable* PropertyTable::copy(JSGlobalData& globalData, JSCell* owner, unsigned newCapacity)
    506457{
    507458    ASSERT(newCapacity >= m_keyCount);
     
    510461    // save rehashing all keys.
    511462    if (sizeForCapacity(newCapacity) == m_indexSize)
    512         return adoptPtr(new PropertyTable(globalData, owner, *this));
    513     return adoptPtr(new PropertyTable(globalData, owner, newCapacity, *this));
     463        return PropertyTable::clone(globalData, owner, *this);
     464    return PropertyTable::clone(globalData, owner, newCapacity, *this);
    514465}
    515466
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r144056 r144074  
    248248            ASSERT(!structure->previousID());
    249249
    250             m_propertyTable = structure->m_propertyTable->copy(globalData, 0, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
     250            m_propertyTable.set(globalData, this, structure->m_propertyTable->copy(globalData, 0, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity)));
    251251            break;
    252252        }
     
    256256
    257257    if (!m_propertyTable)
    258         createPropertyMap(numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
     258        createPropertyMap(globalData, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
    259259
    260260    for (ptrdiff_t i = structures.size() - 1; i >= 0; --i) {
     
    377377        structure->checkOffsetConsistency();
    378378        if (structure->m_isPinnedPropertyTable)
    379             transition->m_propertyTable = structure->m_propertyTable->copy(globalData, transition, structure->m_propertyTable->size() + 1);
    380         else
    381             transition->m_propertyTable = structure->m_propertyTable.release();
     379            transition->m_propertyTable.set(globalData, transition, structure->m_propertyTable->copy(globalData, transition, structure->m_propertyTable->size() + 1));
     380        else {
     381            transition->m_propertyTable.set(globalData, transition, structure->m_propertyTable.get());
     382            structure->m_propertyTable.clear();
     383        }
    382384    } else {
    383385        if (structure->previousID())
    384386            transition->materializePropertyMap(globalData);
    385387        else
    386             transition->createPropertyMap();
     388            transition->createPropertyMap(globalData);
    387389    }
    388390    transition->m_offset = structure->m_offset;
     
    416418
    417419    structure->materializePropertyMapIfNecessary(globalData);
    418     transition->m_propertyTable = structure->copyPropertyTableForPinning(globalData, transition);
     420    transition->m_propertyTable.set(globalData, transition, structure->copyPropertyTableForPinning(globalData, transition));
    419421    transition->m_offset = structure->m_offset;
    420422    transition->pin();
     
    432434
    433435    structure->materializePropertyMapIfNecessary(globalData);
    434     transition->m_propertyTable = structure->copyPropertyTableForPinning(globalData, transition);
     436    transition->m_propertyTable.set(globalData, transition, structure->copyPropertyTableForPinning(globalData, transition));
    435437    transition->m_offset = structure->m_offset;
    436438    transition->pin();
     
    453455
    454456        structure->materializePropertyMapIfNecessary(globalData);
    455         transition->m_propertyTable = structure->copyPropertyTableForPinning(globalData, transition);
     457        transition->m_propertyTable.set(globalData, transition, structure->copyPropertyTableForPinning(globalData, transition));
    456458        transition->m_offset = structure->m_offset;
    457459        transition->pin();
     
    476478
    477479    structure->materializePropertyMapIfNecessary(globalData);
    478     transition->m_propertyTable = structure->copyPropertyTableForPinning(globalData, transition);
     480    transition->m_propertyTable.set(globalData, transition, structure->copyPropertyTableForPinning(globalData, transition));
    479481    transition->m_offset = structure->m_offset;
    480482    transition->m_dictionaryKind = kind;
     
    536538
    537539    structure->materializePropertyMapIfNecessary(globalData);
    538     transition->m_propertyTable = structure->copyPropertyTableForPinning(globalData, transition);
     540    transition->m_propertyTable.set(globalData, transition, structure->copyPropertyTableForPinning(globalData, transition));
    539541    transition->m_offset = structure->m_offset;
    540542    transition->m_preventExtensions = true;
     
    576578        structure->checkOffsetConsistency();
    577579        if (structure->m_isPinnedPropertyTable)
    578             transition->m_propertyTable = structure->m_propertyTable->copy(globalData, transition, structure->m_propertyTable->size() + 1);
    579         else
    580             transition->m_propertyTable = structure->m_propertyTable.release();
     580            transition->m_propertyTable.set(globalData, transition, structure->m_propertyTable->copy(globalData, transition, structure->m_propertyTable->size() + 1));
     581        else {
     582            transition->m_propertyTable.set(globalData, transition, structure->m_propertyTable.get());
     583            structure->m_propertyTable.clear();
     584        }
    581585    } else {
    582586        if (structure->previousID())
    583587            transition->materializePropertyMap(globalData);
    584588        else
    585             transition->createPropertyMap();
     589            transition->createPropertyMap(globalData);
    586590    }
    587591   
     
    738742#endif
    739743
    740 PassOwnPtr<PropertyTable> Structure::copyPropertyTable(JSGlobalData& globalData, Structure* owner)
    741 {
    742     return adoptPtr(m_propertyTable ? new PropertyTable(globalData, owner, *m_propertyTable) : 0);
    743 }
    744 
    745 PassOwnPtr<PropertyTable> Structure::copyPropertyTableForPinning(JSGlobalData& globalData, Structure* owner)
    746 {
    747     return adoptPtr(m_propertyTable ? new PropertyTable(globalData, owner, *m_propertyTable) : new PropertyTable(numberOfSlotsForLastOffset(m_offset, m_inlineCapacity)));
     744PropertyTable* Structure::copyPropertyTable(JSGlobalData& globalData, Structure* owner)
     745{
     746    if (!m_propertyTable)
     747        return 0;
     748    return PropertyTable::clone(globalData, owner, *m_propertyTable.get());
     749}
     750
     751PropertyTable* Structure::copyPropertyTableForPinning(JSGlobalData& globalData, Structure* owner)
     752{
     753    if (m_propertyTable)
     754        return PropertyTable::clone(globalData, owner, *m_propertyTable.get());
     755    return PropertyTable::create(globalData, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
    748756}
    749757
     
    802810
    803811    if (!m_propertyTable)
    804         createPropertyMap();
     812        createPropertyMap(globalData);
    805813
    806814    PropertyOffset newOffset = m_propertyTable->nextOffset(m_inlineCapacity);
     
    834842}
    835843
    836 void Structure::createPropertyMap(unsigned capacity)
     844void Structure::createPropertyMap(JSGlobalData& globalData, unsigned capacity)
    837845{
    838846    ASSERT(!m_propertyTable);
    839847
    840848    checkConsistency();
    841     m_propertyTable = adoptPtr(new PropertyTable(capacity));
     849    m_propertyTable.set(globalData, this, PropertyTable::create(globalData, capacity));
    842850}
    843851
     
    883891    visitor.append(&thisObject->m_previousOrRareData);
    884892    visitor.append(&thisObject->m_specificValueInPrevious);
    885     if (thisObject->m_propertyTable) {
    886         PropertyTable::iterator end = thisObject->m_propertyTable->end();
    887         for (PropertyTable::iterator ptr = thisObject->m_propertyTable->begin(); ptr != end; ++ptr)
    888             visitor.append(&ptr->specificValue);
    889     }
     893
     894    if (thisObject->m_isPinnedPropertyTable) {
     895        ASSERT(thisObject->m_propertyTable);
     896        visitor.append(&thisObject->m_propertyTable);
     897    } else if (thisObject->m_propertyTable)
     898        thisObject->m_propertyTable.clear();
    890899}
    891900
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r144056 r144074  
    3232#include "JSCell.h"
    3333#include "JSType.h"
    34 #include "PropertyMapHashTable.h"
    3534#include "PropertyName.h"
    3635#include "PropertyNameArray.h"
     36#include "PropertyOffset.h"
    3737#include "Protect.h"
    3838#include "StructureRareData.h"
     
    4141#include "Watchpoint.h"
    4242#include "Weak.h"
    43 #include <wtf/PassOwnPtr.h>
    4443#include <wtf/PassRefPtr.h>
    4544#include <wtf/RefCounted.h>
     
    5251class PropertyNameArray;
    5352class PropertyNameArrayData;
     53class PropertyTable;
    5454class StructureChain;
    5555class SlotVisitor;
     
    109109    bool isExtensible() const { return !m_preventExtensions; }
    110110    bool didTransition() const { return m_didTransition; }
    111     bool putWillGrowOutOfLineStorage()
    112     {
    113         checkOffsetConsistency();
    114            
    115         ASSERT(outOfLineCapacity() >= outOfLineSize());
    116            
    117         if (!m_propertyTable) {
    118             unsigned currentSize = numberOfOutOfLineSlotsForLastOffset(m_offset);
    119             ASSERT(outOfLineCapacity() >= currentSize);
    120             return currentSize == outOfLineCapacity();
    121         }
    122            
    123         ASSERT(totalStorageCapacity() >= m_propertyTable->propertyStorageSize());
    124         if (m_propertyTable->hasDeletedOffset())
    125             return false;
    126            
    127         ASSERT(totalStorageCapacity() >= m_propertyTable->size());
    128         return m_propertyTable->size() == totalStorageCapacity();
    129     }
     111    bool putWillGrowOutOfLineStorage();
    130112    JS_EXPORT_PRIVATE size_t suggestedNewOutOfLineStorageCapacity();
    131113
     
    383365    PropertyOffset remove(PropertyName);
    384366
    385     void createPropertyMap(unsigned keyCount = 0);
     367    void createPropertyMap(JSGlobalData&, unsigned keyCount = 0);
    386368    void checkConsistency();
    387369
     
    389371    void despecifyAllFunctions(JSGlobalData&);
    390372
    391     PassOwnPtr<PropertyTable> copyPropertyTable(JSGlobalData&, Structure* owner);
    392     PassOwnPtr<PropertyTable> copyPropertyTableForPinning(JSGlobalData&, Structure* owner);
     373    PropertyTable* copyPropertyTable(JSGlobalData&, Structure* owner);
     374    PropertyTable* copyPropertyTableForPinning(JSGlobalData&, Structure* owner);
    393375    JS_EXPORT_PRIVATE void materializePropertyMap(JSGlobalData&);
    394376    void materializePropertyMapIfNecessary(JSGlobalData& globalData)
     
    446428    }
    447429       
    448     ALWAYS_INLINE bool checkOffsetConsistency() const
    449     {
    450         if (!m_propertyTable) {
    451             ASSERT(!m_isPinnedPropertyTable);
    452             return true;
    453         }
    454            
    455         RELEASE_ASSERT(numberOfSlotsForLastOffset(m_offset, m_inlineCapacity) == m_propertyTable->propertyStorageSize());
    456         unsigned totalSize = m_propertyTable->propertyStorageSize();
    457         RELEASE_ASSERT((totalSize < inlineCapacity() ? 0 : totalSize - inlineCapacity()) == numberOfOutOfLineSlotsForLastOffset(m_offset));
    458            
    459         return true;
    460     }
     430    bool checkOffsetConsistency() const;
    461431
    462432    void allocateRareData(JSGlobalData&);
     
    483453    StructureTransitionTable m_transitionTable;
    484454
    485     OwnPtr<PropertyTable> m_propertyTable;
     455    WriteBarrier<PropertyTable> m_propertyTable;
    486456
    487457    mutable InlineWatchpointSet m_transitionWatchpointSet;
  • trunk/Source/JavaScriptCore/runtime/StructureInlines.h

    r144056 r144074  
    2727#define StructureInlines_h
    2828
     29#include "PropertyMapHashTable.h"
    2930#include "Structure.h"
    3031
     
    180181}
    181182
     183inline bool Structure::putWillGrowOutOfLineStorage()
     184{
     185    checkOffsetConsistency();
     186
     187    ASSERT(outOfLineCapacity() >= outOfLineSize());
     188
     189    if (!m_propertyTable) {
     190        unsigned currentSize = numberOfOutOfLineSlotsForLastOffset(m_offset);
     191        ASSERT(outOfLineCapacity() >= currentSize);
     192        return currentSize == outOfLineCapacity();
     193    }
     194
     195    ASSERT(totalStorageCapacity() >= m_propertyTable->propertyStorageSize());
     196    if (m_propertyTable->hasDeletedOffset())
     197        return false;
     198
     199    ASSERT(totalStorageCapacity() >= m_propertyTable->size());
     200    return m_propertyTable->size() == totalStorageCapacity();
     201}
     202
     203ALWAYS_INLINE bool Structure::checkOffsetConsistency() const
     204{
     205    if (!m_propertyTable) {
     206        ASSERT(!m_isPinnedPropertyTable);
     207        return true;
     208    }
     209
     210    RELEASE_ASSERT(numberOfSlotsForLastOffset(m_offset, m_inlineCapacity) == m_propertyTable->propertyStorageSize());
     211    unsigned totalSize = m_propertyTable->propertyStorageSize();
     212    RELEASE_ASSERT((totalSize < inlineCapacity() ? 0 : totalSize - inlineCapacity()) == numberOfOutOfLineSlotsForLastOffset(m_offset));
     213
     214    return true;
     215}
     216
    182217} // namespace JSC
    183218
Note: See TracChangeset for help on using the changeset viewer.