Update LuaJIT to the latest 2.1.0 source (0bee44c)

This commit is contained in:
Alex Szpakowski
2019-12-25 17:37:36 -05:00
parent 4418ce28e1
commit f138e9052e
188 changed files with 38754 additions and 11773 deletions
+51 -33
View File
@@ -29,6 +29,7 @@
#include "lj_ccall.h"
#include "lj_ccallback.h"
#include "lj_clib.h"
#include "lj_strfmt.h"
#include "lj_ff.h"
#include "lj_lib.h"
@@ -137,7 +138,7 @@ static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm)
}
}
copyTV(L, base, L->top);
tv = L->top-1;
tv = L->top-1-LJ_FR2;
}
return lj_meta_tailcall(L, tv);
}
@@ -193,7 +194,7 @@ LJLIB_CF(ffi_meta___eq) LJLIB_REC(cdata_arith MM_eq)
LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len)
{
return ffi_arith(L);
return lj_carith_len(L);
}
LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt)
@@ -318,7 +319,7 @@ LJLIB_CF(ffi_meta___tostring)
}
}
}
lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p);
lj_strfmt_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p);
checkgc:
lj_gc_check(L);
return 1;
@@ -504,10 +505,7 @@ LJLIB_CF(ffi_new) LJLIB_REC(.)
}
if (sz == CTSIZE_INVALID)
lj_err_arg(L, 1, LJ_ERR_FFI_INVSIZE);
if (!(info & CTF_VLA) && ctype_align(info) <= CT_MEMALIGN)
cd = lj_cdata_new(cts, id, sz);
else
cd = lj_cdata_newv(cts, id, sz, ctype_align(info));
cd = lj_cdata_newx(cts, id, sz, info);
setcdataV(L, o-1, cd); /* Anchor the uninitialized cdata. */
lj_cconv_ct_init(cts, ct, sz, cdataptr(cd),
o, (MSize)(L->top - o)); /* Initialize cdata. */
@@ -558,6 +556,31 @@ LJLIB_CF(ffi_typeof) LJLIB_REC(.)
return 1;
}
/* Internal and unsupported API. */
LJLIB_CF(ffi_typeinfo)
{
CTState *cts = ctype_cts(L);
CTypeID id = (CTypeID)ffi_checkint(L, 1);
if (id > 0 && id < cts->top) {
CType *ct = ctype_get(cts, id);
GCtab *t;
lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */
t = tabV(L->top-1);
setintV(lj_tab_setstr(L, t, lj_str_newlit(L, "info")), (int32_t)ct->info);
if (ct->size != CTSIZE_INVALID)
setintV(lj_tab_setstr(L, t, lj_str_newlit(L, "size")), (int32_t)ct->size);
if (ct->sib)
setintV(lj_tab_setstr(L, t, lj_str_newlit(L, "sib")), (int32_t)ct->sib);
if (gcref(ct->name)) {
GCstr *s = gco2str(gcref(ct->name));
setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "name")), s);
}
lj_gc_check(L);
return 1;
}
return 0;
}
LJLIB_CF(ffi_istype) LJLIB_REC(.)
{
CTState *cts = ctype_cts(L);
@@ -697,44 +720,47 @@ LJLIB_CF(ffi_fill) LJLIB_REC(.)
return 0;
}
#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be)
/* Test ABI string. */
LJLIB_CF(ffi_abi) LJLIB_REC(.)
{
GCstr *s = lj_lib_checkstr(L, 1);
int b = 0;
switch (s->hash) {
int b = lj_cparse_case(s,
#if LJ_64
case H_(849858eb,ad35fd06): b = 1; break; /* 64bit */
"\00564bit"
#else
case H_(662d3c79,d0e22477): b = 1; break; /* 32bit */
"\00532bit"
#endif
#if LJ_ARCH_HASFPU
case H_(e33ee463,e33ee463): b = 1; break; /* fpu */
"\003fpu"
#endif
#if LJ_ABI_SOFTFP
case H_(61211a23,c2e8c81c): b = 1; break; /* softfp */
"\006softfp"
#else
case H_(539417a8,8ce0812f): b = 1; break; /* hardfp */
"\006hardfp"
#endif
#if LJ_ABI_EABI
case H_(2182df8f,f2ed1152): b = 1; break; /* eabi */
"\004eabi"
#endif
#if LJ_ABI_WIN
case H_(4ab624a8,4ab624a8): b = 1; break; /* win */
"\003win"
#endif
case H_(3af93066,1f001464): b = 1; break; /* le/be */
default:
break;
}
#if LJ_TARGET_UWP
"\003uwp"
#endif
#if LJ_LE
"\002le"
#else
"\002be"
#endif
#if LJ_GC64
"\004gc64"
#endif
) >= 0;
setboolV(L->top-1, b);
setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */
return 1;
}
#undef H_
LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */
LJLIB_CF(ffi_metatype)
@@ -768,19 +794,11 @@ LJLIB_CF(ffi_gc) LJLIB_REC(.)
GCcdata *cd = ffi_checkcdata(L, 1);
TValue *fin = lj_lib_checkany(L, 2);
CTState *cts = ctype_cts(L);
GCtab *t = cts->finalizer;
CType *ct = ctype_raw(cts, cd->ctypeid);
if (!(ctype_isptr(ct->info) || ctype_isstruct(ct->info) ||
ctype_isrefarray(ct->info)))
lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE);
if (gcref(t->metatable)) { /* Update finalizer table, if still enabled. */
copyTV(L, lj_tab_set(L, t, L->base), fin);
lj_gc_anybarriert(L, t);
if (!tvisnil(fin))
cd->marked |= LJ_GC_CDATA_FIN;
else
cd->marked &= ~LJ_GC_CDATA_FIN;
}
lj_cdata_setfin(L, cd, gcval(fin), itype(fin));
L->top = L->base+1; /* Pass through the cdata object. */
return 1;
}