diff options
| author | Mike Pall <mike> | 2025-11-08 15:41:42 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2025-11-08 15:41:42 +0100 |
| commit | 578c41ceb73bdf9d97f23c9e0342f8d027c08e77 (patch) | |
| tree | c17a106eda6eedf45baea3a76faf42968ad49885 /src | |
| parent | 68354f444728ef99bb51bb4d86e8f1b40853a898 (diff) | |
| download | luajit-578c41ceb73bdf9d97f23c9e0342f8d027c08e77.tar.gz luajit-578c41ceb73bdf9d97f23c9e0342f8d027c08e77.tar.bz2 luajit-578c41ceb73bdf9d97f23c9e0342f8d027c08e77.zip | |
ARM64: Enable unaligned accesses if indicated by the toolchain.
If you get a crash in jit_init() then you need to fix your toolchain.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_jit.c | 9 | ||||
| -rw-r--r-- | src/lj_arch.h | 4 | ||||
| -rw-r--r-- | src/lj_asm_arm64.h | 3 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 1b74d957..0f75c5ac 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
| @@ -723,7 +723,16 @@ static void jit_init(lua_State *L) | |||
| 723 | jit_State *J = L2J(L); | 723 | jit_State *J = L2J(L); |
| 724 | J->flags = jit_cpudetect() | JIT_F_ON | JIT_F_OPT_DEFAULT; | 724 | J->flags = jit_cpudetect() | JIT_F_ON | JIT_F_OPT_DEFAULT; |
| 725 | memcpy(J->param, jit_param_default, sizeof(J->param)); | 725 | memcpy(J->param, jit_param_default, sizeof(J->param)); |
| 726 | #if LJ_TARGET_UNALIGNED | ||
| 727 | G(L)->tmptv.u64 = U64x(0000504d,4d500000); | ||
| 728 | #endif | ||
| 726 | lj_dispatch_update(G(L)); | 729 | lj_dispatch_update(G(L)); |
| 730 | #if LJ_TARGET_UNALIGNED | ||
| 731 | /* If you get a crash below then your toolchain indicates unaligned | ||
| 732 | ** accesses are OK, but your kernel disagrees. I.e. fix your toolchain. | ||
| 733 | */ | ||
| 734 | if (*(uint32_t *)((char *)&G(L)->tmptv + 2) != 0x504d4d50u) L->top = NULL; | ||
| 735 | #endif | ||
| 727 | } | 736 | } |
| 728 | #endif | 737 | #endif |
| 729 | 738 | ||
diff --git a/src/lj_arch.h b/src/lj_arch.h index 799f9c6c..5f388068 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
| @@ -304,6 +304,10 @@ | |||
| 304 | #define LJ_PAGESIZE 16384 | 304 | #define LJ_PAGESIZE 16384 |
| 305 | #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL | 305 | #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL |
| 306 | 306 | ||
| 307 | #if __ARM_FEATURE_UNALIGNED | ||
| 308 | #define LJ_TARGET_UNALIGNED 1 | ||
| 309 | #endif | ||
| 310 | |||
| 307 | #define LJ_ARCH_VERSION 80 | 311 | #define LJ_ARCH_VERSION 80 |
| 308 | 312 | ||
| 309 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC | 313 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC |
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h index 085f9357..fdcff1db 100644 --- a/src/lj_asm_arm64.h +++ b/src/lj_asm_arm64.h | |||
| @@ -1056,7 +1056,8 @@ static void asm_fstore(ASMState *as, IRIns *ir) | |||
| 1056 | static void asm_xload(ASMState *as, IRIns *ir) | 1056 | static void asm_xload(ASMState *as, IRIns *ir) |
| 1057 | { | 1057 | { |
| 1058 | Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); | 1058 | Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); |
| 1059 | lj_assertA(!(ir->op2 & IRXLOAD_UNALIGNED), "unaligned XLOAD"); | 1059 | lj_assertA(LJ_TARGET_UNALIGNED || !(ir->op2 & IRXLOAD_UNALIGNED), |
| 1060 | "unaligned XLOAD"); | ||
| 1060 | asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR); | 1061 | asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR); |
| 1061 | } | 1062 | } |
| 1062 | 1063 | ||
