aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent7381b620358c2561e8690149f1d25828fdad6675 (diff)
downloadluajit-c7c3c4da432ddb543d4b0a9abbb245f11b26afd0.tar.gz
luajit-c7c3c4da432ddb543d4b0a9abbb245f11b26afd0.tar.bz2
luajit-c7c3c4da432ddb543d4b0a9abbb245f11b26afd0.zip
MIPS: Fix handling of spare long-range jump slots.
Contributed by Djordje Kovacevic and Stefan Pejic.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm_mips.h9
-rw-r--r--src/lj_jit.h6
-rw-r--r--src/lj_mcode.c6
3 files changed, 11 insertions, 10 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)
65static void asm_sparejump_setup(ASMState *as) 65static void asm_sparejump_setup(ASMState *as)
66{ 66{
67 MCode *mxp = as->mcbot; 67 MCode *mxp = as->mcbot;
68 /* Assumes sizeof(MCLink) == 8. */ 68 if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == sizeof(MCLink)) {
69 if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) {
70 lua_assert(MIPSI_NOP == 0); 69 lua_assert(MIPSI_NOP == 0);
71 memset(mxp+2, 0, MIPS_SPAREJUMP*8); 70 memset(mxp, 0, MIPS_SPAREJUMP*2*sizeof(MCode));
72 mxp += MIPS_SPAREJUMP*2; 71 mxp += MIPS_SPAREJUMP*2;
73 lua_assert(mxp < as->mctop); 72 lua_assert(mxp < as->mctop);
74 lj_mcode_sync(as->mcbot, mxp); 73 lj_mcode_sync(as->mcbot, mxp);
@@ -1947,7 +1946,9 @@ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target)
1947 if (!cstart) cstart = p-1; 1946 if (!cstart) cstart = p-1;
1948 } else { /* Branch out of range. Use spare jump slot in mcarea. */ 1947 } else { /* Branch out of range. Use spare jump slot in mcarea. */
1949 int i; 1948 int i;
1950 for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) { 1949 for (i = (int)(sizeof(MCLink)/sizeof(MCode));
1950 i < (int)(sizeof(MCLink)/sizeof(MCode)+MIPS_SPAREJUMP*2);
1951 i += 2) {
1951 if (mcarea[i] == tjump) { 1952 if (mcarea[i] == tjump) {
1952 delta = mcarea+i - p; 1953 delta = mcarea+i - p;
1953 goto patchbranch; 1954 goto patchbranch;
diff --git a/src/lj_jit.h b/src/lj_jit.h
index a2e8fd92..3f38d289 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -155,6 +155,12 @@ typedef uint8_t MCode;
155typedef uint32_t MCode; 155typedef uint32_t MCode;
156#endif 156#endif
157 157
158/* Linked list of MCode areas. */
159typedef struct MCLink {
160 MCode *next; /* Next area. */
161 size_t size; /* Size of current area. */
162} MCLink;
163
158/* Stack snapshot header. */ 164/* Stack snapshot header. */
159typedef struct SnapShot { 165typedef struct SnapShot {
160 uint16_t mapofs; /* Offset into snapshot map. */ 166 uint16_t mapofs; /* Offset into snapshot map. */
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index f0a1f699..5ea89f66 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -272,12 +272,6 @@ static void *mcode_alloc(jit_State *J, size_t sz)
272 272
273/* -- MCode area management ----------------------------------------------- */ 273/* -- MCode area management ----------------------------------------------- */
274 274
275/* Linked list of MCode areas. */
276typedef struct MCLink {
277 MCode *next; /* Next area. */
278 size_t size; /* Size of current area. */
279} MCLink;
280
281/* Allocate a new MCode area. */ 275/* Allocate a new MCode area. */
282static void mcode_allocarea(jit_State *J) 276static void mcode_allocarea(jit_State *J)
283{ 277{