Changeset 38440 in webkit for trunk/JavaScriptCore/runtime/JSObject.h
- Timestamp:
- Nov 15, 2008, 8:40:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSObject.h
r38407 r38440 32 32 #include "PutPropertySlot.h" 33 33 #include "ScopeChain.h" 34 #include "Structure ID.h"34 #include "Structure.h" 35 35 36 36 namespace JSC { … … 38 38 class InternalFunction; 39 39 class PropertyNameArray; 40 class Structure ID;40 class Structure; 41 41 struct HashEntry; 42 42 struct HashTable; … … 60 60 61 61 public: 62 explicit JSObject(PassRefPtr<Structure ID>);62 explicit JSObject(PassRefPtr<Structure>); 63 63 64 64 virtual void mark(); … … 73 73 void setPrototype(JSValue* prototype); 74 74 75 void setStructure ID(PassRefPtr<StructureID>);76 Structure ID* inheritorID();75 void setStructure(PassRefPtr<Structure>); 76 Structure* inheritorID(); 77 77 78 78 PropertyStorage& propertyStorage() { return m_propertyStorage; } … … 125 125 JSValue* getDirect(const Identifier& propertyName) const 126 126 { 127 size_t offset = m_structure ID->get(propertyName);127 size_t offset = m_structure->get(propertyName); 128 128 return offset != WTF::notFound ? m_propertyStorage[offset] : noValue(); 129 129 } … … 131 131 JSValue** getDirectLocation(const Identifier& propertyName) 132 132 { 133 size_t offset = m_structure ID->get(propertyName);133 size_t offset = m_structure->get(propertyName); 134 134 return offset != WTF::notFound ? locationForOffset(offset) : 0; 135 135 } … … 137 137 JSValue** getDirectLocation(const Identifier& propertyName, unsigned& attributes) 138 138 { 139 size_t offset = m_structure ID->get(propertyName, attributes);139 size_t offset = m_structure->get(propertyName, attributes); 140 140 return offset != WTF::notFound ? locationForOffset(offset) : 0; 141 141 } … … 151 151 } 152 152 153 void transitionTo(Structure ID*);153 void transitionTo(Structure*); 154 154 155 155 void removeDirect(const Identifier& propertyName); 156 bool hasCustomProperties() { return !m_structure ID->isEmpty(); }157 bool hasGetterSetterProperties() { return m_structure ID->hasGetterSetterProperties(); }156 bool hasCustomProperties() { return !m_structure->isEmpty(); } 157 bool hasGetterSetterProperties() { return m_structure->hasGetterSetterProperties(); } 158 158 159 159 void putDirect(const Identifier& propertyName, JSValue* value, unsigned attr = 0); … … 186 186 static const size_t nonInlineBaseStorageCapacity = 16; 187 187 188 static PassRefPtr<Structure ID> createStructureID(JSValue* prototype)188 static PassRefPtr<Structure> createStructure(JSValue* prototype) 189 189 { 190 return Structure ID::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));190 return Structure::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot)); 191 191 } 192 192 … … 198 198 199 199 const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const; 200 Structure ID* createInheritorID();201 202 RefPtr<Structure ID> m_inheritorID;200 Structure* createInheritorID(); 201 202 RefPtr<Structure> m_inheritorID; 203 203 204 204 PropertyStorage m_propertyStorage; … … 216 216 } 217 217 218 inline JSObject::JSObject(PassRefPtr<Structure ID> structureID)219 : JSCell(structure ID.releaseRef()) // ~JSObject balances this ref()218 inline JSObject::JSObject(PassRefPtr<Structure> structure) 219 : JSCell(structure.releaseRef()) // ~JSObject balances this ref() 220 220 , m_propertyStorage(m_inlineStorage) 221 221 { 222 ASSERT(m_structure ID);223 ASSERT(m_structure ID->propertyStorageCapacity() == inlineStorageCapacity);224 ASSERT(m_structure ID->isEmpty());222 ASSERT(m_structure); 223 ASSERT(m_structure->propertyStorageCapacity() == inlineStorageCapacity); 224 ASSERT(m_structure->isEmpty()); 225 225 ASSERT(prototype()->isNull() || Heap::heap(this) == Heap::heap(prototype())); 226 226 } … … 228 228 inline JSObject::~JSObject() 229 229 { 230 ASSERT(m_structure ID);230 ASSERT(m_structure); 231 231 if (m_propertyStorage != m_inlineStorage) 232 232 delete [] m_propertyStorage; 233 m_structure ID->deref();233 m_structure->deref(); 234 234 } 235 235 236 236 inline JSValue* JSObject::prototype() const 237 237 { 238 return m_structure ID->storedPrototype();238 return m_structure->storedPrototype(); 239 239 } 240 240 … … 242 242 { 243 243 ASSERT(prototype); 244 RefPtr<Structure ID> newStructureID = StructureID::changePrototypeTransition(m_structureID, prototype);245 setStructure ID(newStructureID.release());246 } 247 248 inline void JSObject::setStructure ID(PassRefPtr<StructureID> structureID)249 { 250 m_structure ID->deref();251 m_structure ID = structureID.releaseRef(); // ~JSObject balances this ref()252 } 253 254 inline Structure ID* JSObject::inheritorID()244 RefPtr<Structure> newStructure = Structure::changePrototypeTransition(m_structure, prototype); 245 setStructure(newStructure.release()); 246 } 247 248 inline void JSObject::setStructure(PassRefPtr<Structure> structure) 249 { 250 m_structure->deref(); 251 m_structure = structure.releaseRef(); // ~JSObject balances this ref() 252 } 253 254 inline Structure* JSObject::inheritorID() 255 255 { 256 256 if (m_inheritorID) … … 277 277 { 278 278 if (JSValue** location = getDirectLocation(propertyName)) { 279 if (m_structure ID->hasGetterSetterProperties() && location[0]->isGetterSetter())279 if (m_structure->hasGetterSetterProperties() && location[0]->isGetterSetter()) 280 280 fillGetterPropertySlot(slot, location); 281 281 else … … 297 297 unsigned attributes; 298 298 if (JSValue** location = getDirectLocation(propertyName, attributes)) { 299 if (m_structure ID->hasGetterSetterProperties() && location[0]->isGetterSetter()) {299 if (m_structure->hasGetterSetterProperties() && location[0]->isGetterSetter()) { 300 300 slotIsWriteable = false; 301 301 fillGetterPropertySlot(slot, location); … … 327 327 ALWAYS_INLINE bool JSCell::fastGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 328 328 { 329 if (structure ID()->typeInfo().hasStandardGetOwnPropertySlot())329 if (structure()->typeInfo().hasStandardGetOwnPropertySlot()) 330 330 return asObject(this)->inlineGetOwnPropertySlot(exec, propertyName, slot); 331 331 return getOwnPropertySlot(exec, propertyName, slot); … … 388 388 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 389 389 390 if (m_structure ID->isDictionary()) {390 if (m_structure->isDictionary()) { 391 391 unsigned currentAttributes; 392 size_t offset = m_structure ID->get(propertyName, currentAttributes);392 size_t offset = m_structure->get(propertyName, currentAttributes); 393 393 if (offset != WTF::notFound) { 394 394 if (checkReadOnly && currentAttributes & ReadOnly) … … 399 399 } 400 400 401 size_t currentCapacity = m_structure ID->propertyStorageCapacity();402 offset = m_structure ID->addPropertyWithoutTransition(propertyName, attributes);403 if (currentCapacity != m_structure ID->propertyStorageCapacity())404 allocatePropertyStorage(currentCapacity, m_structure ID->propertyStorageCapacity());405 406 ASSERT(offset < m_structure ID->propertyStorageCapacity());401 size_t currentCapacity = m_structure->propertyStorageCapacity(); 402 offset = m_structure->addPropertyWithoutTransition(propertyName, attributes); 403 if (currentCapacity != m_structure->propertyStorageCapacity()) 404 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); 405 406 ASSERT(offset < m_structure->propertyStorageCapacity()); 407 407 m_propertyStorage[offset] = value; 408 408 slot.setNewProperty(this, offset); … … 411 411 412 412 size_t offset; 413 size_t currentCapacity = m_structure ID->propertyStorageCapacity();414 if (RefPtr<Structure ID> structureID = StructureID::addPropertyTransitionToExistingStructure(m_structureID, propertyName, attributes, offset)) {415 if (currentCapacity != structure ID->propertyStorageCapacity())416 allocatePropertyStorage(currentCapacity, structure ID->propertyStorageCapacity());417 418 ASSERT(offset < structure ID->propertyStorageCapacity());413 size_t currentCapacity = m_structure->propertyStorageCapacity(); 414 if (RefPtr<Structure> structure = Structure::addPropertyTransitionToExistingStructure(m_structure, propertyName, attributes, offset)) { 415 if (currentCapacity != structure->propertyStorageCapacity()) 416 allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity()); 417 418 ASSERT(offset < structure->propertyStorageCapacity()); 419 419 m_propertyStorage[offset] = value; 420 420 slot.setNewProperty(this, offset); 421 421 slot.setWasTransition(true); 422 setStructure ID(structureID.release());422 setStructure(structure.release()); 423 423 return; 424 424 } 425 425 426 426 unsigned currentAttributes; 427 offset = m_structure ID->get(propertyName, currentAttributes);427 offset = m_structure->get(propertyName, currentAttributes); 428 428 if (offset != WTF::notFound) { 429 429 if (checkReadOnly && currentAttributes & ReadOnly) … … 434 434 } 435 435 436 RefPtr<Structure ID> structureID = StructureID::addPropertyTransition(m_structureID, propertyName, attributes, offset);437 if (currentCapacity != structure ID->propertyStorageCapacity())438 allocatePropertyStorage(currentCapacity, structure ID->propertyStorageCapacity());439 440 ASSERT(offset < structure ID->propertyStorageCapacity());436 RefPtr<Structure> structure = Structure::addPropertyTransition(m_structure, propertyName, attributes, offset); 437 if (currentCapacity != structure->propertyStorageCapacity()) 438 allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity()); 439 440 ASSERT(offset < structure->propertyStorageCapacity()); 441 441 m_propertyStorage[offset] = value; 442 442 slot.setNewProperty(this, offset); 443 443 slot.setWasTransition(true); 444 setStructure ID(structureID.release());444 setStructure(structure.release()); 445 445 } 446 446 447 447 inline void JSObject::putDirectWithoutTransition(const Identifier& propertyName, JSValue* value, unsigned attributes) 448 448 { 449 size_t currentCapacity = m_structure ID->propertyStorageCapacity();450 size_t offset = m_structure ID->addPropertyWithoutTransition(propertyName, attributes);451 if (currentCapacity != m_structure ID->propertyStorageCapacity())452 allocatePropertyStorage(currentCapacity, m_structure ID->propertyStorageCapacity());449 size_t currentCapacity = m_structure->propertyStorageCapacity(); 450 size_t offset = m_structure->addPropertyWithoutTransition(propertyName, attributes); 451 if (currentCapacity != m_structure->propertyStorageCapacity()) 452 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); 453 453 m_propertyStorage[offset] = value; 454 454 } 455 455 456 inline void JSObject::transitionTo(Structure ID* newStructureID)457 { 458 if (m_structure ID->propertyStorageCapacity() != newStructureID->propertyStorageCapacity())459 allocatePropertyStorage(m_structure ID->propertyStorageCapacity(), newStructureID->propertyStorageCapacity());460 setStructure ID(newStructureID);456 inline void JSObject::transitionTo(Structure* newStructure) 457 { 458 if (m_structure->propertyStorageCapacity() != newStructure->propertyStorageCapacity()) 459 allocatePropertyStorage(m_structure->propertyStorageCapacity(), newStructure->propertyStorageCapacity()); 460 setStructure(newStructure); 461 461 } 462 462
Note:
See TracChangeset
for help on using the changeset viewer.