PolymorphicGetByIdList.h [plain text]
#ifndef PolymorphicGetByIdList_h
#define PolymorphicGetByIdList_h
#if ENABLE(JIT)
#include "CodeOrigin.h"
#include "MacroAssembler.h"
#include "Opcode.h"
#include "Structure.h"
#include <wtf/Vector.h>
namespace JSC {
class CodeBlock;
struct StructureStubInfo;
class GetByIdAccess {
public:
enum AccessType {
Invalid,
SimpleInline, SimpleStub, WatchedStub,
Getter,
CustomGetter,
SimpleMiss,
};
GetByIdAccess()
: m_type(Invalid)
, m_chainCount(0)
{
}
GetByIdAccess(
VM&, JSCell* owner, AccessType, PassRefPtr<JITStubRoutine>, Structure*,
StructureChain* = 0, unsigned chainCount = 0);
~GetByIdAccess();
static GetByIdAccess fromStructureStubInfo(StructureStubInfo&);
bool isSet() const { return m_type != Invalid; }
bool operator!() const { return !isSet(); }
AccessType type() const { return m_type; }
Structure* structure() const { return m_structure.get(); }
StructureChain* chain() const { return m_chain.get(); }
unsigned chainCount() const { return m_chainCount; }
JITStubRoutine* stubRoutine() const
{
ASSERT(isSet());
return m_stubRoutine.get();
}
bool doesCalls() const { return type() == Getter || type() == CustomGetter; }
bool isWatched() const { return type() == WatchedStub; }
bool isSimple() const { return !doesCalls() && !isWatched(); }
bool visitWeak(RepatchBuffer&) const;
private:
friend class CodeBlock;
AccessType m_type;
unsigned m_chainCount;
WriteBarrier<Structure> m_structure;
WriteBarrier<StructureChain> m_chain;
RefPtr<JITStubRoutine> m_stubRoutine;
};
class PolymorphicGetByIdList {
WTF_MAKE_FAST_ALLOCATED;
public:
static PolymorphicGetByIdList* from(StructureStubInfo&);
~PolymorphicGetByIdList();
MacroAssemblerCodePtr currentSlowPathTarget(StructureStubInfo& stubInfo) const;
void addAccess(const GetByIdAccess&);
bool isEmpty() const { return m_list.isEmpty(); }
unsigned size() const { return m_list.size(); }
bool isFull() const;
bool isAlmostFull() const; const GetByIdAccess& at(unsigned i) const { return m_list[i]; }
const GetByIdAccess& operator[](unsigned i) const { return m_list[i]; }
bool didSelfPatching() const;
bool visitWeak(RepatchBuffer&) const;
private:
friend class CodeBlock;
PolymorphicGetByIdList(StructureStubInfo&);
Vector<GetByIdAccess, 2> m_list;
};
}
#endif // ENABLE(JIT)
#endif // PolymorphicGetByIdList_h