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