]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/StructureChain.cpp
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / runtime / StructureChain.cpp
index e83f626ab1b134be7e397dcf73092d03ce573273..afb2d95018867f9db7f441f28c893b10e2a601c2 100644 (file)
 #include <wtf/RefPtr.h>
 
 namespace JSC {
+    
+ClassInfo StructureChain::s_info = { "StructureChain", 0, 0, 0, CREATE_METHOD_TABLE(StructureChain) };
 
-StructureChain::StructureChain(Structure* head)
+StructureChain::StructureChain(JSGlobalData& globalData, Structure* structure)
+    : JSCell(globalData, 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<Structure>[size + 1]);
+}
 
-    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;
+void StructureChain::destroy(JSCell* cell)
+{
+    jsCast<StructureChain*>(cell)->StructureChain::~StructureChain();
 }
 
-bool StructureChain::isCacheable() const
+void StructureChain::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
-    uint32_t i = 0;
-    
-    while (m_vector[i]) {
-        // Both classes of dictionary structure may change arbitrarily so we can't cache them
-        if (m_vector[i++]->isDictionary())
-            return false;
-    }
-    return true;
+    StructureChain* thisObject = jsCast<StructureChain*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
+    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
+    size_t i = 0;
+    while (thisObject->m_vector[i])
+        visitor.append(&thisObject->m_vector[i++]);
 }
 
 } // namespace JSC