aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Baylis <charles.baylis@linaro.org>2016-06-07 16:14:33 +0100
committerCharles Baylis <charles.baylis@linaro.org>2016-06-07 16:14:33 +0100
commit909f5fd43a1fab4c08405a8e7250631f2c4d912a (patch)
tree865b15cb25ca7db2328135de2110a18553470c12
parent0b8042c229f3035e994674cb79aab0ce980feae8 (diff)
Fix corruption of stack frame on trace exit.old/aarch64-v2.1-gc64-dis
Can now run some simple lua programs correctly.
-rw-r--r--src/lj_asm_arm64.h5
-rw-r--r--src/lj_frame.h1
-rw-r--r--src/vm_arm64.dasc2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h
index f4f7111..6876615 100644
--- a/src/lj_asm_arm64.h
+++ b/src/lj_asm_arm64.h
@@ -46,12 +46,12 @@ static MCode *asm_exitstub_gen(ASMState *as, ExitNo group)
if (mxp + 5*4+4*EXITSTUBS_PER_GROUP >= as->mctop)
asm_mclimit(as);
dispatch = i64ptr(J2GG(as->J)->dispatch);
- /* str lr, [sp];
+ /* str lr, [sp, #TMPDofs];
bl ->vm_exit_handler;
.long DISPATCH_address (lo)
.long DISPATCH_address (hi)
.long group. */
- *mxp++ = A64I_STRx|A64F_D(RID_LR)|A64F_N(RID_SP);
+ *mxp++ = A64I_STRx|A64F_D(RID_LR)|A64F_N(RID_SP)|A64F_A(CFRAME_OFS_TMPD>>3);
*mxp = A64I_BL|(((MCode *)(void *)lj_vm_exit_handler-mxp)&0x03ffffffu);
mxp++;
*mxp++ = (MCode)(dispatch & 0xffffffff); /* DISPATCH address (lo) */
@@ -303,7 +303,6 @@ static void asm_hrefk(ASMState *as, IRIns *ir)
Reg key = RID_NONE, type = RID_TMP, idx = node;
RegSet allow = rset_exclude(RSET_GPR, node);
lua_assert(ofs % sizeof(Node) == 0);
-printf("%d\n",ofs);
/* !!!TODO check 4095 for AArch64 */
if (ofs > 4095) {
idx = dest;
diff --git a/src/lj_frame.h b/src/lj_frame.h
index db2e4da..96c8c5c 100644
--- a/src/lj_frame.h
+++ b/src/lj_frame.h
@@ -192,6 +192,7 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
#endif
#define CFRAME_SHIFT_MULTRES 3
#elif LJ_TARGET_ARM64
+#define CFRAME_OFS_TMPD 184
#define CFRAME_OFS_ERRF 196
#define CFRAME_OFS_NRES 200
#define CFRAME_OFS_PREV 160
diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc
index e08d7bf..1cd287c 100644
--- a/src/vm_arm64.dasc
+++ b/src/vm_arm64.dasc
@@ -1893,7 +1893,7 @@ static void build_subroutines(BuildCtx *ctx)
| stp x26, x27, [sp, #464]
| stp x28, x29, [sp, #480]
| str lr, [sp, #496] // x31 not valid
- | ldr CARG1, [sp, #1536] // Load original value of lr.
+ | ldr CARG1, [sp, #(1536+184)] // Load original value of lr. 184==TMPDofs
| ldr TMP0, [lr] // Load DISPATCH.
| add CARG3, sp, #1536 // Recompute original value of sp.
| mv_vmstate CARG4, EXIT