void Structure::materializePropertyMap(JSGlobalData& globalData) { ASSERT(structure()->classInfo() == &s_info); ASSERT(!m_propertyTable); Vector<Structure*, 8> structures; structures.append(this); Structure* structure = this; // Search for the last Structure with a property table. while ((structure = structure->previousID())) { if (structure->m_isPinnedPropertyTable) { ASSERT(structure->m_propertyTable); ASSERT(!structure->m_previous); m_propertyTable = structure->m_propertyTable->copy(globalData, 0, numberOfSlotsForLastOffset(m_offset, m_typeInfo.type())); break; } structures.append(structure); } if (!m_propertyTable) createPropertyMap(numberOfSlotsForLastOffset(m_offset, m_typeInfo.type())); for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) { structure = structures[i]; if (!structure->m_nameInPrevious) continue; PropertyMapEntry entry(globalData, this, structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious.get()); m_propertyTable->add(entry); } }
size_t Structure::putSpecificValue(JSGlobalData& globalData, const Identifier& propertyName, unsigned attributes, JSCell* specificValue) { ASSERT(!propertyName.isNull()); ASSERT(get(globalData, propertyName) == notFound); checkConsistency(); if (attributes & DontEnum) m_hasNonEnumerableProperties = true; StringImpl* rep = propertyName.impl(); if (!m_propertyTable) createPropertyMap(); unsigned newOffset; if (m_propertyTable->hasDeletedOffset()) newOffset = m_propertyTable->getDeletedOffset(); else newOffset = m_propertyTable->size(); m_propertyTable->add(PropertyMapEntry(globalData, this, rep, newOffset, attributes, specificValue)); checkConsistency(); return newOffset; }
PropertyOffset Structure::putSpecificValue(JSGlobalData& globalData, PropertyName propertyName, unsigned attributes, JSCell* specificValue) { ASSERT(!JSC::isValidOffset(get(globalData, propertyName))); checkConsistency(); if (attributes & DontEnum) m_hasNonEnumerableProperties = true; StringImpl* rep = propertyName.uid(); if (!m_propertyTable) createPropertyMap(); PropertyOffset newOffset = m_propertyTable->nextOffset(m_inlineCapacity); m_propertyTable->add(PropertyMapEntry(globalData, this, rep, newOffset, attributes, specificValue)); checkConsistency(); return newOffset; }
void Structure::materializePropertyMap(JSGlobalData& globalData) { ASSERT(structure()->classInfo() == &s_info); ASSERT(!propertyTable()); Vector<Structure*, 8> structures; structures.append(this); Structure* structure = this; // Search for the last Structure with a property table. while ((structure = structure->previousID())) { if (structure->m_isPinnedPropertyTable) { ASSERT(structure->propertyTable()); ASSERT(!structure->previousID()); propertyTable().set(globalData, this, structure->propertyTable()->copy(globalData, 0, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity))); break; } structures.append(structure); } if (!propertyTable()) createPropertyMap(globalData, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity)); for (ptrdiff_t i = structures.size() - 1; i >= 0; --i) { structure = structures[i]; if (!structure->m_nameInPrevious) continue; PropertyMapEntry entry(globalData, this, structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious.get()); propertyTable()->add(entry, m_offset, PropertyTable::PropertyOffsetMustNotChange); } checkOffsetConsistency(); }