Changeset 222827 in webkit for trunk/Source/JavaScriptCore/runtime/JSObject.cpp
- Timestamp:
- Oct 3, 2017, 6:53:18 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r222744 r222827 771 771 if (isValidOffset(offset)) { 772 772 if (attributes & PropertyAttribute::ReadOnly) { 773 ASSERT( structure(vm)->prototypeChainMayInterceptStoreTo(vm, propertyName) || obj == this);773 ASSERT(this->prototypeChainMayInterceptStoreTo(vm, propertyName) || obj == this); 774 774 return typeError(exec, scope, slot.isStrictMode(), ASCIILiteral(ReadonlyPropertyWriteError)); 775 775 } … … 1017 1017 IndexingType oldType = indexingType(); 1018 1018 ASSERT_UNUSED(oldType, !hasIndexedProperties(oldType)); 1019 ASSERT(! structure()->needsSlowPutIndexing());1019 ASSERT(!needsSlowPutIndexing()); 1020 1020 ASSERT(!indexingShouldBeSparse()); 1021 1021 Structure* structure = this->structure(vm); … … 1113 1113 Butterfly* newButterfly = createArrayStorageButterfly(vm, this, oldStructure, length, vectorLength, m_butterfly.getMayBeNull()); 1114 1114 ArrayStorage* result = newButterfly->arrayStorage(); 1115 Structure* newStructure = Structure::nonPropertyTransition(vm, oldStructure, oldStructure->suggestedArrayStorageTransition());1115 Structure* newStructure = Structure::nonPropertyTransition(vm, oldStructure, suggestedArrayStorageTransition()); 1116 1116 nukeStructureAndSetButterfly(vm, oldStructureID, newButterfly); 1117 1117 setStructure(vm, newStructure); … … 1208 1208 ArrayStorage* JSObject::convertUndecidedToArrayStorage(VM& vm) 1209 1209 { 1210 return convertUndecidedToArrayStorage(vm, s tructure(vm)->suggestedArrayStorageTransition());1210 return convertUndecidedToArrayStorage(vm, suggestedArrayStorageTransition()); 1211 1211 } 1212 1212 … … 1266 1266 ArrayStorage* JSObject::convertInt32ToArrayStorage(VM& vm) 1267 1267 { 1268 return convertInt32ToArrayStorage(vm, s tructure(vm)->suggestedArrayStorageTransition());1268 return convertInt32ToArrayStorage(vm, suggestedArrayStorageTransition()); 1269 1269 } 1270 1270 … … 1319 1319 ArrayStorage* JSObject::convertDoubleToArrayStorage(VM& vm) 1320 1320 { 1321 return convertDoubleToArrayStorage(vm, s tructure(vm)->suggestedArrayStorageTransition());1321 return convertDoubleToArrayStorage(vm, suggestedArrayStorageTransition()); 1322 1322 } 1323 1323 … … 1368 1368 ArrayStorage* JSObject::convertContiguousToArrayStorage(VM& vm) 1369 1369 { 1370 return convertContiguousToArrayStorage(vm, s tructure(vm)->suggestedArrayStorageTransition());1370 return convertContiguousToArrayStorage(vm, suggestedArrayStorageTransition()); 1371 1371 } 1372 1372 … … 1449 1449 switch (indexingType()) { 1450 1450 case ALL_BLANK_INDEXING_TYPES: 1451 if (UNLIKELY(indexingShouldBeSparse() || structure(vm)->needsSlowPutIndexing()))1451 if (UNLIKELY(indexingShouldBeSparse() || needsSlowPutIndexing())) 1452 1452 return ContiguousJSValues(); 1453 1453 return createInitialInt32(vm, 0); … … 1476 1476 switch (indexingType()) { 1477 1477 case ALL_BLANK_INDEXING_TYPES: 1478 if (UNLIKELY(indexingShouldBeSparse() || structure(vm)->needsSlowPutIndexing()))1478 if (UNLIKELY(indexingShouldBeSparse() || needsSlowPutIndexing())) 1479 1479 return ContiguousDoubles(); 1480 1480 return createInitialDouble(vm, 0); … … 1505 1505 switch (indexingType()) { 1506 1506 case ALL_BLANK_INDEXING_TYPES: 1507 if (UNLIKELY(indexingShouldBeSparse() || structure(vm)->needsSlowPutIndexing()))1507 if (UNLIKELY(indexingShouldBeSparse() || needsSlowPutIndexing())) 1508 1508 return ContiguousJSValues(); 1509 1509 return createInitialContiguous(vm, 0); … … 1542 1542 case ALL_UNDECIDED_INDEXING_TYPES: 1543 1543 ASSERT(!indexingShouldBeSparse()); 1544 ASSERT(! structure(vm)->needsSlowPutIndexing());1544 ASSERT(!needsSlowPutIndexing()); 1545 1545 return convertUndecidedToArrayStorage(vm); 1546 1546 1547 1547 case ALL_INT32_INDEXING_TYPES: 1548 1548 ASSERT(!indexingShouldBeSparse()); 1549 ASSERT(! structure(vm)->needsSlowPutIndexing());1549 ASSERT(!needsSlowPutIndexing()); 1550 1550 return convertInt32ToArrayStorage(vm); 1551 1551 1552 1552 case ALL_DOUBLE_INDEXING_TYPES: 1553 1553 ASSERT(!indexingShouldBeSparse()); 1554 ASSERT(! structure(vm)->needsSlowPutIndexing());1554 ASSERT(!needsSlowPutIndexing()); 1555 1555 return convertDoubleToArrayStorage(vm); 1556 1556 1557 1557 case ALL_CONTIGUOUS_INDEXING_TYPES: 1558 1558 ASSERT(!indexingShouldBeSparse()); 1559 ASSERT(! structure(vm)->needsSlowPutIndexing());1559 ASSERT(!needsSlowPutIndexing()); 1560 1560 return convertContiguousToArrayStorage(vm); 1561 1561 … … 1635 1635 vm.prototypeMap.addPrototype(asObject(prototype)); 1636 1636 1637 Structure* newStructure = Structure::changePrototypeTransition(vm, structure(vm), prototype); 1638 setStructure(vm, newStructure); 1639 1640 if (!newStructure->anyObjectInChainMayInterceptIndexedAccesses()) 1637 if (structure(vm)->hasMonoProto()) { 1638 Structure* newStructure = Structure::changePrototypeTransition(vm, structure(vm), prototype); 1639 setStructure(vm, newStructure); 1640 } else 1641 putDirect(vm, structure(vm)->polyProtoOffset(), prototype); 1642 1643 if (!anyObjectInChainMayInterceptIndexedAccesses()) 1641 1644 return; 1642 1645 1643 1646 if (vm.prototypeMap.isPrototype(this)) { 1644 newStructure->globalObject()->haveABadTime(vm);1647 structure(vm)->globalObject()->haveABadTime(vm); 1645 1648 return; 1646 1649 } … … 1953 1956 // Make sure that whatever default value methods there are on object's prototype chain are 1954 1957 // being watched. 1955 this->structure()->startWatchingInternalPropertiesIfNecessaryForEntireChain(vm); 1958 for (const JSObject* object = this; object; object = object->structure(vm)->storedPrototypeObject(object)) 1959 object->structure(vm)->startWatchingInternalPropertiesIfNecessary(vm); 1956 1960 1957 1961 JSValue value; … … 2728 2732 exec, i, value, shouldThrow, createArrayStorage(vm, 0, 0)); 2729 2733 } 2730 if ( structure(vm)->needsSlowPutIndexing()) {2734 if (needsSlowPutIndexing()) { 2731 2735 // Convert the indexing type to the SlowPutArrayStorage and retry. 2732 2736 createArrayStorage(vm, i + 1, getNewVectorLength(0, 0, 0, i + 1)); … … 2880 2884 exec, i, value, attributes, mode, createArrayStorage(vm, 0, 0)); 2881 2885 } 2882 if ( structure(vm)->needsSlowPutIndexing()) {2886 if (needsSlowPutIndexing()) { 2883 2887 ArrayStorage* storage = createArrayStorage(vm, i + 1, getNewVectorLength(0, 0, 0, i + 1)); 2884 2888 storage->m_vector[i].set(vm, this, value); … … 3560 3564 VM& vm = exec->vm(); 3561 3565 Structure* structure = object->structure(vm); 3562 if (structure->holesMustForwardToPrototype(vm ))3566 if (structure->holesMustForwardToPrototype(vm, object)) 3563 3567 return 0; 3564 3568 switch (object->indexingType()) { … … 3670 3674 } 3671 3675 3676 bool JSObject::anyObjectInChainMayInterceptIndexedAccesses() const 3677 { 3678 VM& vm = *this->vm(); 3679 for (const JSObject* current = this; ;) { 3680 if (current->structure(vm)->mayInterceptIndexedAccesses()) 3681 return true; 3682 3683 JSValue prototype = current->getPrototypeDirect(); 3684 if (prototype.isNull()) 3685 return false; 3686 3687 current = asObject(prototype); 3688 } 3689 } 3690 3691 bool JSObject::prototypeChainMayInterceptStoreTo(VM& vm, PropertyName propertyName) 3692 { 3693 if (parseIndex(propertyName)) 3694 return anyObjectInChainMayInterceptIndexedAccesses(); 3695 3696 for (JSObject* current = this; ;) { 3697 JSValue prototype = current->getPrototypeDirect(); 3698 if (prototype.isNull()) 3699 return false; 3700 3701 current = asObject(prototype); 3702 3703 unsigned attributes; 3704 PropertyOffset offset = current->structure(vm)->get(vm, propertyName, attributes); 3705 if (!JSC::isValidOffset(offset)) 3706 continue; 3707 3708 if (attributes & (PropertyAttribute::ReadOnly | PropertyAttribute::Accessor)) 3709 return true; 3710 3711 return false; 3712 } 3713 } 3714 3715 bool JSObject::needsSlowPutIndexing() const 3716 { 3717 return anyObjectInChainMayInterceptIndexedAccesses() || globalObject()->isHavingABadTime(); 3718 } 3719 3720 NonPropertyTransition JSObject::suggestedArrayStorageTransition() const 3721 { 3722 if (needsSlowPutIndexing()) 3723 return NonPropertyTransition::AllocateSlowPutArrayStorage; 3724 3725 return NonPropertyTransition::AllocateArrayStorage; 3726 } 3727 3672 3728 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.