// In future we may want to cache this transition. Structure* Structure::freezeTransition(VM& vm, Structure* structure) { Structure* transition = preventExtensionsTransition(vm, structure); if (transition->propertyTable()) { PropertyTable::iterator iter = transition->propertyTable()->begin(); PropertyTable::iterator end = transition->propertyTable()->end(); if (iter != end) transition->setHasReadOnlyOrGetterSetterPropertiesExcludingProto(true); for (; iter != end; ++iter) iter->attributes |= iter->attributes & Accessor ? DontDelete : (DontDelete | ReadOnly); } ASSERT(transition->hasReadOnlyOrGetterSetterPropertiesExcludingProto() || !transition->classInfo()->hasStaticSetterOrReadonlyProperties()); ASSERT(transition->hasGetterSetterProperties() || !transition->classInfo()->hasStaticSetterOrReadonlyProperties()); transition->checkOffsetConsistency(); return transition; }
Structure* Structure::nonPropertyTransition(VM& vm, Structure* structure, NonPropertyTransition transitionKind) { unsigned attributes = toAttributes(transitionKind); IndexingType indexingType = newIndexingType(structure->indexingTypeIncludingHistory(), transitionKind); if (changesIndexingType(transitionKind)) { if (JSGlobalObject* globalObject = structure->m_globalObject.get()) { if (globalObject->isOriginalArrayStructure(structure)) { Structure* result = globalObject->originalArrayStructureForIndexingType(indexingType); if (result->indexingTypeIncludingHistory() == indexingType) { structure->didTransitionFromThisStructure(); return result; } } } } Structure* existingTransition; if (!structure->isDictionary() && (existingTransition = structure->m_transitionTable.get(0, attributes))) { ASSERT(existingTransition->attributesInPrevious() == attributes); ASSERT(existingTransition->indexingTypeIncludingHistory() == indexingType); return existingTransition; } DeferGC deferGC(vm.heap); Structure* transition = create(vm, structure); transition->setAttributesInPrevious(attributes); transition->m_blob.setIndexingType(indexingType); if (preventsExtensions(transitionKind)) transition->setDidPreventExtensions(true); if (setsDontDeleteOnAllProperties(transitionKind) || setsReadOnlyOnNonAccessorProperties(transitionKind)) { // We pin the property table on transitions that do wholesale editing of the property // table, since our logic for walking the property transition chain to rematerialize the // table doesn't know how to take into account such wholesale edits. structure->materializePropertyMapIfNecessary(vm, deferGC); transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm)); transition->m_offset = structure->m_offset; transition->pinForCaching(); if (transition->propertyTable()) { for (auto& entry : *transition->propertyTable().get()) { if (setsDontDeleteOnAllProperties(transitionKind)) entry.attributes |= DontDelete; if (setsReadOnlyOnNonAccessorProperties(transitionKind) && !(entry.attributes & Accessor)) entry.attributes |= ReadOnly; } } } else { transition->propertyTable().set(vm, transition, structure->takePropertyTableOrCloneIfPinned(vm)); transition->m_offset = structure->m_offset; checkOffset(transition->m_offset, transition->inlineCapacity()); } if (setsReadOnlyOnNonAccessorProperties(transitionKind) && transition->propertyTable() && !transition->propertyTable()->isEmpty()) transition->setHasReadOnlyOrGetterSetterPropertiesExcludingProto(true); if (structure->isDictionary()) transition->pin(); else { ConcurrentJITLocker locker(structure->m_lock); structure->m_transitionTable.add(vm, transition); } transition->checkOffsetConsistency(); return transition; }