ARM: Add LJ_SOFTFP define. Add support for soft-float slot handling.

master
Mike Pall 2011-05-16 02:38:07 +02:00
parent be73a96751
commit 1ac71f1fa8
5 changed files with 30 additions and 12 deletions

View File

@ -320,6 +320,10 @@ local function printsnap(tr, snap)
else
local m, ot, op1, op2 = traceir(tr, ref)
out:write(colorize(format("%04d", ref), band(ot, 31)))
if band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM
local m, ot, op1, op2 = traceir(tr, ref+1)
out:write(colorize(format("/%04d", ref+1), band(ot, 31)))
end
end
out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME
else

View File

@ -232,6 +232,8 @@
#define LJ_HASFFI 1
#endif
#define LJ_SOFTFP (!LJ_ARCH_HASFPU)
#if LJ_ARCH_ENDIAN == LUAJIT_BE
#define LJ_LE 0
#define LJ_BE 1

View File

@ -143,6 +143,7 @@ typedef uint32_t SnapEntry;
#define SNAP_FRAME 0x010000 /* Frame slot. */
#define SNAP_CONT 0x020000 /* Continuation slot. */
#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */
#define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */
LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME);
LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT);

View File

@ -786,18 +786,18 @@ static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2)
/* -- Number to integer conversion ---------------------------------------- */
#if !LJ_ARCH_HASFPU
#if LJ_SOFTFP
LJ_ASMF int32_t lj_vm_tobit(double x);
#endif
static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
{
#if LJ_ARCH_HASFPU
#if LJ_SOFTFP
return lj_vm_tobit(n);
#else
TValue o;
o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */
return (int32_t)o.u32.lo;
#else
return lj_vm_tobit(n);
#endif
}

View File

@ -72,6 +72,8 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
(ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT)
sn |= SNAP_NORESTORE;
}
if (LJ_SOFTFP && !irref_isk(ref) && irt_isnum(ir->t))
sn |= SNAP_SOFTFPNUM;
map[n++] = sn;
}
}
@ -386,9 +388,11 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
rs = snap_renameref(T, snapno, ref, rs);
if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */
int32_t *sps = &ex->spill[regsp_spill(rs)];
if (irt_isinteger(t)) {
if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
o->u32.lo = (uint32_t)*sps;
} else if (irt_isinteger(t)) {
setintV(o, *sps);
} else if (irt_isnum(t)) {
} else if (!LJ_SOFTFP && irt_isnum(t)) {
o->u64 = *(uint64_t *)sps;
#if LJ_64
} else if (irt_islightud(t)) {
@ -403,13 +407,12 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
} else { /* Restore from register. */
Reg r = regsp_reg(rs);
lua_assert(ra_hasreg(r));
if (irt_isinteger(t)) {
if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
o->u32.lo = (uint32_t)ex->gpr[r-RID_MIN_GPR];
} else if (irt_isinteger(t)) {
setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]);
} else if (irt_isnum(t)) {
if (RID_NUM_FPR)
setnumV(o, ex->fpr[r-RID_MIN_FPR]);
else
setnumV(o, *(double *)&ex->gpr[r-RID_MIN_GPR]);
} else if (!LJ_SOFTFP && irt_isnum(t)) {
setnumV(o, ex->fpr[r-RID_MIN_FPR]);
#if LJ_64
} else if (irt_islightud(t)) {
/* 64 bit lightuserdata which may escape already has the tag bits. */
@ -421,6 +424,14 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
setitype(o, irt_toitype(t));
}
}
if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
rs = (ir+1)->prev;
if (LJ_UNLIKELY(bloomtest(rfilt, ref+1)))
rs = snap_renameref(T, snapno, ref+1, rs);
o->u32.hi = (ra_hasspill(regsp_spill(rs))) ?
(uint32_t)*&ex->spill[regsp_spill(rs)] :
(uint32_t)ex->gpr[regsp_reg(rs)-RID_MIN_GPR];
}
}
}
switch (bc_op(*pc)) {