Changeset 44076 in webkit for trunk/JavaScriptCore/runtime/JSObject.h
- Timestamp:
- May 22, 2009, 6:48:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSObject.h
r43692 r44076 33 33 #include "ScopeChain.h" 34 34 #include "Structure.h" 35 #include "JSGlobalData.h" 35 36 36 37 namespace JSC { 38 39 inline JSCell* getJSFunction(JSGlobalData& globalData, JSValue value) 40 { 41 if (value.isCell() && (value.asCell()->vptr() == globalData.jsFunctionVPtr)) 42 return value.asCell(); 43 return 0; 44 } 37 45 38 46 class InternalFunction; … … 94 102 virtual void put(ExecState*, unsigned propertyName, JSValue value); 95 103 104 virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot); 96 105 virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue value, unsigned attributes); 97 106 virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue value, unsigned attributes); … … 123 132 124 133 virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const; 134 bool getPropertySpecificValue(ExecState* exec, const Identifier& propertyName, JSCell*& specificFunction) const; 125 135 126 136 // This get function only looks at the property map. … … 144 154 JSValue* getDirectLocation(const Identifier& propertyName, unsigned& attributes) 145 155 { 146 size_t offset = m_structure->get(propertyName, attributes); 156 JSCell* specificFunction; 157 size_t offset = m_structure->get(propertyName, attributes, specificFunction); 147 158 return offset != WTF::notFound ? locationForOffset(offset) : 0; 148 159 } … … 169 180 bool hasGetterSetterProperties() { return m_structure->hasGetterSetterProperties(); } 170 181 182 void putDirect(const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 171 183 void putDirect(const Identifier& propertyName, JSValue value, unsigned attr = 0); 172 void putDirect(const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 184 185 void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr = 0); 186 void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 173 187 void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0); 188 174 189 void putDirectWithoutTransition(const Identifier& propertyName, JSValue value, unsigned attr = 0); 190 void putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attr = 0); 175 191 void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr = 0); 176 192 … … 208 224 209 225 private: 226 void putDirectInternal(const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot, JSCell*); 227 void putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 228 void putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue value, unsigned attr = 0); 229 210 230 bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 211 231 … … 397 417 } 398 418 399 inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attr) 400 { 401 PutPropertySlot slot; 402 putDirect(propertyName, value, attr, false, slot); 403 } 404 405 inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 419 inline void JSObject::putDirectInternal(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot, JSCell* specificFunction) 406 420 { 407 421 ASSERT(value); … … 410 424 if (m_structure->isDictionary()) { 411 425 unsigned currentAttributes; 412 size_t offset = m_structure->get(propertyName, currentAttributes); 426 JSCell* currentSpecificFunction; 427 size_t offset = m_structure->get(propertyName, currentAttributes, currentSpecificFunction); 413 428 if (offset != WTF::notFound) { 414 429 if (checkReadOnly && currentAttributes & ReadOnly) … … 420 435 421 436 size_t currentCapacity = m_structure->propertyStorageCapacity(); 422 offset = m_structure->addPropertyWithoutTransition(propertyName, attributes );437 offset = m_structure->addPropertyWithoutTransition(propertyName, attributes, specificFunction); 423 438 if (currentCapacity != m_structure->propertyStorageCapacity()) 424 439 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); … … 426 441 ASSERT(offset < m_structure->propertyStorageCapacity()); 427 442 putDirectOffset(offset, value); 428 slot.setNewProperty(this, offset); 443 // See comment on setNewProperty call below. 444 if (!specificFunction) 445 slot.setNewProperty(this, offset); 429 446 return; 430 447 } … … 432 449 size_t offset; 433 450 size_t currentCapacity = m_structure->propertyStorageCapacity(); 434 if (RefPtr<Structure> structure = Structure::addPropertyTransitionToExistingStructure(m_structure, propertyName, attributes, offset)) {451 if (RefPtr<Structure> structure = Structure::addPropertyTransitionToExistingStructure(m_structure, propertyName, attributes, specificFunction, offset)) { 435 452 if (currentCapacity != structure->propertyStorageCapacity()) 436 453 allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity()); … … 439 456 setStructure(structure.release()); 440 457 putDirectOffset(offset, value); 441 slot.setNewProperty(this, offset); 442 slot.setWasTransition(true); 458 // See comment on setNewProperty call below. 459 if (!specificFunction) 460 slot.setNewProperty(this, offset); 443 461 return; 444 462 } 445 463 446 464 unsigned currentAttributes; 447 offset = m_structure->get(propertyName, currentAttributes); 465 JSCell* currentSpecificFunction; 466 offset = m_structure->get(propertyName, currentAttributes, currentSpecificFunction); 448 467 if (offset != WTF::notFound) { 449 468 if (checkReadOnly && currentAttributes & ReadOnly) 450 469 return; 470 471 if (currentSpecificFunction && (specificFunction != currentSpecificFunction)) { 472 setStructure(Structure::changeFunctionTransition(m_structure, propertyName)); 473 putDirectOffset(offset, value); 474 // Function transitions are not currently cachable, so leave the slot in an uncachable state. 475 return; 476 } 451 477 putDirectOffset(offset, value); 452 478 slot.setExistingProperty(this, offset); … … 454 480 } 455 481 456 RefPtr<Structure> structure = Structure::addPropertyTransition(m_structure, propertyName, attributes, offset);482 RefPtr<Structure> structure = Structure::addPropertyTransition(m_structure, propertyName, attributes, specificFunction, offset); 457 483 if (currentCapacity != structure->propertyStorageCapacity()) 458 484 allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity()); … … 461 487 setStructure(structure.release()); 462 488 putDirectOffset(offset, value); 463 slot.setNewProperty(this, offset); 464 slot.setWasTransition(true); 489 // Function transitions are not currently cachable, so leave the slot in an uncachable state. 490 if (!specificFunction) 491 slot.setNewProperty(this, offset); 492 } 493 494 inline void JSObject::putDirectInternal(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 495 { 496 ASSERT(value); 497 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 498 499 putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, getJSFunction(globalData, value)); 500 } 501 502 inline void JSObject::putDirectInternal(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes) 503 { 504 PutPropertySlot slot; 505 putDirectInternal(propertyName, value, attributes, false, slot, getJSFunction(globalData, value)); 506 } 507 508 inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 509 { 510 ASSERT(value); 511 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 512 513 putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, 0); 514 } 515 516 inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes) 517 { 518 PutPropertySlot slot; 519 putDirectInternal(propertyName, value, attributes, false, slot, 0); 520 } 521 522 inline void JSObject::putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 523 { 524 putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, value); 525 } 526 527 inline void JSObject::putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr) 528 { 529 PutPropertySlot slot; 530 putDirectInternal(propertyName, value, attr, false, slot, value); 465 531 } 466 532 … … 468 534 { 469 535 size_t currentCapacity = m_structure->propertyStorageCapacity(); 470 size_t offset = m_structure->addPropertyWithoutTransition(propertyName, attributes); 536 size_t offset = m_structure->addPropertyWithoutTransition(propertyName, attributes, 0); 537 if (currentCapacity != m_structure->propertyStorageCapacity()) 538 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); 539 putDirectOffset(offset, value); 540 } 541 542 inline void JSObject::putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attributes) 543 { 544 size_t currentCapacity = m_structure->propertyStorageCapacity(); 545 size_t offset = m_structure->addPropertyWithoutTransition(propertyName, attributes, value); 471 546 if (currentCapacity != m_structure->propertyStorageCapacity()) 472 547 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity());
Note:
See TracChangeset
for help on using the changeset viewer.