X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..12899fa232562c774004a3a9d7d3149944dec712:/runtime/StructureChain.cpp diff --git a/runtime/StructureChain.cpp b/runtime/StructureChain.cpp index 085876c..85abcd3 100644 --- a/runtime/StructureChain.cpp +++ b/runtime/StructureChain.cpp @@ -27,23 +27,32 @@ #include "StructureChain.h" #include "JSObject.h" +#include "Operations.h" #include "Structure.h" #include namespace JSC { + +ClassInfo StructureChain::s_info = { "StructureChain", 0, 0, 0, CREATE_METHOD_TABLE(StructureChain) }; -StructureChain::StructureChain(Structure* head) +StructureChain::StructureChain(VM& vm, Structure* structure) + : JSCell(vm, structure) { - size_t size = 0; - for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure()) - ++size; - - m_vector.set(new RefPtr[size + 1]); +} +void StructureChain::destroy(JSCell* cell) +{ + static_cast(cell)->StructureChain::~StructureChain(); +} + +void StructureChain::visitChildren(JSCell* cell, SlotVisitor& visitor) +{ + StructureChain* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); size_t i = 0; - for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure()) - m_vector[i++] = current; - m_vector[i] = 0; + while (thisObject->m_vector[i]) + visitor.append(&thisObject->m_vector[i++]); } } // namespace JSC