aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/dump.lua4
-rw-r--r--src/lj_arch.h2
-rw-r--r--src/lj_jit.h1
-rw-r--r--src/lj_obj.h8
-rw-r--r--src/lj_snap.c27
5 files changed, 30 insertions, 12 deletions
diff --git a/lib/dump.lua b/lib/dump.lua
index 652761ff..0f9f7b2b 100644
--- a/lib/dump.lua
+++ b/lib/dump.lua
@@ -320,6 +320,10 @@ local function printsnap(tr, snap)
320 else 320 else
321 local m, ot, op1, op2 = traceir(tr, ref) 321 local m, ot, op1, op2 = traceir(tr, ref)
322 out:write(colorize(format("%04d", ref), band(ot, 31))) 322 out:write(colorize(format("%04d", ref), band(ot, 31)))
323 if band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM
324 local m, ot, op1, op2 = traceir(tr, ref+1)
325 out:write(colorize(format("/%04d", ref+1), band(ot, 31)))
326 end
323 end 327 end
324 out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME 328 out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME
325 else 329 else
diff --git a/src/lj_arch.h b/src/lj_arch.h
index b361e3dc..3c6d9e9c 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -232,6 +232,8 @@
232#define LJ_HASFFI 1 232#define LJ_HASFFI 1
233#endif 233#endif
234 234
235#define LJ_SOFTFP (!LJ_ARCH_HASFPU)
236
235#if LJ_ARCH_ENDIAN == LUAJIT_BE 237#if LJ_ARCH_ENDIAN == LUAJIT_BE
236#define LJ_LE 0 238#define LJ_LE 0
237#define LJ_BE 1 239#define LJ_BE 1
diff --git a/src/lj_jit.h b/src/lj_jit.h
index 22f1d581..1cf63448 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -143,6 +143,7 @@ typedef uint32_t SnapEntry;
143#define SNAP_FRAME 0x010000 /* Frame slot. */ 143#define SNAP_FRAME 0x010000 /* Frame slot. */
144#define SNAP_CONT 0x020000 /* Continuation slot. */ 144#define SNAP_CONT 0x020000 /* Continuation slot. */
145#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ 145#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */
146#define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */
146LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); 147LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME);
147LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); 148LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT);
148 149
diff --git a/src/lj_obj.h b/src/lj_obj.h
index c1bdb844..6d6782b4 100644
--- a/src/lj_obj.h
+++ b/src/lj_obj.h
@@ -786,18 +786,18 @@ static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2)
786 786
787/* -- Number to integer conversion ---------------------------------------- */ 787/* -- Number to integer conversion ---------------------------------------- */
788 788
789#if !LJ_ARCH_HASFPU 789#if LJ_SOFTFP
790LJ_ASMF int32_t lj_vm_tobit(double x); 790LJ_ASMF int32_t lj_vm_tobit(double x);
791#endif 791#endif
792 792
793static LJ_AINLINE int32_t lj_num2bit(lua_Number n) 793static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
794{ 794{
795#if LJ_ARCH_HASFPU 795#if LJ_SOFTFP
796 return lj_vm_tobit(n);
797#else
796 TValue o; 798 TValue o;
797 o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */ 799 o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */
798 return (int32_t)o.u32.lo; 800 return (int32_t)o.u32.lo;
799#else
800 return lj_vm_tobit(n);
801#endif 801#endif
802} 802}
803 803
diff --git a/src/lj_snap.c b/src/lj_snap.c
index a3c081e1..e1791b51 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -72,6 +72,8 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
72 (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) 72 (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT)
73 sn |= SNAP_NORESTORE; 73 sn |= SNAP_NORESTORE;
74 } 74 }
75 if (LJ_SOFTFP && !irref_isk(ref) && irt_isnum(ir->t))
76 sn |= SNAP_SOFTFPNUM;
75 map[n++] = sn; 77 map[n++] = sn;
76 } 78 }
77 } 79 }
@@ -386,9 +388,11 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
386 rs = snap_renameref(T, snapno, ref, rs); 388 rs = snap_renameref(T, snapno, ref, rs);
387 if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */ 389 if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */
388 int32_t *sps = &ex->spill[regsp_spill(rs)]; 390 int32_t *sps = &ex->spill[regsp_spill(rs)];
389 if (irt_isinteger(t)) { 391 if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
392 o->u32.lo = (uint32_t)*sps;
393 } else if (irt_isinteger(t)) {
390 setintV(o, *sps); 394 setintV(o, *sps);
391 } else if (irt_isnum(t)) { 395 } else if (!LJ_SOFTFP && irt_isnum(t)) {
392 o->u64 = *(uint64_t *)sps; 396 o->u64 = *(uint64_t *)sps;
393#if LJ_64 397#if LJ_64
394 } else if (irt_islightud(t)) { 398 } else if (irt_islightud(t)) {
@@ -403,13 +407,12 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
403 } else { /* Restore from register. */ 407 } else { /* Restore from register. */
404 Reg r = regsp_reg(rs); 408 Reg r = regsp_reg(rs);
405 lua_assert(ra_hasreg(r)); 409 lua_assert(ra_hasreg(r));
406 if (irt_isinteger(t)) { 410 if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
411 o->u32.lo = (uint32_t)ex->gpr[r-RID_MIN_GPR];
412 } else if (irt_isinteger(t)) {
407 setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]); 413 setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]);
408 } else if (irt_isnum(t)) { 414 } else if (!LJ_SOFTFP && irt_isnum(t)) {
409 if (RID_NUM_FPR) 415 setnumV(o, ex->fpr[r-RID_MIN_FPR]);
410 setnumV(o, ex->fpr[r-RID_MIN_FPR]);
411 else
412 setnumV(o, *(double *)&ex->gpr[r-RID_MIN_GPR]);
413#if LJ_64 416#if LJ_64
414 } else if (irt_islightud(t)) { 417 } else if (irt_islightud(t)) {
415 /* 64 bit lightuserdata which may escape already has the tag bits. */ 418 /* 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)
421 setitype(o, irt_toitype(t)); 424 setitype(o, irt_toitype(t));
422 } 425 }
423 } 426 }
427 if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) {
428 rs = (ir+1)->prev;
429 if (LJ_UNLIKELY(bloomtest(rfilt, ref+1)))
430 rs = snap_renameref(T, snapno, ref+1, rs);
431 o->u32.hi = (ra_hasspill(regsp_spill(rs))) ?
432 (uint32_t)*&ex->spill[regsp_spill(rs)] :
433 (uint32_t)ex->gpr[regsp_reg(rs)-RID_MIN_GPR];
434 }
424 } 435 }
425 } 436 }
426 switch (bc_op(*pc)) { 437 switch (bc_op(*pc)) {