Changeset 77044 in webkit for trunk/Source/JavaScriptCore/runtime/JSObject.h
- Timestamp:
- Jan 28, 2011, 8:06:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSObject.h
r77006 r77044 71 71 }; 72 72 73 typedef WriteBarrierBase<Unknown>* PropertyStorage;74 typedef const WriteBarrierBase<Unknown>* ConstPropertyStorage;73 typedef EncodedJSValue* PropertyStorage; 74 typedef const EncodedJSValue* ConstPropertyStorage; 75 75 76 76 class JSObject : public JSCell { … … 180 180 bool hasGetterSetterProperties() { return m_structure->hasGetterSetterProperties(); } 181 181 182 bool putDirect( JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, bool checkReadOnly, PutPropertySlot&);183 void putDirect( JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0);184 bool putDirect( JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&);185 186 void putDirectFunction( JSGlobalData&, const Identifier& propertyName, JSCell*, unsigned attr = 0);187 void putDirectFunction( JSGlobalData&, const Identifier& propertyName, JSCell*, unsigned attr, bool checkReadOnly, PutPropertySlot&);182 bool putDirect(const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 183 void putDirect(const Identifier& propertyName, JSValue value, unsigned attr = 0); 184 bool putDirect(const Identifier& propertyName, JSValue value, PutPropertySlot&); 185 186 void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr = 0); 187 void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 188 188 void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0); 189 189 void putDirectFunction(ExecState* exec, JSFunction* function, unsigned attr = 0); 190 190 191 void putDirectWithoutTransition( JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0);192 void putDirectFunctionWithoutTransition( JSGlobalData&,const Identifier& propertyName, JSCell* value, unsigned attr = 0);191 void putDirectWithoutTransition(const Identifier& propertyName, JSValue value, unsigned attr = 0); 192 void putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attr = 0); 193 193 void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr = 0); 194 194 void putDirectFunctionWithoutTransition(ExecState* exec, JSFunction* function, unsigned attr = 0); 195 195 196 196 // Fast access to known property offsets. 197 JSValue getDirectOffset(size_t offset) const { return propertyStorage()[offset].get(); } 198 void putDirectOffset(JSGlobalData& globalData, size_t offset, JSValue value) { propertyStorage()[offset].set(globalData, this, value); } 199 void putUndefinedAtDirectOffset(size_t offset) { propertyStorage()[offset].setUndefined(); } 197 JSValue getDirectOffset(size_t offset) const { return JSValue::decode(propertyStorage()[offset]); } 198 void putDirectOffset(size_t offset, JSValue value) { propertyStorage()[offset] = JSValue::encode(value); } 200 199 201 200 void fillGetterPropertySlot(PropertySlot&, JSValue* location); … … 227 226 } 228 227 229 void flattenDictionaryObject( JSGlobalData& globalData)230 { 231 m_structure->flattenDictionaryStructure( globalData,this);228 void flattenDictionaryObject() 229 { 230 m_structure->flattenDictionaryStructure(this); 232 231 } 233 232 … … 269 268 } 270 269 271 bool putDirectInternal( JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, bool checkReadOnly, PutPropertySlot&, JSCell*);272 bool putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue , unsigned attr, bool checkReadOnly, PutPropertySlot&);270 bool putDirectInternal(const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot, JSCell*); 271 bool putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 273 272 void putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue value, unsigned attr = 0); 274 273 … … 280 279 union { 281 280 PropertyStorage m_externalStorage; 282 WriteBarrierBase<Unknown>m_inlineStorage[inlineStorageCapacity];281 EncodedJSValue m_inlineStorage[inlineStorageCapacity]; 283 282 }; 284 283 … … 452 451 } 453 452 454 inline bool JSObject::putDirectInternal( JSGlobalData& globalData,const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot, JSCell* specificFunction)453 inline bool JSObject::putDirectInternal(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot, JSCell* specificFunction) 455 454 { 456 455 ASSERT(value); … … 469 468 return false; 470 469 471 putDirectOffset( globalData,offset, value);470 putDirectOffset(offset, value); 472 471 // At this point, the objects structure only has a specific value set if previously there 473 472 // had been one set, and if the new value being specified is the same (otherwise we would … … 487 486 488 487 ASSERT(offset < m_structure->propertyStorageCapacity()); 489 putDirectOffset( globalData,offset, value);488 putDirectOffset(offset, value); 490 489 // See comment on setNewProperty call below. 491 490 if (!specificFunction) … … 502 501 ASSERT(offset < structure->propertyStorageCapacity()); 503 502 setStructure(structure.release()); 504 putDirectOffset( globalData,offset, value);503 putDirectOffset(offset, value); 505 504 // This is a new property; transitions with specific values are not currently cachable, 506 505 // so leave the slot in an uncachable state. … … 529 528 // case (1) Do the put, then return leaving the slot uncachable. 530 529 if (specificFunction == currentSpecificFunction) { 531 putDirectOffset( globalData,offset, value);530 putDirectOffset(offset, value); 532 531 return true; 533 532 } … … 538 537 // case (3) set the slot, do the put, return. 539 538 slot.setExistingProperty(this, offset); 540 putDirectOffset( globalData,offset, value);539 putDirectOffset(offset, value); 541 540 return true; 542 541 } … … 559 558 ASSERT(offset < structure->propertyStorageCapacity()); 560 559 setStructure(structure.release()); 561 putDirectOffset( globalData,offset, value);560 putDirectOffset(offset, value); 562 561 // This is a new property; transitions with specific values are not currently cachable, 563 562 // so leave the slot in an uncachable state. … … 572 571 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 573 572 574 return putDirectInternal( globalData,propertyName, value, attributes, checkReadOnly, slot, getJSFunction(globalData, value));573 return putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, getJSFunction(globalData, value)); 575 574 } 576 575 … … 578 577 { 579 578 PutPropertySlot slot; 580 putDirectInternal( globalData,propertyName, value, attributes, false, slot, getJSFunction(globalData, value));581 } 582 583 inline bool JSObject::putDirect( JSGlobalData& globalData,const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)579 putDirectInternal(propertyName, value, attributes, false, slot, getJSFunction(globalData, value)); 580 } 581 582 inline bool JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 584 583 { 585 584 ASSERT(value); 586 585 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 587 586 588 return putDirectInternal( globalData,propertyName, value, attributes, checkReadOnly, slot, 0);589 } 590 591 inline void JSObject::putDirect( JSGlobalData& globalData,const Identifier& propertyName, JSValue value, unsigned attributes)587 return putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, 0); 588 } 589 590 inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes) 592 591 { 593 592 PutPropertySlot slot; 594 putDirectInternal( globalData,propertyName, value, attributes, false, slot, 0);595 } 596 597 inline bool JSObject::putDirect( JSGlobalData& globalData,const Identifier& propertyName, JSValue value, PutPropertySlot& slot)598 { 599 return putDirectInternal( globalData,propertyName, value, 0, false, slot, 0);600 } 601 602 inline void JSObject::putDirectFunction( JSGlobalData& globalData,const Identifier& propertyName, JSCell* value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)603 { 604 putDirectInternal( globalData,propertyName, value, attributes, checkReadOnly, slot, value);605 } 606 607 inline void JSObject::putDirectFunction( JSGlobalData& globalData,const Identifier& propertyName, JSCell* value, unsigned attr)593 putDirectInternal(propertyName, value, attributes, false, slot, 0); 594 } 595 596 inline bool JSObject::putDirect(const Identifier& propertyName, JSValue value, PutPropertySlot& slot) 597 { 598 return putDirectInternal(propertyName, value, 0, false, slot, 0); 599 } 600 601 inline void JSObject::putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 602 { 603 putDirectInternal(propertyName, value, attributes, checkReadOnly, slot, value); 604 } 605 606 inline void JSObject::putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr) 608 607 { 609 608 PutPropertySlot slot; 610 putDirectInternal( globalData,propertyName, value, attr, false, slot, value);611 } 612 613 inline void JSObject::putDirectWithoutTransition( JSGlobalData& globalData,const Identifier& propertyName, JSValue value, unsigned attributes)609 putDirectInternal(propertyName, value, attr, false, slot, value); 610 } 611 612 inline void JSObject::putDirectWithoutTransition(const Identifier& propertyName, JSValue value, unsigned attributes) 614 613 { 615 614 size_t currentCapacity = m_structure->propertyStorageCapacity(); … … 617 616 if (currentCapacity != m_structure->propertyStorageCapacity()) 618 617 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); 619 putDirectOffset( globalData,offset, value);620 } 621 622 inline void JSObject::putDirectFunctionWithoutTransition( JSGlobalData& globalData,const Identifier& propertyName, JSCell* value, unsigned attributes)618 putDirectOffset(offset, value); 619 } 620 621 inline void JSObject::putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attributes) 623 622 { 624 623 size_t currentCapacity = m_structure->propertyStorageCapacity(); … … 626 625 if (currentCapacity != m_structure->propertyStorageCapacity()) 627 626 allocatePropertyStorage(currentCapacity, m_structure->propertyStorageCapacity()); 628 putDirectOffset( globalData,offset, value);627 putDirectOffset(offset, value); 629 628 } 630 629 … … 705 704 { 706 705 ASSERT(isCell() && isObject()); 707 if (!asObject(asCell())->putDirect( exec->globalData(),propertyName, value, slot) && slot.isStrictMode())706 if (!asObject(asCell())->putDirect(propertyName, value, slot) && slot.isStrictMode()) 708 707 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 709 708 } … … 727 726 728 727 PropertyStorage oldPropertyStorage = (wasInline ? m_inlineStorage : m_externalStorage); 729 PropertyStorage newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];728 PropertyStorage newPropertyStorage = new EncodedJSValue[newSize]; 730 729 731 730 for (unsigned i = 0; i < oldSize; ++i) … … 742 741 JSCell::markChildren(markStack); 743 742 744 markStack.append(m_structure->storedPrototypeSlot()); 743 markStack.append(prototype()); 744 745 745 PropertyStorage storage = propertyStorage(); 746 746 size_t storageSize = m_structure->propertyStorageSize(); 747 markStack.appendValues( storage, storageSize);747 markStack.appendValues(reinterpret_cast<JSValue*>(storage), storageSize); 748 748 } 749 749
Note:
See TracChangeset
for help on using the changeset viewer.