DFGVariableEvent.h [plain text]
#ifndef DFGVariableEvent_h
#define DFGVariableEvent_h
#include <wtf/Platform.h>
#if ENABLE(DFG_JIT)
#include "DFGCommon.h"
#include "DFGMinifiedID.h"
#include "DataFormat.h"
#include "MacroAssembler.h"
#include <stdio.h>
namespace JSC { namespace DFG {
enum VariableEventKind {
Reset,
BirthToFill,
BirthToSpill,
Fill,
Spill,
Death,
MovHintEvent,
SetLocalEvent,
InvalidEventKind
};
union VariableRepresentation {
MacroAssembler::RegisterID gpr;
MacroAssembler::FPRegisterID fpr;
#if USE(JSVALUE32_64)
struct {
MacroAssembler::RegisterID tagGPR;
MacroAssembler::RegisterID payloadGPR;
} pair;
#endif
int32_t virtualReg;
};
class VariableEvent {
public:
VariableEvent()
: m_kind(InvalidEventKind)
{
}
static VariableEvent reset()
{
VariableEvent event;
event.m_kind = Reset;
return event;
}
static VariableEvent fillGPR(VariableEventKind kind, MinifiedID id, MacroAssembler::RegisterID gpr, DataFormat dataFormat)
{
ASSERT(kind == BirthToFill || kind == Fill);
ASSERT(dataFormat != DataFormatDouble);
#if USE(JSVALUE32_64)
ASSERT(!(dataFormat & DataFormatJS));
#endif
VariableEvent event;
event.m_id = id;
event.u.gpr = gpr;
event.m_kind = kind;
event.m_dataFormat = dataFormat;
return event;
}
#if USE(JSVALUE32_64)
static VariableEvent fillPair(VariableEventKind kind, MinifiedID id, MacroAssembler::RegisterID tagGPR, MacroAssembler::RegisterID payloadGPR)
{
ASSERT(kind == BirthToFill || kind == Fill);
VariableEvent event;
event.m_id = id;
event.u.pair.tagGPR = tagGPR;
event.u.pair.payloadGPR = payloadGPR;
event.m_kind = kind;
event.m_dataFormat = DataFormatJS;
return event;
}
#endif // USE(JSVALUE32_64)
static VariableEvent fillFPR(VariableEventKind kind, MinifiedID id, MacroAssembler::FPRegisterID fpr)
{
ASSERT(kind == BirthToFill || kind == Fill);
VariableEvent event;
event.m_id = id;
event.u.fpr = fpr;
event.m_kind = kind;
event.m_dataFormat = DataFormatDouble;
return event;
}
static VariableEvent spill(VariableEventKind kind, MinifiedID id, VirtualRegister virtualRegister, DataFormat format)
{
ASSERT(kind == BirthToSpill || kind == Spill);
VariableEvent event;
event.m_id = id;
event.u.virtualReg = virtualRegister;
event.m_kind = kind;
event.m_dataFormat = format;
return event;
}
static VariableEvent death(MinifiedID id)
{
VariableEvent event;
event.m_id = id;
event.m_kind = Death;
return event;
}
static VariableEvent setLocal(int operand, DataFormat format)
{
VariableEvent event;
event.u.virtualReg = operand;
event.m_kind = SetLocalEvent;
event.m_dataFormat = format;
return event;
}
static VariableEvent movHint(MinifiedID id, int operand)
{
VariableEvent event;
event.m_id = id;
event.u.virtualReg = operand;
event.m_kind = MovHintEvent;
return event;
}
VariableEventKind kind() const
{
return static_cast<VariableEventKind>(m_kind);
}
MinifiedID id() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill
|| m_kind == BirthToSpill || m_kind == Spill
|| m_kind == Death || m_kind == MovHintEvent);
return m_id;
}
DataFormat dataFormat() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill
|| m_kind == BirthToSpill || m_kind == Spill
|| m_kind == SetLocalEvent);
return static_cast<DataFormat>(m_dataFormat);
}
MacroAssembler::RegisterID gpr() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill);
ASSERT(m_dataFormat);
ASSERT(m_dataFormat != DataFormatDouble);
#if USE(JSVALUE32_64)
ASSERT(!(m_dataFormat & DataFormatJS));
#endif
return u.gpr;
}
#if USE(JSVALUE32_64)
MacroAssembler::RegisterID tagGPR() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill);
ASSERT(m_dataFormat & DataFormatJS);
return u.pair.tagGPR;
}
MacroAssembler::RegisterID payloadGPR() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill);
ASSERT(m_dataFormat & DataFormatJS);
return u.pair.payloadGPR;
}
#endif // USE(JSVALUE32_64)
MacroAssembler::FPRegisterID fpr() const
{
ASSERT(m_kind == BirthToFill || m_kind == Fill);
ASSERT(m_dataFormat == DataFormatDouble);
return u.fpr;
}
VirtualRegister virtualRegister() const
{
ASSERT(m_kind == BirthToSpill || m_kind == Spill);
return static_cast<VirtualRegister>(u.virtualReg);
}
int operand() const
{
ASSERT(m_kind == SetLocalEvent || m_kind == MovHintEvent);
return u.virtualReg;
}
const VariableRepresentation& variableRepresentation() const { return u; }
void dump(PrintStream&) const;
private:
void dumpFillInfo(const char* name, PrintStream&) const;
void dumpSpillInfo(const char* name, PrintStream&) const;
MinifiedID m_id;
VariableRepresentation u;
int8_t m_kind;
int8_t m_dataFormat;
};
} }
#endif // ENABLE(DFG_JIT)
#endif // DFGVariableEvent_h