+PassRefPtr<StructureShape> Structure::toStructureShape(JSValue value)
+{
+ RefPtr<StructureShape> baseShape = StructureShape::create();
+ RefPtr<StructureShape> curShape = baseShape;
+ Structure* curStructure = this;
+ JSValue curValue = value;
+ while (curStructure) {
+ Vector<Structure*, 8> structures;
+ Structure* structure;
+ PropertyTable* table;
+
+ curStructure->findStructuresAndMapForMaterialization(structures, structure, table);
+ if (table) {
+ PropertyTable::iterator iter = table->begin();
+ PropertyTable::iterator end = table->end();
+ for (; iter != end; ++iter)
+ curShape->addProperty(*iter->key);
+
+ structure->m_lock.unlock();
+ }
+ for (unsigned i = structures.size(); i--;) {
+ Structure* structure = structures[i];
+ if (structure->m_nameInPrevious)
+ curShape->addProperty(*structure->m_nameInPrevious);
+ }
+
+ if (JSObject* curObject = curValue.getObject())
+ curShape->setConstructorName(JSObject::calculatedClassName(curObject));
+ else
+ curShape->setConstructorName(curStructure->classInfo()->className);
+
+ if (curStructure->isDictionary())
+ curShape->enterDictionaryMode();
+
+ curShape->markAsFinal();
+
+ if (curStructure->storedPrototypeStructure()) {
+ RefPtr<StructureShape> newShape = StructureShape::create();
+ curShape->setProto(newShape);
+ curShape = newShape.release();
+ curValue = curStructure->storedPrototype();
+ }
+
+ curStructure = curStructure->storedPrototypeStructure();
+ }
+
+ return baseShape.release();
+}
+
+bool Structure::canUseForAllocationsOf(Structure* other)
+{
+ return inlineCapacity() == other->inlineCapacity()
+ && storedPrototype() == other->storedPrototype()
+ && objectInitializationBlob() == other->objectInitializationBlob();
+}
+
+void Structure::dump(PrintStream& out) const
+{
+ out.print(RawPointer(this), ":[", classInfo()->className, ", {");
+
+ CommaPrinter comma;
+
+ const_cast<Structure*>(this)->forEachPropertyConcurrently(
+ [&] (const PropertyMapEntry& entry) -> bool {
+ out.print(comma, entry.key, ":", static_cast<int>(entry.offset));
+ return true;
+ });
+
+ out.print("}, ", IndexingTypeDump(indexingType()));
+
+ if (m_prototype.get().isCell())
+ out.print(", Proto:", RawPointer(m_prototype.get().asCell()));
+
+ out.print("]");
+}
+
+void Structure::dumpInContext(PrintStream& out, DumpContext* context) const
+{
+ if (context)
+ context->structures.dumpBrief(this, out);
+ else
+ dump(out);
+}
+
+void Structure::dumpBrief(PrintStream& out, const CString& string) const
+{
+ out.print("%", string, ":", classInfo()->className);
+}
+
+void Structure::dumpContextHeader(PrintStream& out)
+{
+ out.print("Structures:");
+}
+