#ifndef StructureChain_h
#define StructureChain_h
+#include "JSCell.h"
+#include "JSObject.h"
+#include "Structure.h"
+
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace JSC {
+ class LLIntOffsetsExtractor;
class Structure;
- class StructureChain : public RefCounted<StructureChain> {
+ class StructureChain : public JSCell {
+ friend class JIT;
+
public:
- static PassRefPtr<StructureChain> create(Structure* head) { return adoptRef(new StructureChain(head)); }
- RefPtr<Structure>* head() { return m_vector.get(); }
+ typedef JSCell Base;
- private:
- StructureChain(Structure* head);
+ static StructureChain* create(JSGlobalData& globalData, Structure* head)
+ {
+ StructureChain* chain = new (NotNull, allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get());
+ chain->finishCreation(globalData, head);
+ return chain;
+ }
+ WriteBarrier<Structure>* head() { return m_vector.get(); }
+ static void visitChildren(JSCell*, SlotVisitor&);
+
+ static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) { return Structure::create(globalData, globalObject, prototype, TypeInfo(CompoundType, OverridesVisitChildren), &s_info); }
+
+ static ClassInfo s_info;
- OwnArrayPtr<RefPtr<Structure> > m_vector;
+ protected:
+ void finishCreation(JSGlobalData& globalData, Structure* head)
+ {
+ Base::finishCreation(globalData);
+ size_t size = 0;
+ for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
+ ++size;
+
+ m_vector = adoptArrayPtr(new WriteBarrier<Structure>[size + 1]);
+
+ size_t i = 0;
+ for (Structure* current = head; current; current = current->storedPrototype().isNull() ? 0 : asObject(current->storedPrototype())->structure())
+ m_vector[i++].set(globalData, this, current);
+ }
+
+ private:
+ friend class LLIntOffsetsExtractor;
+
+ StructureChain(JSGlobalData&, Structure*);
+ static void destroy(JSCell*);
+ OwnArrayPtr<WriteBarrier<Structure> > m_vector;
};
} // namespace JSC