aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm_x86.h
diff options
context:
space:
mode:
authorMike Pall <mike>2013-05-24 00:45:44 +0200
committerMike Pall <mike>2013-05-24 00:49:02 +0200
commitf1f7e403182c891a356ce8813417820af19a778b (patch)
treee992da894d0e7fb21cffb2948ad04ffc38cd158c /src/lj_asm_x86.h
parentb3369f3c95a11a8c451b244a2da69f1c3aee31c4 (diff)
downloadluajit-f1f7e403182c891a356ce8813417820af19a778b.tar.gz
luajit-f1f7e403182c891a356ce8813417820af19a778b.tar.bz2
luajit-f1f7e403182c891a356ce8813417820af19a778b.zip
FFI: Compile VLA/VLS and large cdata allocs with default initialization.
Diffstat (limited to 'src/lj_asm_x86.h')
-rw-r--r--src/lj_asm_x86.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h
index 25da5246..f2f8157d 100644
--- a/src/lj_asm_x86.h
+++ b/src/lj_asm_x86.h
@@ -1438,15 +1438,13 @@ static void asm_sload(ASMState *as, IRIns *ir)
1438static void asm_cnew(ASMState *as, IRIns *ir) 1438static void asm_cnew(ASMState *as, IRIns *ir)
1439{ 1439{
1440 CTState *cts = ctype_ctsG(J2G(as->J)); 1440 CTState *cts = ctype_ctsG(J2G(as->J));
1441 CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; 1441 CTypeID id = (CTypeID)IR(ir->op1)->i;
1442 CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? 1442 CTSize sz;
1443 lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; 1443 CTInfo info = lj_ctype_info(cts, id, &sz);
1444 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; 1444 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco];
1445 IRRef args[2]; 1445 IRRef args[4];
1446 lua_assert(sz != CTSIZE_INVALID); 1446 lua_assert(sz != CTSIZE_INVALID || (ir->o == IR_CNEW && ir->op2 != REF_NIL));
1447 1447
1448 args[0] = ASMREF_L; /* lua_State *L */
1449 args[1] = ASMREF_TMP1; /* MSize size */
1450 as->gcsteps++; 1448 as->gcsteps++;
1451 asm_setupresult(as, ir, ci); /* GCcdata * */ 1449 asm_setupresult(as, ir, ci); /* GCcdata * */
1452 1450
@@ -1489,15 +1487,26 @@ static void asm_cnew(ASMState *as, IRIns *ir)
1489 } while (1); 1487 } while (1);
1490#endif 1488#endif
1491 lua_assert(sz == 4 || sz == 8); 1489 lua_assert(sz == 4 || sz == 8);
1490 } else if (ir->op2 != REF_NIL) { /* Create VLA/VLS/aligned cdata. */
1491 ci = &lj_ir_callinfo[IRCALL_lj_cdata_newv];
1492 args[0] = ASMREF_L; /* lua_State *L */
1493 args[1] = ir->op1; /* CTypeID id */
1494 args[2] = ir->op2; /* CTSize sz */
1495 args[3] = ASMREF_TMP1; /* CTSize align */
1496 asm_gencall(as, ci, args);
1497 emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)ctype_align(info));
1498 return;
1492 } 1499 }
1493 1500
1494 /* Combine initialization of marked, gct and ctypeid. */ 1501 /* Combine initialization of marked, gct and ctypeid. */
1495 emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked)); 1502 emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked));
1496 emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX, 1503 emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX,
1497 (int32_t)((~LJ_TCDATA<<8)+(ctypeid<<16))); 1504 (int32_t)((~LJ_TCDATA<<8)+(id<<16)));
1498 emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES); 1505 emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES);
1499 emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite); 1506 emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite);
1500 1507
1508 args[0] = ASMREF_L; /* lua_State *L */
1509 args[1] = ASMREF_TMP1; /* MSize size */
1501 asm_gencall(as, ci, args); 1510 asm_gencall(as, ci, args);
1502 emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata))); 1511 emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata)));
1503} 1512}