Skip to content

Commit

Permalink
Merge branch 'master' into v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Pall committed Mar 8, 2017
2 parents a25c0b9 + f50bf75 commit d3e36e7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
4 changes: 1 addition & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ TARGET_CC= $(STATIC_CC)
TARGET_STCC= $(STATIC_CC)
TARGET_DYNCC= $(DYNAMIC_CC)
TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus
TARGET_AR= $(CROSS)ar rcus 2>/dev/null
TARGET_STRIP= $(CROSS)strip

TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
Expand Down Expand Up @@ -313,7 +313,6 @@ ifeq (Darwin,$(TARGET_SYS))
export MACOSX_DEPLOYMENT_TARGET=10.4
endif
TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
Expand All @@ -324,7 +323,6 @@ ifeq (Darwin,$(TARGET_SYS))
else
ifeq (iOS,$(TARGET_SYS))
TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
Expand Down
2 changes: 1 addition & 1 deletion src/lib_ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ static GCtab *ffi_finalizer(lua_State *L)
settabV(L, L->top++, t);
setgcref(t->metatable, obj2gco(t));
setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")),
lj_str_newlit(L, "K"));
lj_str_newlit(L, "k"));
t->nomm = (uint8_t)(~(1u<<MM_mode));
return t;
}
Expand Down
17 changes: 12 additions & 5 deletions src/lj_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,19 @@ static int gc_traverse_tab(global_State *g, GCtab *t)
while ((c = *modestr++)) {
if (c == 'k') weak |= LJ_GC_WEAKKEY;
else if (c == 'v') weak |= LJ_GC_WEAKVAL;
else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL);
}
if (weak > 0) { /* Weak tables are cleared in the atomic phase. */
t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak);
setgcrefr(t->gclist, g->gc.weak);
setgcref(g->gc.weak, obj2gco(t));
if (weak) { /* Weak tables are cleared in the atomic phase. */
#if LJ_HASFFI
CTState *cts = ctype_ctsG(g);
if (cts && cts->finalizer == t) {
weak = (int)(~0u & ~LJ_GC_WEAKVAL);
} else
#endif
{
t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak);
setgcrefr(t->gclist, g->gc.weak);
setgcref(g->gc.weak, obj2gco(t));
}
}
}
if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */
Expand Down
16 changes: 7 additions & 9 deletions src/lj_mcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ static void mcode_protect(jit_State *J, int prot)

/* -- MCode area allocation ----------------------------------------------- */

#if LJ_TARGET_X64
#define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47)
#elif LJ_TARGET_ARM64 || LJ_TARGET_MIPS64
/* We have no clue about the valid VA range. It could be 39 - 52 bits. */
#if LJ_64
#define mcode_validptr(p) (p)
#else
#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000)
Expand All @@ -233,7 +230,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
/* First try a contiguous area below the last one. */
uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
int i;
for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */
/* Limit probing iterations, depending on the available pool size. */
for (i = 0; i < LJ_TARGET_JUMPRANGE; i++) {
if (mcode_validptr(hint)) {
void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN);

Expand All @@ -242,11 +240,11 @@ static void *mcode_alloc(jit_State *J, size_t sz)
return p;
if (p) mcode_free(J, p, sz); /* Free badly placed area. */
}
/* Next try probing pseudo-random addresses. */
/* Next try probing 64K-aligned pseudo-random addresses. */
do {
hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */
} while (!(hint + sz < range));
hint = target + hint - (range>>1);
hint = LJ_PRNG_BITS(J, LJ_TARGET_JUMPRANGE-16) << 16;
} while (!(hint + sz < range+range));
hint = target + hint - range;
}
lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */
return NULL;
Expand Down
10 changes: 6 additions & 4 deletions src/lj_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,12 +1282,14 @@ static void fscope_end(FuncState *fs)
MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc);
ls->vtop = idx; /* Drop break label immediately. */
gola_resolve(ls, bl, idx);
} else { /* Need the fixup step to propagate the breaks. */
gola_fixup(ls, bl);
return;
} /* else: need the fixup step to propagate the breaks. */
} else if (!(bl->flags & FSCOPE_GOLA)) {
return;
}
}
if ((bl->flags & FSCOPE_GOLA)) {
gola_fixup(ls, bl);
}
gola_fixup(ls, bl);
}

/* Mark scope as having an upvalue. */
Expand Down

0 comments on commit d3e36e7

Please sign in to comment.