Changeset 54129 in webkit
- Timestamp:
- Feb 1, 2010 1:43:01 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r54123 r54129 1 2010-01-31 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 JSC is failing to propagate anonymous slot count on some transitions 6 https://bugs.webkit.org/show_bug.cgi?id=34321 7 8 Remove secondary Structure constructor, and make Structure store a copy 9 of the number of anonymous slots directly so saving an immediate allocation 10 of a property map for all structures with anonymous storage, which also 11 avoids the leaked property map on new property transition in the original 12 version of this patch. 13 14 We need to propagate the the anonymous slot count otherwise we can end up 15 with a structure recording incorrect information about the available and 16 needed space for property storage, or alternatively incorrectly reusing 17 some slots. 18 19 * JavaScriptCore.exp: 20 * runtime/Structure.cpp: 21 (JSC::Structure::Structure): 22 (JSC::Structure::materializePropertyMap): 23 (JSC::Structure::addPropertyTransition): 24 (JSC::Structure::changePrototypeTransition): 25 (JSC::Structure::despecifyFunctionTransition): 26 (JSC::Structure::getterSetterTransition): 27 (JSC::Structure::toDictionaryTransition): 28 (JSC::Structure::flattenDictionaryStructure): 29 (JSC::Structure::copyPropertyTable): 30 (JSC::Structure::put): 31 (JSC::Structure::remove): 32 (JSC::Structure::insertIntoPropertyMapHashTable): 33 (JSC::Structure::createPropertyMapHashTable): 34 * runtime/Structure.h: 35 (JSC::Structure::create): 36 (JSC::Structure::hasAnonymousSlots): 37 (JSC::Structure::anonymousSlotCount): 38 1 39 2010-01-31 Patrick Gansterer <paroga@paroga.com> 2 40 -
trunk/JavaScriptCore/JavaScriptCore.exp
r54022 r54129 293 293 __ZN3JSC9Structure3getEPKNS_11UStringImplERjRPNS_6JSCellE 294 294 __ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjPNS_6JSCellERm 295 __ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoE 295 __ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoEj 296 296 __ZN3JSC9StructureD1Ev 297 297 __ZN3JSC9constructEPNS_9ExecStateENS_7JSValueENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE -
trunk/JavaScriptCore/runtime/Structure.cpp
r54100 r54129 124 124 } 125 125 126 Structure::Structure(JSValue prototype, const TypeInfo& typeInfo )126 Structure::Structure(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) 127 127 : m_typeInfo(typeInfo) 128 128 , m_prototype(prototype) … … 136 136 , m_attributesInPrevious(0) 137 137 , m_specificFunctionThrashCount(0) 138 , m_anonymousSlotCount(anonymousSlotCount) 138 139 { 139 140 ASSERT(m_prototype); … … 272 273 rehashPropertyMapHashTable(sizeForKeyCount(m_offset + 1)); // This could be made more efficient by combining with the copy above. 273 274 } 274 275 276 m_propertyTable->anonymousSlotCount = m_anonymousSlotCount; 275 277 for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) { 276 278 structure = structures[i]; … … 367 369 } 368 370 369 RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo() );371 RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); 370 372 371 373 transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain; … … 380 382 381 383 if (structure->m_propertyTable) { 384 ASSERT(structure->m_propertyTable->anonymousSlotCount == structure->m_anonymousSlotCount); 382 385 if (structure->m_isPinnedPropertyTable) 383 386 transition->m_propertyTable = structure->copyPropertyTable(); … … 398 401 399 402 transition->m_offset = offset; 400 403 ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); 401 404 structure->table.add(make_pair(propertyName.ustring().rep(), attributes), transition.get(), specificValue); 402 405 return transition.release(); … … 416 419 PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, JSValue prototype) 417 420 { 418 RefPtr<Structure> transition = create(prototype, structure->typeInfo() );421 RefPtr<Structure> transition = create(prototype, structure->typeInfo(), structure->anonymousSlotCount()); 419 422 420 423 transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; … … 428 431 transition->m_propertyTable = structure->copyPropertyTable(); 429 432 transition->m_isPinnedPropertyTable = true; 430 433 434 ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); 431 435 return transition.release(); 432 436 } … … 435 439 { 436 440 ASSERT(structure->m_specificFunctionThrashCount < maxSpecificFunctionThrashCount); 437 RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo() );441 RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); 438 442 439 443 transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; … … 454 458 ASSERT_UNUSED(removed, removed); 455 459 } 456 460 461 ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); 457 462 return transition.release(); 458 463 } … … 460 465 PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure) 461 466 { 462 RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo() );467 RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); 463 468 transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; 464 469 transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties; … … 471 476 transition->m_propertyTable = structure->copyPropertyTable(); 472 477 transition->m_isPinnedPropertyTable = true; 473 478 479 ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); 474 480 return transition.release(); 475 481 } … … 479 485 ASSERT(!structure->isUncacheableDictionary()); 480 486 481 RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo() );487 RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); 482 488 transition->m_dictionaryKind = kind; 483 489 transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; … … 490 496 transition->m_isPinnedPropertyTable = true; 491 497 498 ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); 492 499 return transition.release(); 493 500 } … … 523 530 // reorder the storage, so we have to copy the current values out 524 531 Vector<JSValue> values(propertyCount); 532 ASSERT(m_propertyTable->anonymousSlotCount == m_anonymousSlotCount); 525 533 unsigned anonymousSlotCount = m_propertyTable->anonymousSlotCount; 526 534 for (unsigned i = 0; i < propertyCount; i++) { … … 613 621 if (!m_propertyTable) 614 622 return 0; 615 623 624 ASSERT(m_propertyTable->anonymousSlotCount == m_anonymousSlotCount); 616 625 size_t tableSize = PropertyMapHashTable::allocationSize(m_propertyTable->size); 617 626 PropertyMapHashTable* newTable = static_cast<PropertyMapHashTable*>(fastMalloc(tableSize)); … … 755 764 if (!m_propertyTable) 756 765 createPropertyMapHashTable(); 766 ASSERT(m_propertyTable->anonymousSlotCount == m_anonymousSlotCount); 757 767 758 768 // FIXME: Consider a fast case for tables with no deleted sentinels. … … 849 859 if (!m_propertyTable) 850 860 return notFound; 851 861 862 ASSERT(m_propertyTable->anonymousSlotCount == m_anonymousSlotCount); 852 863 #if DUMP_PROPERTYMAP_STATS 853 864 ++numProbes; … … 913 924 { 914 925 ASSERT(m_propertyTable); 915 926 927 ASSERT(m_propertyTable->anonymousSlotCount == m_anonymousSlotCount); 916 928 unsigned i = entry.key->existingHash(); 917 929 unsigned k = 0; … … 963 975 m_propertyTable->size = newTableSize; 964 976 m_propertyTable->sizeMask = newTableSize - 1; 977 m_propertyTable->anonymousSlotCount = m_anonymousSlotCount; 965 978 966 979 checkConsistency(); -
trunk/JavaScriptCore/runtime/Structure.h
r54100 r54129 63 63 static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) 64 64 { 65 Structure* structure = (new Structure(prototype, typeInfo)); 66 if (anonymousSlotCount) { 67 structure->materializePropertyMap(); 68 structure->m_isPinnedPropertyTable = true; 69 structure->m_propertyTable->anonymousSlotCount = anonymousSlotCount; 70 // Currently we don't allow more anonymous slots than fit in the inline capacity 71 ASSERT(structure->propertyStorageSize() <= structure->propertyStorageCapacity()); 72 } 73 return adoptRef(structure); 65 return adoptRef(new Structure(prototype, typeInfo, anonymousSlotCount)); 74 66 } 75 67 … … 135 127 bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } 136 128 137 bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; }138 unsigned anonymousSlotCount() const { return m_ propertyTable ? m_propertyTable->anonymousSlotCount : 0; }129 bool hasAnonymousSlots() const { return !!m_anonymousSlotCount; } 130 unsigned anonymousSlotCount() const { return m_anonymousSlotCount; } 139 131 140 132 bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; } … … 148 140 149 141 private: 150 static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo) 151 { 152 return adoptRef(new Structure(prototype, typeInfo)); 153 } 154 155 Structure(JSValue prototype, const TypeInfo&); 142 143 Structure(JSValue prototype, const TypeInfo&, unsigned anonymousSlotCount); 156 144 157 145 typedef enum { … … 232 220 #endif 233 221 unsigned m_specificFunctionThrashCount : 2; 234 // 10 free bits 222 unsigned m_anonymousSlotCount : 5; 223 // 5 free bits 235 224 }; 236 225 -
trunk/LayoutTests/ChangeLog
r54121 r54129 1 2010-02-01 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 JSC is failing to propagate anonymous slot count on some transitions 6 https://bugs.webkit.org/show_bug.cgi?id=34321 7 8 Add test case for modifying DOM objects with anonymous storage. 9 10 * fast/dom/Window/anonymous-slot-with-changes-expected.txt: Added. 11 * fast/dom/Window/anonymous-slot-with-changes.html: Added. 12 1 13 2010-01-31 Kent Tamura <tkent@chromium.org> 2 14
Note: See TracChangeset
for help on using the changeset viewer.