aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-01-02 23:52:00 +0100
committerMike Pall <mike>2013-01-02 23:56:49 +0100
commit8b97dc738f97616875276eab38dcf225b03d1ec4 (patch)
treeeb0e68ea57a0ecfb35850c7ed58e7f81c868b6b4
parent9827650582ac07b3c269871ac17a1876f5352934 (diff)
downloadluajit-8b97dc738f97616875276eab38dcf225b03d1ec4.tar.gz
luajit-8b97dc738f97616875276eab38dcf225b03d1ec4.tar.bz2
luajit-8b97dc738f97616875276eab38dcf225b03d1ec4.zip
FFI: Fix code generation for bool call result check on x86/x64.
-rw-r--r--src/lj_asm_x86.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h
index 241da5a1..8cdbadb9 100644
--- a/src/lj_asm_x86.h
+++ b/src/lj_asm_x86.h
@@ -2158,12 +2158,27 @@ static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc)
2158 return; 2158 return;
2159 } /* Otherwise handle register case as usual. */ 2159 } /* Otherwise handle register case as usual. */
2160 } else { 2160 } else {
2161 left = asm_fuseloadm(as, lref, RSET_GPR, r64); 2161 left = asm_fuseloadm(as, lref,
2162 irt_isu8(ir->t) ? RSET_GPR8 : RSET_GPR, r64);
2162 } 2163 }
2163 asm_guardcc(as, cc); 2164 asm_guardcc(as, cc);
2164 if (usetest && left != RID_MRM) { 2165 if (usetest && left != RID_MRM) {
2165 /* Use test r,r instead of cmp r,0. */ 2166 /* Use test r,r instead of cmp r,0. */
2166 emit_rr(as, irt_isu8(ir->t) ? XO_TESTb : XO_TEST, r64 + left, left); 2167 x86Op xo = XO_TEST;
2168 if (irt_isu8(ir->t)) {
2169 lua_assert(ir->o == IR_EQ || ir->o == IR_NE);
2170 xo = XO_TESTb;
2171 if (!rset_test(RSET_RANGE(RID_EAX, RID_EBX+1), left)) {
2172 if (LJ_64) {
2173 left |= FORCE_REX;
2174 } else {
2175 emit_i32(as, 0xff);
2176 emit_mrm(as, XO_GROUP3, XOg_TEST, left);
2177 return;
2178 }
2179 }
2180 }
2181 emit_rr(as, xo, r64 + left, left);
2167 if (irl+1 == ir) /* Referencing previous ins? */ 2182 if (irl+1 == ir) /* Referencing previous ins? */
2168 as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */ 2183 as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */
2169 } else { 2184 } else {