Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2019-12-08 19:50:36 +01:00
commit 1d9a337de6
7 changed files with 16 additions and 13 deletions

View File

@ -502,7 +502,8 @@ LJLIB_CF(print)
lua_gettable(L, LUA_GLOBALSINDEX); lua_gettable(L, LUA_GLOBALSINDEX);
tv = L->top-1; tv = L->top-1;
} }
shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring)
&& !gcrefu(basemt_it(G(L), LJ_TNUMX));
for (i = 0; i < nargs; i++) { for (i = 0; i < nargs; i++) {
cTValue *o = &L->base[i]; cTValue *o = &L->base[i];
const char *str; const char *str;

View File

@ -22,7 +22,6 @@
#include "lj_ircall.h" #include "lj_ircall.h"
#include "lj_iropt.h" #include "lj_iropt.h"
#include "lj_mcode.h" #include "lj_mcode.h"
#include "lj_iropt.h"
#include "lj_trace.h" #include "lj_trace.h"
#include "lj_snap.h" #include "lj_snap.h"
#include "lj_asm.h" #include "lj_asm.h"

View File

@ -119,12 +119,13 @@ static void *clib_loadlib(lua_State *L, const char *name, int global)
RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL));
if (!h) { if (!h) {
const char *e, *err = dlerror(); const char *e, *err = dlerror();
if (*err == '/' && (e = strchr(err, ':')) && if (err && *err == '/' && (e = strchr(err, ':')) &&
(name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) {
h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL));
if (h) return h; if (h) return h;
err = dlerror(); err = dlerror();
} }
if (!err) err = "dlopen failed";
lj_err_callermsg(L, err); lj_err_callermsg(L, err);
} }
return h; return h;
@ -384,6 +385,7 @@ TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name)
cd = lj_cdata_new(cts, id, CTSIZE_PTR); cd = lj_cdata_new(cts, id, CTSIZE_PTR);
*(void **)cdataptr(cd) = p; *(void **)cdataptr(cd) = p;
setcdataV(L, tv, cd); setcdataV(L, tv, cd);
lj_gc_anybarriert(L, cl->cache);
} }
} }
return tv; return tv;

View File

@ -262,19 +262,19 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
return _CountLeadingZeros(x) ^ 31; return _CountLeadingZeros(x) ^ 31;
} }
#else #else
unsigned char _BitScanForward(uint32_t *, unsigned long); unsigned char _BitScanForward(unsigned long *, unsigned long);
unsigned char _BitScanReverse(uint32_t *, unsigned long); unsigned char _BitScanReverse(unsigned long *, unsigned long);
#pragma intrinsic(_BitScanForward) #pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse) #pragma intrinsic(_BitScanReverse)
static LJ_AINLINE uint32_t lj_ffs(uint32_t x) static LJ_AINLINE uint32_t lj_ffs(uint32_t x)
{ {
uint32_t r; _BitScanForward(&r, x); return r; unsigned long r; _BitScanForward(&r, x); return (uint32_t)r;
} }
static LJ_AINLINE uint32_t lj_fls(uint32_t x) static LJ_AINLINE uint32_t lj_fls(uint32_t x)
{ {
uint32_t r; _BitScanReverse(&r, x); return r; unsigned long r; _BitScanReverse(&r, x); return (uint32_t)r;
} }
#endif #endif

View File

@ -138,7 +138,7 @@ static int lex_skipeq(LexState *ls)
int count = 0; int count = 0;
LexChar s = ls->c; LexChar s = ls->c;
lua_assert(s == '[' || s == ']'); lua_assert(s == '[' || s == ']');
while (lex_savenext(ls) == '=') while (lex_savenext(ls) == '=' && count < 0x20000000)
count++; count++;
return (ls->c == s) ? count : (-count) - 1; return (ls->c == s) ? count : (-count) - 1;
} }

View File

@ -1860,6 +1860,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
lj_trace_err_info(J, LJ_TRERR_NYIBC); lj_trace_err_info(J, LJ_TRERR_NYIBC);
} }
} }
if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS)
lj_trace_err(J, LJ_TRERR_STACKOV);
} }
/* -- Record allocations -------------------------------------------------- */ /* -- Record allocations -------------------------------------------------- */

View File

@ -486,8 +486,7 @@ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key)
/* Rechain pseudo-resurrected string keys with colliding hashes. */ /* Rechain pseudo-resurrected string keys with colliding hashes. */
while (nextnode(freenode)) { while (nextnode(freenode)) {
Node *nn = nextnode(freenode); Node *nn = nextnode(freenode);
if (tvisstr(&nn->key) && !tvisnil(&nn->val) && if (!tvisnil(&nn->val) && hashkey(t, &nn->key) == n) {
hashstr(t, strV(&nn->key)) == n) {
freenode->next = nn->next; freenode->next = nn->next;
nn->next = n->next; nn->next = n->next;
setmref(n->next, nn); setmref(n->next, nn);
@ -500,9 +499,9 @@ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key)
** any string key that's currently in a non-main positions. ** any string key that's currently in a non-main positions.
*/ */
while ((nn = nextnode(freenode))) { while ((nn = nextnode(freenode))) {
if (tvisstr(&nn->key) && !tvisnil(&nn->val)) { if (!tvisnil(&nn->val)) {
Node *mn = hashstr(t, strV(&nn->key)); Node *mn = hashkey(t, &nn->key);
if (mn != freenode) { if (mn != freenode && mn != nn) {
freenode->next = nn->next; freenode->next = nn->next;
nn->next = mn->next; nn->next = mn->next;
setmref(mn->next, nn); setmref(mn->next, nn);