DFGMultiGetByOffsetData.h [plain text]
#pragma once
#if ENABLE(DFG_JIT)
#include "DFGRegisteredStructureSet.h"
#include "DumpContext.h"
#include "StructureSet.h"
namespace JSC { namespace DFG {
class FrozenValue;
class GetByOffsetMethod {
public:
enum Kind {
Invalid,
Constant,
Load,
LoadFromPrototype
};
GetByOffsetMethod()
: m_kind(Invalid)
{
}
static GetByOffsetMethod constant(FrozenValue* value)
{
GetByOffsetMethod result;
result.m_kind = Constant;
result.u.constant = value;
return result;
}
static GetByOffsetMethod load(PropertyOffset offset)
{
GetByOffsetMethod result;
result.m_kind = Load;
result.u.load.offset = offset;
return result;
}
static GetByOffsetMethod loadFromPrototype(FrozenValue* prototype, PropertyOffset offset)
{
GetByOffsetMethod result;
result.m_kind = LoadFromPrototype;
result.u.load.prototype = prototype;
result.u.load.offset = offset;
return result;
}
bool operator!() const { return m_kind == Invalid; }
Kind kind() const { return m_kind; }
FrozenValue* constant() const
{
ASSERT(kind() == Constant);
return u.constant;
}
FrozenValue* prototype() const
{
ASSERT(kind() == LoadFromPrototype);
return u.load.prototype;
}
PropertyOffset offset() const
{
ASSERT(kind() == Load || kind() == LoadFromPrototype);
return u.load.offset;
}
void dumpInContext(PrintStream&, DumpContext*) const;
void dump(PrintStream&) const;
private:
union {
FrozenValue* constant;
struct {
FrozenValue* prototype;
PropertyOffset offset;
} load;
} u;
Kind m_kind;
};
class MultiGetByOffsetCase {
public:
MultiGetByOffsetCase()
{
}
MultiGetByOffsetCase(const RegisteredStructureSet& set, const GetByOffsetMethod& method)
: m_set(set)
, m_method(method)
{
}
RegisteredStructureSet& set() { return m_set; }
const RegisteredStructureSet& set() const { return m_set; }
const GetByOffsetMethod& method() const { return m_method; }
void dumpInContext(PrintStream&, DumpContext*) const;
void dump(PrintStream&) const;
private:
RegisteredStructureSet m_set;
GetByOffsetMethod m_method;
};
struct MultiGetByOffsetData {
unsigned identifierNumber;
Vector<MultiGetByOffsetCase, 2> cases;
};
} }
namespace WTF {
void printInternal(PrintStream&, JSC::DFG::GetByOffsetMethod::Kind);
}
#endif // ENABLE(DFG_JIT)