diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_asm.c | 3 | ||||
-rw-r--r-- | src/lj_asm_arm64.h | 23 | ||||
-rw-r--r-- | src/lj_emit_arm64.h | 2 |
3 files changed, 12 insertions, 16 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c index 0e159e52..319ba837 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -2117,6 +2117,9 @@ static void asm_setup_regsp(ASMState *as) | |||
2117 | #endif | 2117 | #endif |
2118 | 2118 | ||
2119 | ra_setup(as); | 2119 | ra_setup(as); |
2120 | #if LJ_TARGET_ARM64 | ||
2121 | ra_setkref(as, RID_GL, (intptr_t)J2G(as->J)); | ||
2122 | #endif | ||
2120 | 2123 | ||
2121 | /* Clear reg/sp for constants. */ | 2124 | /* Clear reg/sp for constants. */ |
2122 | for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) { | 2125 | for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) { |
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h index b346b034..f6e99d9c 100644 --- a/src/lj_asm_arm64.h +++ b/src/lj_asm_arm64.h | |||
@@ -689,7 +689,7 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) | |||
689 | } else { | 689 | } else { |
690 | /* Otherwise use g->tmptv to hold the TValue. */ | 690 | /* Otherwise use g->tmptv to hold the TValue. */ |
691 | asm_tvstore64(as, dest, 0, ref); | 691 | asm_tvstore64(as, dest, 0, ref); |
692 | ra_allockreg(as, i64ptr(&J2G(as->J)->tmptv), dest); | 692 | emit_dn(as, A64I_ADDx^emit_isk12(glofs(as, &J2G(as->J)->tmptv)), dest, RID_GL); |
693 | } | 693 | } |
694 | } | 694 | } |
695 | 695 | ||
@@ -1261,17 +1261,13 @@ static void asm_tbar(ASMState *as, IRIns *ir) | |||
1261 | { | 1261 | { |
1262 | Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); | 1262 | Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); |
1263 | Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); | 1263 | Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); |
1264 | Reg gr = ra_allock(as, i64ptr(J2G(as->J)), | ||
1265 | rset_exclude(rset_exclude(RSET_GPR, tab), link)); | ||
1266 | Reg mark = RID_TMP; | 1264 | Reg mark = RID_TMP; |
1267 | MCLabel l_end = emit_label(as); | 1265 | MCLabel l_end = emit_label(as); |
1268 | emit_lso(as, A64I_STRx, link, tab, (int32_t)offsetof(GCtab, gclist)); | 1266 | emit_lso(as, A64I_STRx, link, tab, (int32_t)offsetof(GCtab, gclist)); |
1269 | emit_lso(as, A64I_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); | 1267 | emit_lso(as, A64I_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); |
1270 | emit_lso(as, A64I_STRx, tab, gr, | 1268 | emit_setgl(as, tab, gc.grayagain); |
1271 | (int32_t)offsetof(global_State, gc.grayagain)); | ||
1272 | emit_dn(as, A64I_ANDw^emit_isk13(~LJ_GC_BLACK, 0), mark, mark); | 1269 | emit_dn(as, A64I_ANDw^emit_isk13(~LJ_GC_BLACK, 0), mark, mark); |
1273 | emit_lso(as, A64I_LDRx, link, gr, | 1270 | emit_getgl(as, link, gc.grayagain); |
1274 | (int32_t)offsetof(global_State, gc.grayagain)); | ||
1275 | emit_cond_branch(as, CC_EQ, l_end); | 1271 | emit_cond_branch(as, CC_EQ, l_end); |
1276 | emit_n(as, A64I_TSTw^emit_isk13(LJ_GC_BLACK, 0), mark); | 1272 | emit_n(as, A64I_TSTw^emit_isk13(LJ_GC_BLACK, 0), mark); |
1277 | emit_lso(as, A64I_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); | 1273 | emit_lso(as, A64I_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); |
@@ -1291,7 +1287,7 @@ static void asm_obar(ASMState *as, IRIns *ir) | |||
1291 | args[0] = ASMREF_TMP1; /* global_State *g */ | 1287 | args[0] = ASMREF_TMP1; /* global_State *g */ |
1292 | args[1] = ir->op1; /* TValue *tv */ | 1288 | args[1] = ir->op1; /* TValue *tv */ |
1293 | asm_gencall(as, ci, args); | 1289 | asm_gencall(as, ci, args); |
1294 | ra_allockreg(as, i64ptr(J2G(as->J)), ra_releasetmp(as, ASMREF_TMP1) ); | 1290 | emit_dm(as, A64I_MOVx, ra_releasetmp(as, ASMREF_TMP1), RID_GL); |
1295 | obj = IR(ir->op1)->r; | 1291 | obj = IR(ir->op1)->r; |
1296 | tmp = ra_scratch(as, rset_exclude(allow, obj)); | 1292 | tmp = ra_scratch(as, rset_exclude(allow, obj)); |
1297 | emit_cond_branch(as, CC_EQ, l_end); | 1293 | emit_cond_branch(as, CC_EQ, l_end); |
@@ -1804,7 +1800,7 @@ static void asm_gc_check(ASMState *as) | |||
1804 | const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; | 1800 | const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; |
1805 | IRRef args[2]; | 1801 | IRRef args[2]; |
1806 | MCLabel l_end; | 1802 | MCLabel l_end; |
1807 | Reg tmp1, tmp2; | 1803 | Reg tmp2; |
1808 | ra_evictset(as, RSET_SCRATCH); | 1804 | ra_evictset(as, RSET_SCRATCH); |
1809 | l_end = emit_label(as); | 1805 | l_end = emit_label(as); |
1810 | /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ | 1806 | /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ |
@@ -1813,17 +1809,14 @@ static void asm_gc_check(ASMState *as) | |||
1813 | args[0] = ASMREF_TMP1; /* global_State *g */ | 1809 | args[0] = ASMREF_TMP1; /* global_State *g */ |
1814 | args[1] = ASMREF_TMP2; /* MSize steps */ | 1810 | args[1] = ASMREF_TMP2; /* MSize steps */ |
1815 | asm_gencall(as, ci, args); | 1811 | asm_gencall(as, ci, args); |
1816 | tmp1 = ra_releasetmp(as, ASMREF_TMP1); | 1812 | emit_dm(as, A64I_MOVx, ra_releasetmp(as, ASMREF_TMP1), RID_GL); |
1817 | tmp2 = ra_releasetmp(as, ASMREF_TMP2); | 1813 | tmp2 = ra_releasetmp(as, ASMREF_TMP2); |
1818 | emit_loadi(as, tmp2, as->gcsteps); | 1814 | emit_loadi(as, tmp2, as->gcsteps); |
1819 | /* Jump around GC step if GC total < GC threshold. */ | 1815 | /* Jump around GC step if GC total < GC threshold. */ |
1820 | emit_cond_branch(as, CC_LS, l_end); | 1816 | emit_cond_branch(as, CC_LS, l_end); |
1821 | emit_nm(as, A64I_CMPx, RID_TMP, tmp2); | 1817 | emit_nm(as, A64I_CMPx, RID_TMP, tmp2); |
1822 | emit_lso(as, A64I_LDRx, tmp2, tmp1, | 1818 | emit_getgl(as, tmp2, gc.threshold); |
1823 | (int32_t)offsetof(global_State, gc.threshold)); | 1819 | emit_getgl(as, RID_TMP, gc.total); |
1824 | emit_lso(as, A64I_LDRx, RID_TMP, tmp1, | ||
1825 | (int32_t)offsetof(global_State, gc.total)); | ||
1826 | ra_allockreg(as, i64ptr(J2G(as->J)), tmp1); | ||
1827 | as->gcsteps = 0; | 1820 | as->gcsteps = 0; |
1828 | checkmclim(as); | 1821 | checkmclim(as); |
1829 | } | 1822 | } |
diff --git a/src/lj_emit_arm64.h b/src/lj_emit_arm64.h index 938486ca..00086e8a 100644 --- a/src/lj_emit_arm64.h +++ b/src/lj_emit_arm64.h | |||
@@ -163,7 +163,7 @@ nopair: | |||
163 | /* Try to find an N-step delta relative to other consts with N < lim. */ | 163 | /* Try to find an N-step delta relative to other consts with N < lim. */ |
164 | static int emit_kdelta(ASMState *as, Reg rd, uint64_t k, int lim) | 164 | static int emit_kdelta(ASMState *as, Reg rd, uint64_t k, int lim) |
165 | { | 165 | { |
166 | RegSet work = ~as->freeset & RSET_GPR; | 166 | RegSet work = (~as->freeset & RSET_GPR) | RID2RSET(RID_GL); |
167 | if (lim <= 1) return 0; /* Can't beat that. */ | 167 | if (lim <= 1) return 0; /* Can't beat that. */ |
168 | while (work) { | 168 | while (work) { |
169 | Reg r = rset_picktop(work); | 169 | Reg r = rset_picktop(work); |