Changeset 128400 in webkit for trunk/Source/JavaScriptCore/runtime/JSObject.h
- Timestamp:
- Sep 12, 2012, 9:18:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSObject.h
r128146 r128400 2 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 25 25 26 26 #include "ArgList.h" 27 #include "ArrayConventions.h" 28 #include "ArrayStorage.h" 29 #include "Butterfly.h" 27 30 #include "ClassInfo.h" 28 31 #include "CommonIdentifiers.h" … … 30 33 #include "JSCell.h" 31 34 #include "PropertySlot.h" 35 #include "PropertyStorage.h" 36 #include "PutDirectIndexMode.h" 32 37 #include "PutPropertySlot.h" 33 38 34 #include "StorageBarrier.h"35 39 #include "Structure.h" 36 40 #include "JSGlobalData.h" 37 41 #include "JSString.h" 42 #include "SparseArrayValueMap.h" 38 43 #include <wtf/StdLibExtras.h> 39 44 … … 80 85 }; 81 86 87 COMPILE_ASSERT(None < FirstInternalAttribute, None_is_below_FirstInternalAttribute); 88 COMPILE_ASSERT(ReadOnly < FirstInternalAttribute, ReadOnly_is_below_FirstInternalAttribute); 89 COMPILE_ASSERT(DontEnum < FirstInternalAttribute, DontEnum_is_below_FirstInternalAttribute); 90 COMPILE_ASSERT(DontDelete < FirstInternalAttribute, DontDelete_is_below_FirstInternalAttribute); 91 COMPILE_ASSERT(Function < FirstInternalAttribute, Function_is_below_FirstInternalAttribute); 92 COMPILE_ASSERT(Accessor < FirstInternalAttribute, Accessor_is_below_FirstInternalAttribute); 93 82 94 class JSFinalObject; 83 95 … … 97 109 public: 98 110 typedef JSCell Base; 99 111 100 112 JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&); 101 113 … … 121 133 bool allowsAccessFrom(ExecState*); 122 134 135 unsigned getArrayLength() const 136 { 137 switch (structure()->indexingType()) { 138 case NonArray: 139 case Array: 140 return 0; 141 case NonArrayWithArrayStorage: 142 case ArrayWithArrayStorage: 143 return m_butterfly->arrayStorage()->length(); 144 default: 145 ASSERT_NOT_REACHED(); 146 return 0; 147 } 148 } 149 150 unsigned getVectorLength() 151 { 152 switch (structure()->indexingType()) { 153 case NonArray: 154 case Array: 155 return 0; 156 case NonArrayWithArrayStorage: 157 case ArrayWithArrayStorage: 158 return m_butterfly->arrayStorage()->vectorLength(); 159 default: 160 ASSERT_NOT_REACHED(); 161 return 0; 162 } 163 } 164 123 165 JS_EXPORT_PRIVATE static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&); 124 166 JS_EXPORT_PRIVATE static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow); 167 168 // This is similar to the putDirect* methods: 169 // - the prototype chain is not consulted 170 // - accessors are not called. 171 // - it will ignore extensibility and read-only properties if PutDirectIndexLikePutDirect is passed as the mode (the default). 172 // This method creates a property with attributes writable, enumerable and configurable all set to true. 173 bool putDirectIndex(ExecState* exec, unsigned propertyName, JSValue value, unsigned attributes, PutDirectIndexMode mode) 174 { 175 if (!attributes && canSetIndexQuickly(propertyName)) { 176 setIndexQuickly(exec->globalData(), propertyName, value); 177 return true; 178 } 179 return putDirectIndexBeyondVectorLength(exec, propertyName, value, attributes, mode); 180 } 181 bool putDirectIndex(ExecState* exec, unsigned propertyName, JSValue value) 182 { 183 return putDirectIndex(exec, propertyName, value, 0, PutDirectIndexLikePutDirect); 184 } 185 186 // A non-throwing version of putDirect and putDirectIndex. 187 void putDirectMayBeIndex(ExecState*, PropertyName, JSValue); 188 189 bool canGetIndexQuickly(unsigned i) 190 { 191 switch (structure()->indexingType()) { 192 case NonArray: 193 case Array: 194 return false; 195 case NonArrayWithArrayStorage: 196 case ArrayWithArrayStorage: 197 return i < m_butterfly->arrayStorage()->vectorLength() && m_butterfly->arrayStorage()->m_vector[i]; 198 default: 199 ASSERT_NOT_REACHED(); 200 return false; 201 } 202 } 203 204 JSValue getIndexQuickly(unsigned i) 205 { 206 switch (structure()->indexingType()) { 207 case NonArrayWithArrayStorage: 208 case ArrayWithArrayStorage: 209 return m_butterfly->arrayStorage()->m_vector[i].get(); 210 default: 211 ASSERT_NOT_REACHED(); 212 return JSValue(); 213 } 214 } 215 216 bool canSetIndexQuickly(unsigned i) 217 { 218 switch (structure()->indexingType()) { 219 case NonArray: 220 case Array: 221 return false; 222 case NonArrayWithArrayStorage: 223 case ArrayWithArrayStorage: 224 return i < m_butterfly->arrayStorage()->vectorLength(); 225 default: 226 ASSERT_NOT_REACHED(); 227 return false; 228 } 229 } 230 231 void setIndexQuickly(JSGlobalData& globalData, unsigned i, JSValue v) 232 { 233 switch (structure()->indexingType()) { 234 case NonArrayWithArrayStorage: 235 case ArrayWithArrayStorage: { 236 WriteBarrier<Unknown>& x = m_butterfly->arrayStorage()->m_vector[i]; 237 if (!x) { 238 ArrayStorage* storage = m_butterfly->arrayStorage(); 239 ++storage->m_numValuesInVector; 240 if (i >= storage->length()) 241 storage->setLength(i + 1); 242 } 243 x.set(globalData, this, v); 244 break; 245 } 246 default: 247 ASSERT_NOT_REACHED(); 248 } 249 } 250 251 void initializeIndex(JSGlobalData& globalData, unsigned i, JSValue v) 252 { 253 switch (structure()->indexingType()) { 254 case NonArrayWithArrayStorage: 255 case ArrayWithArrayStorage: { 256 ArrayStorage* storage = m_butterfly->arrayStorage(); 257 #if CHECK_ARRAY_CONSISTENCY 258 ASSERT(storage->m_inCompactInitialization); 259 // Check that we are initializing the next index in sequence. 260 ASSERT(i == storage->m_initializationIndex); 261 // tryCreateUninitialized set m_numValuesInVector to the initialLength, 262 // check we do not try to initialize more than this number of properties. 263 ASSERT(storage->m_initializationIndex < storage->m_numValuesInVector); 264 storage->m_initializationIndex++; 265 #endif 266 ASSERT(i < storage->length()); 267 ASSERT(i < storage->m_numValuesInVector); 268 storage->m_vector[i].set(globalData, this, v); 269 break; 270 } 271 default: 272 ASSERT_NOT_REACHED(); 273 } 274 } 275 276 void completeInitialization(unsigned newLength) 277 { 278 switch (structure()->indexingType()) { 279 case NonArrayWithArrayStorage: 280 case ArrayWithArrayStorage: { 281 ArrayStorage* storage = m_butterfly->arrayStorage(); 282 // Check that we have initialized as meny properties as we think we have. 283 UNUSED_PARAM(storage); 284 ASSERT_UNUSED(newLength, newLength == storage->length()); 285 #if CHECK_ARRAY_CONSISTENCY 286 // Check that the number of propreties initialized matches the initialLength. 287 ASSERT(storage->m_initializationIndex == m_storage->m_numValuesInVector); 288 ASSERT(storage->m_inCompactInitialization); 289 storage->m_inCompactInitialization = false; 290 #endif 291 break; 292 } 293 default: 294 ASSERT_NOT_REACHED(); 295 } 296 } 297 298 bool inSparseIndexingMode() 299 { 300 switch (structure()->indexingType()) { 301 case NonArray: 302 case Array: 303 return false; 304 case NonArrayWithArrayStorage: 305 case ArrayWithArrayStorage: 306 return m_butterfly->arrayStorage()->inSparseMode(); 307 default: 308 ASSERT_NOT_REACHED(); 309 return false; 310 } 311 } 312 313 void enterDictionaryIndexingMode(JSGlobalData&); 125 314 126 315 // putDirect is effectively an unchecked vesion of 'defineOwnProperty': … … 128 317 // - accessors are not called. 129 318 // - attributes will be respected (after the call the property will exist with the given attributes) 319 // - the property name is assumed to not be an index. 130 320 JS_EXPORT_PRIVATE static void putDirectVirtual(JSObject*, ExecState*, PropertyName, JSValue, unsigned attributes); 131 321 void putDirect(JSGlobalData&, PropertyName, JSValue, unsigned attributes = 0); 132 322 void putDirect(JSGlobalData&, PropertyName, JSValue, PutPropertySlot&); 133 323 void putDirectWithoutTransition(JSGlobalData&, PropertyName, JSValue, unsigned attributes = 0); 134 void putDirectAccessor( JSGlobalData&, PropertyName, JSValue, unsigned attributes);324 void putDirectAccessor(ExecState*, PropertyName, JSValue, unsigned attributes); 135 325 136 326 bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const; … … 148 338 149 339 JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); 340 JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); 150 341 JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); 151 342 … … 204 395 } 205 396 206 ConstPropertyStorage outOfLineStorage() const { return m_outOfLineStorage.get(); } 207 PropertyStorage outOfLineStorage() { return m_outOfLineStorage.get(); } 397 const Butterfly* butterfly() const { return m_butterfly; } 398 Butterfly* butterfly() { return m_butterfly; } 399 400 ConstPropertyStorage outOfLineStorage() const { return m_butterfly->propertyStorage(); } 401 PropertyStorage outOfLineStorage() { return m_butterfly->propertyStorage(); } 208 402 209 403 const WriteBarrierBase<Unknown>* locationForOffset(PropertyOffset offset) const … … 228 422 result = offsetInInlineStorage; 229 423 else 230 result = outOfLineStorage() - location + (inlineStorageCapacity - 2);424 result = outOfLineStorage() - location + (inlineStorageCapacity - 1); 231 425 validateOffset(result, structure()->typeInfo().type()); 232 426 return result; … … 266 460 bool isFrozen(JSGlobalData& globalData) { return structure()->isFrozen(globalData); } 267 461 bool isExtensible() { return structure()->isExtensible(); } 462 bool indexingShouldBeSparse() 463 { 464 return !isExtensible() 465 || structure()->typeInfo().interceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero(); 466 } 268 467 269 468 bool staticFunctionsReified() { return structure()->staticFunctionsReified(); } 270 469 void reifyStaticFunctionsForDelete(ExecState* exec); 271 470 272 JS_EXPORT_PRIVATE PropertyStorage growOutOfLineStorage(JSGlobalData&, size_t oldSize, size_t newSize); 273 void setOutOfLineStorage(JSGlobalData&, PropertyStorage, Structure*); 471 JS_EXPORT_PRIVATE Butterfly* growOutOfLineStorage(JSGlobalData&, size_t oldSize, size_t newSize); 472 void setButterfly(JSGlobalData&, Butterfly*, Structure*); 473 void setButterflyWithoutChangingStructure(Butterfly*); // You probably don't want to call this. 274 474 275 475 void setStructureAndReallocateStorageIfNecessary(JSGlobalData&, unsigned oldCapacity, Structure*); 276 476 void setStructureAndReallocateStorageIfNecessary(JSGlobalData&, Structure*); 277 278 void* addressOfOutOfLineStorage()279 {280 return &m_outOfLineStorage;281 }282 477 283 478 void flattenDictionaryObject(JSGlobalData& globalData) … … 294 489 295 490 static size_t offsetOfInlineStorage(); 296 static size_t offsetOfOutOfLineStorage(); 491 492 static ptrdiff_t butterflyOffset() 493 { 494 return OBJECT_OFFSETOF(JSObject, m_butterfly); 495 } 496 497 void* butterflyAddress() 498 { 499 return &m_butterfly; 500 } 297 501 298 502 static JS_EXPORTDATA const ClassInfo s_info; … … 317 521 // To instantiate objects you likely want JSFinalObject, below. 318 522 // To create derived types you likely want JSNonFinalObject, below. 319 JSObject(JSGlobalData&, Structure* );523 JSObject(JSGlobalData&, Structure*, Butterfly* = 0); 320 524 321 525 void resetInheritorID(JSGlobalData& globalData) … … 324 528 } 325 529 326 void visitOutOfLineStorage(SlotVisitor&, PropertyStorage, size_t storageSize); 530 void visitButterfly(SlotVisitor&, Butterfly*, size_t storageSize); 531 532 // Call this if you know that the object is in a mode where it has array 533 // storage. This will assert otherwise. 534 ArrayStorage* arrayStorage() 535 { 536 ASSERT(structure()->indexingType() | HasArrayStorage); 537 return m_butterfly->arrayStorage(); 538 } 539 540 // Call this if you want to predicate some actions on whether or not the 541 // object is in a mode where it has array storage. 542 ArrayStorage* arrayStorageOrNull() 543 { 544 switch (structure()->indexingType()) { 545 case ArrayWithArrayStorage: 546 case NonArrayWithArrayStorage: 547 return m_butterfly->arrayStorage(); 548 549 default: 550 return 0; 551 } 552 } 553 554 // Ensure that the object is in a mode where it has array storage. Use 555 // this if you're about to perform actions that would have required the 556 // object to be converted to have array storage, if it didn't have it 557 // already. 558 ArrayStorage* ensureArrayStorage(JSGlobalData& globalData) 559 { 560 switch (structure()->indexingType()) { 561 case ArrayWithArrayStorage: 562 case NonArrayWithArrayStorage: 563 return m_butterfly->arrayStorage(); 564 565 case NonArray: 566 case Array: 567 return createInitialArrayStorage(globalData); 568 569 default: 570 ASSERT_NOT_REACHED(); 571 return 0; 572 } 573 } 574 575 ArrayStorage* createArrayStorage(JSGlobalData&, unsigned length, unsigned vectorLength); 576 ArrayStorage* createInitialArrayStorage(JSGlobalData&); 577 578 ArrayStorage* ensureArrayStorageExistsAndEnterDictionaryIndexingMode(JSGlobalData&); 579 580 bool defineOwnNonIndexProperty(ExecState*, PropertyName, PropertyDescriptor&, bool throwException); 581 582 enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck }; 583 #if !CHECK_ARRAY_CONSISTENCY 584 void checkIndexingConsistency(ConsistencyCheckType = NormalConsistencyCheck) { } 585 #else 586 void checkIndexingConsistency(ConsistencyCheckType = NormalConsistencyCheck); 587 #endif 588 589 void putByIndexBeyondVectorLengthWithArrayStorage(ExecState*, unsigned propertyName, JSValue, bool shouldThrow, ArrayStorage*); 590 591 bool increaseVectorLength(JSGlobalData&, unsigned newLength); 592 void deallocateSparseIndexMap(); 593 bool defineOwnIndexedProperty(ExecState*, unsigned, PropertyDescriptor&, bool throwException); 594 SparseArrayValueMap* allocateSparseIndexMap(JSGlobalData&); 327 595 328 596 private: … … 337 605 void isString(); 338 606 607 ArrayStorage* enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(JSGlobalData&, ArrayStorage*); 608 339 609 template<PutMode> 340 610 bool putDirectInternal(JSGlobalData&, PropertyName, JSValue, unsigned attr, PutPropertySlot&, JSCell*); 341 611 342 612 bool inlineGetOwnPropertySlot(ExecState*, PropertyName, PropertySlot&); 343 JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, WriteBarrierBase<Unknown>* location);613 JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, PropertyOffset); 344 614 345 615 const HashEntry* findPropertyHashEntry(ExecState*, PropertyName) const; 346 616 Structure* createInheritorID(JSGlobalData&); 347 348 StorageBarrier m_outOfLineStorage; 617 618 void putIndexedDescriptor(ExecState*, SparseArrayEntry*, PropertyDescriptor&, PropertyDescriptor& old); 619 620 void putByIndexBeyondVectorLength(ExecState*, unsigned propertyName, JSValue, bool shouldThrow); 621 bool putDirectIndexBeyondVectorLengthWithArrayStorage(ExecState*, unsigned propertyName, JSValue, unsigned attributes, PutDirectIndexMode, ArrayStorage*); 622 JS_EXPORT_PRIVATE bool putDirectIndexBeyondVectorLength(ExecState*, unsigned propertyName, JSValue, unsigned attributes, PutDirectIndexMode); 623 624 unsigned getNewVectorLength(unsigned currentVectorLength, unsigned currentLength, unsigned desiredLength); 625 unsigned getNewVectorLength(unsigned desiredLength); 626 627 JS_EXPORT_PRIVATE bool getOwnPropertySlotSlow(ExecState*, PropertyName, PropertySlot&); 628 629 protected: 630 Butterfly* m_butterfly; 349 631 }; 350 632 … … 370 652 371 653 protected: 372 explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure )373 : JSObject(globalData, structure )654 explicit JSNonFinalObject(JSGlobalData& globalData, Structure* structure, Butterfly* butterfly = 0) 655 : JSObject(globalData, structure, butterfly) 374 656 { 375 657 } … … 454 736 } 455 737 456 inline size_t JSObject::offsetOfOutOfLineStorage()457 {458 return OBJECT_OFFSETOF(JSObject, m_outOfLineStorage);459 }460 461 738 inline bool JSObject::isGlobalObject() const 462 739 { … … 489 766 } 490 767 491 inline void JSObject::set OutOfLineStorage(JSGlobalData& globalData, PropertyStorage storage, Structure* structure)768 inline void JSObject::setButterfly(JSGlobalData& globalData, Butterfly* butterfly, Structure* structure) 492 769 { 493 770 ASSERT(structure); 494 if (!storage) { 495 ASSERT(!structure->outOfLineCapacity()); 496 ASSERT(!structure->outOfLineSize()); 497 } else { 498 ASSERT(structure->outOfLineCapacity()); 499 ASSERT(structure->outOfLineSize()); 500 } 771 ASSERT(!butterfly == (!structure->outOfLineCapacity() && !hasIndexingHeader(structure->indexingType()))); 501 772 setStructure(globalData, structure); 502 m_outOfLineStorage.set(globalData, this, storage); 773 m_butterfly = butterfly; 774 } 775 776 inline void JSObject::setButterflyWithoutChangingStructure(Butterfly* butterfly) 777 { 778 m_butterfly = butterfly; 503 779 } 504 780 … … 538 814 } 539 815 540 inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure )816 inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure, Butterfly* butterfly) 541 817 : JSCell(globalData, structure) 542 , m_ outOfLineStorage(globalData, this, 0)818 , m_butterfly(butterfly) 543 819 { 544 820 } … … 588 864 ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot) 589 865 { 590 if (WriteBarrierBase<Unknown>* location = getDirectLocation(exec->globalData(), propertyName)) { 591 if (structure()->hasGetterSetterProperties() && location->isGetterSetter()) 592 fillGetterPropertySlot(slot, location); 866 PropertyOffset offset = structure()->get(exec->globalData(), propertyName); 867 if (LIKELY(isValidOffset(offset))) { 868 JSValue value = getDirectOffset(offset); 869 if (structure()->hasGetterSetterProperties() && value.isGetterSetter()) 870 fillGetterPropertySlot(slot, offset); 593 871 else 594 slot.setValue(this, location->get(), offsetForLocation(location));872 slot.setValue(this, value, offset); 595 873 return true; 596 874 } 597 875 598 return false;876 return getOwnPropertySlotSlow(exec, propertyName, slot); 599 877 } 600 878 … … 682 960 ASSERT(value.isGetterSetter() == !!(attributes & Accessor)); 683 961 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 962 ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex); 684 963 685 964 if (structure()->isDictionary()) { … … 710 989 return false; 711 990 712 PropertyStorage newStorage = outOfLineStorage();991 Butterfly* newButterfly = m_butterfly; 713 992 if (structure()->putWillGrowOutOfLineStorage()) 714 new Storage= growOutOfLineStorage(globalData, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());993 newButterfly = growOutOfLineStorage(globalData, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity()); 715 994 offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, specificFunction); 716 set OutOfLineStorage(globalData, newStorage, structure());995 setButterfly(globalData, newButterfly, structure()); 717 996 718 997 validateOffset(offset); … … 728 1007 size_t currentCapacity = structure()->outOfLineCapacity(); 729 1008 if (Structure* structure = Structure::addPropertyTransitionToExistingStructure(this->structure(), propertyName, attributes, specificFunction, offset)) { 730 PropertyStorage newStorage = outOfLineStorage();1009 Butterfly* newButterfly = m_butterfly; 731 1010 if (currentCapacity != structure->outOfLineCapacity()) 732 new Storage= growOutOfLineStorage(globalData, currentCapacity, structure->outOfLineCapacity());1011 newButterfly = growOutOfLineStorage(globalData, currentCapacity, structure->outOfLineCapacity()); 733 1012 734 1013 validateOffset(offset); 735 1014 ASSERT(structure->isValidOffset(offset)); 736 set OutOfLineStorage(globalData, newStorage, structure);1015 setButterfly(globalData, newButterfly, structure); 737 1016 putDirectOffset(globalData, offset, value); 738 1017 // This is a new property; transitions with specific values are not currently cachable, … … 801 1080 } 802 1081 803 PropertyStorage newStorage= growOutOfLineStorage(1082 Butterfly* newButterfly = growOutOfLineStorage( 804 1083 globalData, oldCapacity, newStructure->outOfLineCapacity()); 805 set OutOfLineStorage(globalData, newStorage, newStructure);1084 setButterfly(globalData, newButterfly, newStructure); 806 1085 } 807 1086 … … 837 1116 { 838 1117 ASSERT(!value.isGetterSetter() && !(attributes & Accessor)); 839 PropertyStorage newStorage = outOfLineStorage();1118 Butterfly* newButterfly = m_butterfly; 840 1119 if (structure()->putWillGrowOutOfLineStorage()) 841 new Storage= growOutOfLineStorage(globalData, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());1120 newButterfly = growOutOfLineStorage(globalData, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity()); 842 1121 PropertyOffset offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, getCallableObject(value)); 843 set OutOfLineStorage(globalData, newStorage, structure());1122 setButterfly(globalData, newButterfly, structure()); 844 1123 putDirectOffset(globalData, offset, value); 845 1124 } … … 933 1212 } 934 1213 1214 inline size_t offsetInButterfly(PropertyOffset offset) 1215 { 1216 return offsetInOutOfLineStorage(offset) + Butterfly::indexOfPropertyStorage(); 1217 } 1218 935 1219 // This is a helper for patching code where you want to emit a load or store and 936 1220 // the base is: … … 940 1224 { 941 1225 if (isOutOfLineOffset(offset)) 942 return sizeof(EncodedJSValue) * offsetIn OutOfLineStorage(offset);943 return JSObject::offsetOfInlineStorage() - JSObject:: offsetOfOutOfLineStorage() + sizeof(EncodedJSValue) * offsetInInlineStorage(offset);1226 return sizeof(EncodedJSValue) * offsetInButterfly(offset); 1227 return JSObject::offsetOfInlineStorage() - JSObject::butterflyOffset() + sizeof(EncodedJSValue) * offsetInInlineStorage(offset); 944 1228 } 945 1229 … … 947 1231 { 948 1232 if (isOutOfLineOffset(offset)) 949 return offsetInOutOfLineStorage(offset) ;1233 return offsetInOutOfLineStorage(offset) + Butterfly::indexOfPropertyStorage(); 950 1234 ASSERT(!(JSObject::offsetOfInlineStorage() % sizeof(EncodedJSValue))); 951 1235 return JSObject::offsetOfInlineStorage() / sizeof(EncodedJSValue) + offsetInInlineStorage(offset); … … 955 1239 { 956 1240 if (isOutOfLineOffset(offset)) 957 return offsetInOutOfLineStorage(offset) * sizeof(EncodedJSValue) ;1241 return offsetInOutOfLineStorage(offset) * sizeof(EncodedJSValue) + Butterfly::offsetOfPropertyStorage(); 958 1242 return JSObject::offsetOfInlineStorage() + offsetInInlineStorage(offset) * sizeof(EncodedJSValue); 959 1243 }
Note:
See TracChangeset
for help on using the changeset viewer.