Changeset 36285 in webkit for trunk/JavaScriptCore/kjs/PropertyMap.h
- Timestamp:
- Sep 8, 2008, 11:55:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/PropertyMap.h
r36263 r36285 24 24 #include "PropertySlot.h" 25 25 #include "identifier.h" 26 #include <wtf/OwnArrayPtr.h> 26 27 #include <wtf/NotFound.h> 27 28 … … 31 32 class JSValue; 32 33 class PropertyNameArray; 33 struct PropertyMapEntry; 34 struct PropertyMapHashTable;34 35 typedef OwnArrayPtr<JSValue*> PropertyStorage; 35 36 36 37 struct PropertyMapEntry { 37 38 UString::Rep* key; 38 JSValue* value;39 39 unsigned attributes; 40 40 unsigned index; 41 41 42 PropertyMapEntry(UString::Rep* k, JSValue* v,int a)42 PropertyMapEntry(UString::Rep* k, int a) 43 43 : key(k) 44 , value(v)45 44 , attributes(a) 46 45 , index(0) … … 81 80 }; 82 81 83 class PropertyMap : Noncopyable{82 class PropertyMap { 84 83 friend class CTI; 85 86 84 public: 87 85 PropertyMap(); 88 86 ~PropertyMap(); 89 87 90 bool isEmpty() { return !m_usingTable & !m_singleEntryKey; }88 PropertyMap& operator=(const PropertyMap&); 91 89 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; } 109 91 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&); 111 98 112 void mark() const; 99 size_t getOffset(const Identifier& propertyName); 100 size_t getOffset(const Identifier& propertyName, bool& isWriteable); 101 113 102 void getEnumerablePropertyNames(PropertyNameArray&) const; 114 103 115 104 bool hasGetterSetterProperties() const { return m_getterSetterFlag; } 116 105 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); 117 111 118 112 private: … … 121 115 122 116 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&); 135 121 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&); 143 123 144 short m_singleEntryAttributes; 124 void checkConsistency(PropertyStorage&); 125 126 Table* m_table; 145 127 bool m_getterSetterFlag : 1; 146 bool m_usingTable : 1;147 128 }; 148 129 149 130 inline PropertyMap::PropertyMap() 150 : m_ singleEntryKey(0)131 : m_table(0) 151 132 , m_getterSetterFlag(false) 152 , m_usingTable(false)153 154 133 { 155 134 }
Note:
See TracChangeset
for help on using the changeset viewer.