FFI: Fix recording of bool call result check on x86/x64.

This commit is contained in:
Mike Pall 2012-11-06 17:05:37 +01:00
parent 8a1a6097be
commit 4e5ef81b86
3 changed files with 9 additions and 2 deletions

View File

@ -1815,7 +1815,7 @@ static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa)
int32_t k = 0;
if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */
as->flagmcp = NULL;
as->mcp += (LJ_64 && *as->mcp != XI_TEST) ? 3 : 2;
as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2;
}
right = IR(rref)->r;
if (ra_hasreg(right)) {
@ -2151,7 +2151,7 @@ static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc)
asm_guardcc(as, cc);
if (usetest && left != RID_MRM) {
/* Use test r,r instead of cmp r,0. */
emit_rr(as, XO_TEST, r64 + left, left);
emit_rr(as, irt_isu8(ir->t) ? XO_TESTb : XO_TEST, r64 + left, left);
if (irl+1 == ir) /* Referencing previous ins? */
as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */
} else {

View File

@ -1140,7 +1140,12 @@ static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd)
tr = TREF_NIL;
} else {
crec_snap_caller(J);
#if LJ_TARGET_X86ORX64
/* Note: only the x86/x64 backend supports U8 and only for EQ(tr, 0). */
lj_ir_set(J, IRTG(IR_NE, IRT_U8), tr, lj_ir_kint(J, 0));
#else
lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0));
#endif
J->postproc = LJ_POST_FIXGUARDSNAP;
tr = TREF_TRUE;
}

View File

@ -205,6 +205,7 @@ typedef enum {
XI_ARITHi = 0x81,
XI_ARITHi8 = 0x83,
XI_PUSHi8 = 0x6a,
XI_TESTb = 0x84,
XI_TEST = 0x85,
XI_MOVmi = 0xc7,
XI_GROUP5 = 0xff,
@ -244,6 +245,7 @@ typedef enum {
XO_IMULi = XO_(69),
XO_IMULi8 = XO_(6b),
XO_CMP = XO_(3b),
XO_TESTb = XO_(84),
XO_TEST = XO_(85),
XO_GROUP3b = XO_(f6),
XO_GROUP3 = XO_(f7),