Replacing a use of strings for xbyak labels.

This commit is contained in:
Ben Vanik 2015-07-29 18:58:45 -07:00
parent 40e98eab7c
commit 19901c4759
3 changed files with 17 additions and 9 deletions

View File

@ -146,6 +146,9 @@ void* X64Emitter::Emplace(size_t stack_size, FunctionInfo* function_info) {
}
bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
Xbyak::Label epilog_label;
epilog_label_ = &epilog_label;
// Calculate stack size. We need to align things to their natural sizes.
// This could be much better (sort by type/etc).
auto locals = builder->locals();
@ -240,7 +243,8 @@ bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
}
// Function epilog.
L("epilog");
L(epilog_label);
epilog_label_ = nullptr;
EmitTraceUserCallReturn();
mov(rcx, qword[rsp + StackLayout::GUEST_RCX_HOME]);
add(rsp, (uint32_t)stack_size);
@ -397,7 +401,7 @@ void X64Emitter::CallIndirect(const hir::Instr* instr, const Reg64& reg) {
// Check if return.
if (instr->flags & CALL_POSSIBLE_RETURN) {
cmp(reg.cvt32(), dword[rsp + StackLayout::GUEST_RET_ADDR]);
je("epilog", CodeGenerator::T_NEAR);
je(epilog_label(), CodeGenerator::T_NEAR);
}
// Load the pointer to the indirection table maintained in X64CodeCache.

View File

@ -151,6 +151,8 @@ class X64Emitter : public Xbyak::CodeGenerator {
r = Xbyak::Xmm(idx);
}
Xbyak::Label& epilog_label() { return *epilog_label_; }
void MarkSourceOffset(const hir::Instr* i);
void DebugBreak();
@ -206,6 +208,8 @@ class X64Emitter : public Xbyak::CodeGenerator {
Xbyak::util::Cpu cpu_;
uint32_t feature_flags_;
Xbyak::Label* epilog_label_ = nullptr;
hir::Instr* current_instr_;
DebugInfo* debug_info_;

View File

@ -1032,7 +1032,7 @@ struct RETURN : Sequence<RETURN, I<OPCODE_RETURN, VoidOp>> {
// If this is the last instruction in the last block, just let us
// fall through.
if (i.instr->next || i.instr->block->next) {
e.jmp("epilog", CodeGenerator::T_NEAR);
e.jmp(e.epilog_label(), CodeGenerator::T_NEAR);
}
}
};
@ -1045,42 +1045,42 @@ struct RETURN_TRUE_I8
: Sequence<RETURN_TRUE_I8, I<OPCODE_RETURN_TRUE, VoidOp, I8Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.test(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
struct RETURN_TRUE_I16
: Sequence<RETURN_TRUE_I16, I<OPCODE_RETURN_TRUE, VoidOp, I16Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.test(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
struct RETURN_TRUE_I32
: Sequence<RETURN_TRUE_I32, I<OPCODE_RETURN_TRUE, VoidOp, I32Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.test(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
struct RETURN_TRUE_I64
: Sequence<RETURN_TRUE_I64, I<OPCODE_RETURN_TRUE, VoidOp, I64Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.test(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
struct RETURN_TRUE_F32
: Sequence<RETURN_TRUE_F32, I<OPCODE_RETURN_TRUE, VoidOp, F32Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.vptest(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
struct RETURN_TRUE_F64
: Sequence<RETURN_TRUE_F64, I<OPCODE_RETURN_TRUE, VoidOp, F64Op>> {
static void Emit(X64Emitter& e, const EmitArgType& i) {
e.vptest(i.src1, i.src1);
e.jnz("epilog", CodeGenerator::T_NEAR);
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
}
};
EMITTER_OPCODE_TABLE(OPCODE_RETURN_TRUE, RETURN_TRUE_I8, RETURN_TRUE_I16,