diff options
| author | Mike Pall <mike> | 2023-12-10 16:10:48 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2023-12-10 16:10:48 +0100 |
| commit | 10cc759f259e1f3b6572ce663858c8ce4d34a483 (patch) | |
| tree | 67a24c061a7d09d3dbab765d6187d3fd933957f7 /src | |
| parent | 1b38c736550004fba1b9712c1a5788b3eefa49be (diff) | |
| download | luajit-10cc759f259e1f3b6572ce663858c8ce4d34a483.tar.gz luajit-10cc759f259e1f3b6572ce663858c8ce4d34a483.tar.bz2 luajit-10cc759f259e1f3b6572ce663858c8ce4d34a483.zip | |
ARM: Fix stack restore for FP slots.
Thanks to Peter Cawley. #1131
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_asm_arm.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h index f53f708b..8869af32 100644 --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h | |||
| @@ -1991,11 +1991,12 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap) | |||
| 1991 | SnapEntry *map = &as->T->snapmap[snap->mapofs]; | 1991 | SnapEntry *map = &as->T->snapmap[snap->mapofs]; |
| 1992 | SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; | 1992 | SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; |
| 1993 | MSize n, nent = snap->nent; | 1993 | MSize n, nent = snap->nent; |
| 1994 | int32_t bias = 0; | ||
| 1994 | /* Store the value of all modified slots to the Lua stack. */ | 1995 | /* Store the value of all modified slots to the Lua stack. */ |
| 1995 | for (n = 0; n < nent; n++) { | 1996 | for (n = 0; n < nent; n++) { |
| 1996 | SnapEntry sn = map[n]; | 1997 | SnapEntry sn = map[n]; |
| 1997 | BCReg s = snap_slot(sn); | 1998 | BCReg s = snap_slot(sn); |
| 1998 | int32_t ofs = 8*((int32_t)s-1); | 1999 | int32_t ofs = 8*((int32_t)s-1) - bias; |
| 1999 | IRRef ref = snap_ref(sn); | 2000 | IRRef ref = snap_ref(sn); |
| 2000 | IRIns *ir = IR(ref); | 2001 | IRIns *ir = IR(ref); |
| 2001 | if ((sn & SNAP_NORESTORE)) | 2002 | if ((sn & SNAP_NORESTORE)) |
| @@ -2013,6 +2014,12 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap) | |||
| 2013 | emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); | 2014 | emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); |
| 2014 | #else | 2015 | #else |
| 2015 | Reg src = ra_alloc1(as, ref, RSET_FPR); | 2016 | Reg src = ra_alloc1(as, ref, RSET_FPR); |
| 2017 | if (LJ_UNLIKELY(ofs < -1020 || ofs > 1020)) { | ||
| 2018 | int32_t adj = ofs & 0xffffff00; /* K12-friendly. */ | ||
| 2019 | bias += adj; | ||
| 2020 | ofs -= adj; | ||
| 2021 | emit_addptr(as, RID_BASE, -adj); | ||
| 2022 | } | ||
| 2016 | emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); | 2023 | emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); |
| 2017 | #endif | 2024 | #endif |
| 2018 | } else { | 2025 | } else { |
| @@ -2038,6 +2045,7 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap) | |||
| 2038 | } | 2045 | } |
| 2039 | checkmclim(as); | 2046 | checkmclim(as); |
| 2040 | } | 2047 | } |
| 2048 | emit_addptr(as, RID_BASE, bias); | ||
| 2041 | lua_assert(map + nent == flinks); | 2049 | lua_assert(map + nent == flinks); |
| 2042 | } | 2050 | } |
| 2043 | 2051 | ||
