aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2017-03-08 23:04:46 +0100
committerMike Pall <mike>2017-03-08 23:04:46 +0100
commitd3e36e7920c641410dfcdf1fc6c10069fd3192a6 (patch)
tree04ae8ac89a49d1017171f293eff8e4bfbd2a547b
parenta25c0b99b84558887887b8e298409dcf8605e5e3 (diff)
parentf50bf7585a32738c4fb719cb8fc59d02231fc8c3 (diff)
downloadluajit-d3e36e7920c641410dfcdf1fc6c10069fd3192a6.tar.gz
luajit-d3e36e7920c641410dfcdf1fc6c10069fd3192a6.tar.bz2
luajit-d3e36e7920c641410dfcdf1fc6c10069fd3192a6.zip
Merge branch 'master' into v2.1
-rw-r--r--src/Makefile4
-rw-r--r--src/lib_ffi.c2
-rw-r--r--src/lj_gc.c17
-rw-r--r--src/lj_mcode.c16
-rw-r--r--src/lj_parse.c10
5 files changed, 27 insertions, 22 deletions
diff --git a/src/Makefile b/src/Makefile
index 5a2277cc..7cb4c14a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -209,7 +209,7 @@ TARGET_CC= $(STATIC_CC)
209TARGET_STCC= $(STATIC_CC) 209TARGET_STCC= $(STATIC_CC)
210TARGET_DYNCC= $(DYNAMIC_CC) 210TARGET_DYNCC= $(DYNAMIC_CC)
211TARGET_LD= $(CROSS)$(CC) 211TARGET_LD= $(CROSS)$(CC)
212TARGET_AR= $(CROSS)ar rcus 212TARGET_AR= $(CROSS)ar rcus 2>/dev/null
213TARGET_STRIP= $(CROSS)strip 213TARGET_STRIP= $(CROSS)strip
214 214
215TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) 215TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
@@ -313,7 +313,6 @@ ifeq (Darwin,$(TARGET_SYS))
313 export MACOSX_DEPLOYMENT_TARGET=10.4 313 export MACOSX_DEPLOYMENT_TARGET=10.4
314 endif 314 endif
315 TARGET_STRIP+= -x 315 TARGET_STRIP+= -x
316 TARGET_AR+= 2>/dev/null
317 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC 316 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
318 TARGET_DYNXLDOPTS= 317 TARGET_DYNXLDOPTS=
319 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) 318 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
@@ -324,7 +323,6 @@ ifeq (Darwin,$(TARGET_SYS))
324else 323else
325ifeq (iOS,$(TARGET_SYS)) 324ifeq (iOS,$(TARGET_SYS))
326 TARGET_STRIP+= -x 325 TARGET_STRIP+= -x
327 TARGET_AR+= 2>/dev/null
328 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC 326 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
329 TARGET_DYNXLDOPTS= 327 TARGET_DYNXLDOPTS=
330 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) 328 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index 5b9e25ea..136e98e8 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -829,7 +829,7 @@ static GCtab *ffi_finalizer(lua_State *L)
829 settabV(L, L->top++, t); 829 settabV(L, L->top++, t);
830 setgcref(t->metatable, obj2gco(t)); 830 setgcref(t->metatable, obj2gco(t));
831 setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), 831 setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")),
832 lj_str_newlit(L, "K")); 832 lj_str_newlit(L, "k"));
833 t->nomm = (uint8_t)(~(1u<<MM_mode)); 833 t->nomm = (uint8_t)(~(1u<<MM_mode));
834 return t; 834 return t;
835} 835}
diff --git a/src/lj_gc.c b/src/lj_gc.c
index c82af662..2aaf5b2c 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -169,12 +169,19 @@ static int gc_traverse_tab(global_State *g, GCtab *t)
169 while ((c = *modestr++)) { 169 while ((c = *modestr++)) {
170 if (c == 'k') weak |= LJ_GC_WEAKKEY; 170 if (c == 'k') weak |= LJ_GC_WEAKKEY;
171 else if (c == 'v') weak |= LJ_GC_WEAKVAL; 171 else if (c == 'v') weak |= LJ_GC_WEAKVAL;
172 else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL);
173 } 172 }
174 if (weak > 0) { /* Weak tables are cleared in the atomic phase. */ 173 if (weak) { /* Weak tables are cleared in the atomic phase. */
175 t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); 174#if LJ_HASFFI
176 setgcrefr(t->gclist, g->gc.weak); 175 CTState *cts = ctype_ctsG(g);
177 setgcref(g->gc.weak, obj2gco(t)); 176 if (cts && cts->finalizer == t) {
177 weak = (int)(~0u & ~LJ_GC_WEAKVAL);
178 } else
179#endif
180 {
181 t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak);
182 setgcrefr(t->gclist, g->gc.weak);
183 setgcref(g->gc.weak, obj2gco(t));
184 }
178 } 185 }
179 } 186 }
180 if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ 187 if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index 0f29a3ce..77035bf7 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -204,10 +204,7 @@ static void mcode_protect(jit_State *J, int prot)
204 204
205/* -- MCode area allocation ----------------------------------------------- */ 205/* -- MCode area allocation ----------------------------------------------- */
206 206
207#if LJ_TARGET_X64 207#if LJ_64
208#define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47)
209#elif LJ_TARGET_ARM64 || LJ_TARGET_MIPS64
210/* We have no clue about the valid VA range. It could be 39 - 52 bits. */
211#define mcode_validptr(p) (p) 208#define mcode_validptr(p) (p)
212#else 209#else
213#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) 210#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000)
@@ -233,7 +230,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
233 /* First try a contiguous area below the last one. */ 230 /* First try a contiguous area below the last one. */
234 uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; 231 uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
235 int i; 232 int i;
236 for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */ 233 /* Limit probing iterations, depending on the available pool size. */
234 for (i = 0; i < LJ_TARGET_JUMPRANGE; i++) {
237 if (mcode_validptr(hint)) { 235 if (mcode_validptr(hint)) {
238 void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); 236 void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN);
239 237
@@ -242,11 +240,11 @@ static void *mcode_alloc(jit_State *J, size_t sz)
242 return p; 240 return p;
243 if (p) mcode_free(J, p, sz); /* Free badly placed area. */ 241 if (p) mcode_free(J, p, sz); /* Free badly placed area. */
244 } 242 }
245 /* Next try probing pseudo-random addresses. */ 243 /* Next try probing 64K-aligned pseudo-random addresses. */
246 do { 244 do {
247 hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */ 245 hint = LJ_PRNG_BITS(J, LJ_TARGET_JUMPRANGE-16) << 16;
248 } while (!(hint + sz < range)); 246 } while (!(hint + sz < range+range));
249 hint = target + hint - (range>>1); 247 hint = target + hint - range;
250 } 248 }
251 lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ 249 lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */
252 return NULL; 250 return NULL;
diff --git a/src/lj_parse.c b/src/lj_parse.c
index b5b7b6b4..08f7cfa6 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -1282,12 +1282,14 @@ static void fscope_end(FuncState *fs)
1282 MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); 1282 MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc);
1283 ls->vtop = idx; /* Drop break label immediately. */ 1283 ls->vtop = idx; /* Drop break label immediately. */
1284 gola_resolve(ls, bl, idx); 1284 gola_resolve(ls, bl, idx);
1285 } else { /* Need the fixup step to propagate the breaks. */
1286 gola_fixup(ls, bl);
1285 return; 1287 return;
1286 } /* else: need the fixup step to propagate the breaks. */ 1288 }
1287 } else if (!(bl->flags & FSCOPE_GOLA)) { 1289 }
1288 return; 1290 if ((bl->flags & FSCOPE_GOLA)) {
1291 gola_fixup(ls, bl);
1289 } 1292 }
1290 gola_fixup(ls, bl);
1291} 1293}
1292 1294
1293/* Mark scope as having an upvalue. */ 1295/* Mark scope as having an upvalue. */