summaryrefslogtreecommitdiff
path: root/src/lj_asm_mips.h
diff options
context:
space:
mode:
authorMike Pall <mike>2017-06-07 19:36:46 +0200
committerMike Pall <mike>2017-06-07 19:36:46 +0200
commitc7c3c4da432ddb543d4b0a9abbb245f11b26afd0 (patch)
treed153382bd0121bb289984d4270bd8f8cc9926144 /src/lj_asm_mips.h
parent7381b620358c2561e8690149f1d25828fdad6675 (diff)
downloadluajit2-c7c3c4da432ddb543d4b0a9abbb245f11b26afd0.tar.gz
MIPS: Fix handling of spare long-range jump slots.
Contributed by Djordje Kovacevic and Stefan Pejic.
Diffstat (limited to 'src/lj_asm_mips.h')
-rw-r--r--src/lj_asm_mips.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index d0a1ca51..76311903 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -65,10 +65,9 @@ static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow)
static void asm_sparejump_setup(ASMState *as)
{
MCode *mxp = as->mcbot;
- /* Assumes sizeof(MCLink) == 8. */
- if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) {
+ if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == sizeof(MCLink)) {
lua_assert(MIPSI_NOP == 0);
- memset(mxp+2, 0, MIPS_SPAREJUMP*8);
+ memset(mxp, 0, MIPS_SPAREJUMP*2*sizeof(MCode));
mxp += MIPS_SPAREJUMP*2;
lua_assert(mxp < as->mctop);
lj_mcode_sync(as->mcbot, mxp);
@@ -1947,7 +1946,9 @@ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target)
if (!cstart) cstart = p-1;
} else { /* Branch out of range. Use spare jump slot in mcarea. */
int i;
- for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) {
+ for (i = (int)(sizeof(MCLink)/sizeof(MCode));
+ i < (int)(sizeof(MCLink)/sizeof(MCode)+MIPS_SPAREJUMP*2);
+ i += 2) {
if (mcarea[i] == tjump) {
delta = mcarea+i - p;
goto patchbranch;