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/PropertyMap.h

    r36263 r36285  
    2424#include "PropertySlot.h"
    2525#include "identifier.h"
     26#include <wtf/OwnArrayPtr.h>
    2627#include <wtf/NotFound.h>
    2728
     
    3132    class JSValue;
    3233    class PropertyNameArray;
    33     struct PropertyMapEntry;
    34     struct PropertyMapHashTable;
     34
     35    typedef OwnArrayPtr<JSValue*> PropertyStorage;
    3536
    3637    struct PropertyMapEntry {
    3738        UString::Rep* key;
    38         JSValue* value;
    3939        unsigned attributes;
    4040        unsigned index;
    4141
    42         PropertyMapEntry(UString::Rep* k, JSValue* v, int a)
     42        PropertyMapEntry(UString::Rep* k, int a)
    4343            : key(k)
    44             , value(v)
    4544            , attributes(a)
    4645            , index(0)
     
    8180    };
    8281
    83     class PropertyMap : Noncopyable {
     82    class PropertyMap {
    8483        friend class CTI;
    85 
    8684    public:
    8785        PropertyMap();
    8886        ~PropertyMap();
    8987
    90         bool isEmpty() { return !m_usingTable & !m_singleEntryKey; }
     88        PropertyMap& operator=(const PropertyMap&);
    9189
    92         void put(const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&);
    93         void remove(const Identifier& propertyName);
    94         JSValue* get(const Identifier& propertyName) const;
    95         JSValue* get(const Identifier& propertyName, unsigned& attributes) const;
    96         JSValue** getLocation(const Identifier& propertyName);
    97         JSValue** getLocation(const Identifier& propertyName, bool& isWriteable);
    98        
    99         JSValue* getOffset(size_t offset)
    100         {
    101             ASSERT(m_usingTable);
    102             return reinterpret_cast<JSValue**>(m_u.table->entryIndices)[offset];
    103         }
    104         void putOffset(size_t offset, JSValue* v)
    105         {
    106             ASSERT(m_usingTable);
    107             reinterpret_cast<JSValue**>(m_u.table->entryIndices)[offset] = v;
    108         }
     90        bool isEmpty() { return !m_table; }
    10991
    110         size_t offsetForLocation(JSValue** location) { return m_usingTable ? offsetForTableLocation(location) : WTF::notFound; }
     92        void put(const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&, PropertyStorage&);
     93        void remove(const Identifier& propertyName, PropertyStorage&);
     94        JSValue* get(const Identifier& propertyName, const PropertyStorage&) const;
     95        JSValue* get(const Identifier& propertyName, unsigned& attributes, const PropertyStorage&) const;
     96        JSValue** getLocation(const Identifier& propertyName, const PropertyStorage&);
     97        JSValue** getLocation(const Identifier& propertyName, bool& isWriteable, const PropertyStorage&);
    11198
    112         void mark() const;
     99        size_t getOffset(const Identifier& propertyName);
     100        size_t getOffset(const Identifier& propertyName, bool& isWriteable);
     101
    113102        void getEnumerablePropertyNames(PropertyNameArray&) const;
    114103
    115104        bool hasGetterSetterProperties() const { return m_getterSetterFlag; }
    116105        void setHasGetterSetterProperties(bool f) { m_getterSetterFlag = f; }
     106
     107        unsigned size() const { return m_table ? m_table->size : 0; }
     108        unsigned makingCount() const { return m_table ? m_table->keyCount + m_table->deletedSentinelCount : 0; }
     109
     110        void resizePropertyStorage(PropertyStorage&, unsigned oldSize);
    117111
    118112    private:
     
    121115
    122116        static bool keysMatch(const UString::Rep*, const UString::Rep*);
    123         void expand();
    124         void rehash();
    125         void rehash(unsigned newTableSize);
    126         void createTable();
    127        
    128         void insert(const Entry&);
    129        
    130         size_t offsetForTableLocation(JSValue** location)
    131         {
    132             ASSERT(m_usingTable);
    133             return location - reinterpret_cast<JSValue**>(m_u.table->entryIndices);
    134         }
     117        void expand(PropertyStorage&);
     118        void rehash(PropertyStorage&);
     119        void rehash(unsigned newTableSize, PropertyStorage&);
     120        void createTable(PropertyStorage&);
    135121
    136         void checkConsistency();
    137        
    138         UString::Rep* m_singleEntryKey;
    139         union {
    140             JSValue* singleEntryValue;
    141             Table* table;
    142         } m_u;
     122        void insert(const Entry&, JSValue*, PropertyStorage&);
    143123
    144         short m_singleEntryAttributes;
     124        void checkConsistency(PropertyStorage&);
     125
     126        Table* m_table;
    145127        bool m_getterSetterFlag : 1;
    146         bool m_usingTable : 1;
    147128    };
    148129
    149130    inline PropertyMap::PropertyMap()
    150         : m_singleEntryKey(0)
     131        : m_table(0)
    151132        , m_getterSetterFlag(false)
    152         , m_usingTable(false)
    153 
    154133    {
    155134    }
Note: See TracChangeset for help on using the changeset viewer.