mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-16 12:19:19 +00:00
Compare commits
9 Commits
2c1183e12c
...
71b97d9872
Author | SHA1 | Date | |
---|---|---|---|
![]() |
71b97d9872 | ||
![]() |
eec7a8016c | ||
![]() |
51d4c26ec7 | ||
![]() |
c262976486 | ||
![]() |
e0a7ea8a92 | ||
![]() |
e76bb50d44 | ||
![]() |
e9e4b6d302 | ||
![]() |
dc809beb57 | ||
![]() |
89213015a6 |
@ -302,6 +302,9 @@ endif
|
||||
ifneq (,$(INSTALL_LJLIBD))
|
||||
TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\"
|
||||
endif
|
||||
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-strict-float-cast-overflow 2>/dev/null || echo 1))
|
||||
TARGET_XCFLAGS+= -fno-strict-float-cast-overflow
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
# Target system detection.
|
||||
|
@ -224,7 +224,7 @@ LJLIB_CF(rawlen) LJLIB_REC(.)
|
||||
}
|
||||
#endif
|
||||
|
||||
LJLIB_CF(unpack)
|
||||
LJLIB_CF(unpack) LJLIB_REC(.)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
int32_t n, i = lj_lib_optint(L, 2, 1);
|
||||
|
@ -1927,7 +1927,7 @@ static void asm_hiop(ASMState *as, IRIns *ir)
|
||||
} else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) {
|
||||
as->curins--; /* Always skip the loword min/max. */
|
||||
if (uselo || usehi)
|
||||
asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_PL : CC_LE);
|
||||
asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HS : CC_LS);
|
||||
return;
|
||||
#elif LJ_HASFFI
|
||||
} else if ((ir-1)->o == IR_CONV) {
|
||||
|
@ -781,17 +781,24 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
|
||||
{
|
||||
CTSize sz = ct->size;
|
||||
unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION);
|
||||
while (ct->sib) {
|
||||
while (ct->sib && n <= 4) {
|
||||
unsigned int m = 1;
|
||||
CType *sct;
|
||||
ct = ctype_get(cts, ct->sib);
|
||||
if (ctype_isfield(ct->info)) {
|
||||
sct = ctype_rawchild(cts, ct);
|
||||
if (ctype_isarray(sct->info)) {
|
||||
CType *cct = ctype_rawchild(cts, sct);
|
||||
if (!cct->size) continue;
|
||||
m = sct->size / cct->size;
|
||||
sct = cct;
|
||||
}
|
||||
if (ctype_isfp(sct->info)) {
|
||||
r |= sct->size;
|
||||
if (!isu) n++; else if (n == 0) n = 1;
|
||||
if (!isu) n += m; else if (n < m) n = m;
|
||||
} else if (ctype_iscomplex(sct->info)) {
|
||||
r |= (sct->size >> 1);
|
||||
if (!isu) n += 2; else if (n < 2) n = 2;
|
||||
if (!isu) n += 2*m; else if (n < 2*m) n = 2*m;
|
||||
} else if (ctype_isstruct(sct->info)) {
|
||||
goto substruct;
|
||||
} else {
|
||||
@ -803,10 +810,11 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
|
||||
sct = ctype_rawchild(cts, ct);
|
||||
substruct:
|
||||
if (sct->size > 0) {
|
||||
unsigned int s = ccall_classify_struct(cts, sct);
|
||||
unsigned int s = ccall_classify_struct(cts, sct), sn;
|
||||
if (s <= 1) goto noth;
|
||||
r |= (s & 255);
|
||||
if (!isu) n += (s >> 8); else if (n < (s >>8)) n = (s >> 8);
|
||||
sn = (s >> 8) * m;
|
||||
if (!isu) n += sn; else if (n < sn) n = sn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -568,6 +568,44 @@ static void LJ_FASTCALL recff_next(jit_State *J, RecordFFData *rd)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_unpack(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tab = J->base[0], trstart = J->base[1], trend = J->base[2];
|
||||
if (tref_istab(tab) && trstart && trend && tref_isk2(trstart, trend) &&
|
||||
!tref_isnil(trend)) {
|
||||
if (!tref_isnil(trstart))
|
||||
trstart = lj_opt_narrow_toint(J, trstart);
|
||||
trend = lj_opt_narrow_toint(J, trend);
|
||||
if (tref_isk2(trstart, trend)) {
|
||||
uint32_t nu;
|
||||
int32_t start = tref_isnil(trstart) ? 1 : IR(tref_ref(trstart))->i;
|
||||
int32_t end = IR(tref_ref(trend))->i;
|
||||
if (start > end) {
|
||||
rd->nres = 0;
|
||||
return;
|
||||
}
|
||||
nu = (uint32_t)end - (uint32_t)start;
|
||||
/* Check for space for the return values. */
|
||||
if (nu <= INT32_MAX - LJ_MAX_JSLOTS && J->baseslot + nu < LJ_MAX_JSLOTS) {
|
||||
int32_t i, n = (int32_t)(nu+1);
|
||||
RecordIndex ix;
|
||||
ix.tab = tab;
|
||||
settabV(J->L, &ix.tabv, tabV(&rd->argv[0]));
|
||||
ix.val = 0;
|
||||
ix.idxchain = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
ix.key = lj_ir_kint(J, start + i);
|
||||
setintV(&ix.keyv, start + i);
|
||||
J->base[i] = lj_record_idx(J, &ix);
|
||||
}
|
||||
rd->nres = n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
recff_nyiu(J, rd);
|
||||
}
|
||||
|
||||
/* -- Math library fast functions ----------------------------------------- */
|
||||
|
||||
static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
|
||||
|
@ -122,8 +122,9 @@ LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename,
|
||||
copyTV(L, L->top-1, L->top);
|
||||
}
|
||||
if (err) {
|
||||
const char *fname = filename ? filename : "stdin";
|
||||
L->top--;
|
||||
lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(err));
|
||||
lua_pushfstring(L, "cannot read %s: %s", fname, strerror(err));
|
||||
return LUA_ERRFILE;
|
||||
}
|
||||
return status;
|
||||
|
@ -1107,7 +1107,10 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
||||
return 0; /* No metamethod. */
|
||||
}
|
||||
/* The cdata metatable is treated as immutable. */
|
||||
if (LJ_HASFFI && tref_iscdata(ix->tab)) goto immutable_mt;
|
||||
if (LJ_HASFFI && tref_iscdata(ix->tab)) {
|
||||
mix.tab = TREF_NIL;
|
||||
goto immutable_mt;
|
||||
}
|
||||
ix->mt = mix.tab = lj_ir_ggfload(J, IRT_TAB,
|
||||
GG_OFS(g.gcroot[GCROOT_BASEMT+itypemap(&ix->tabv)]));
|
||||
goto nocheck;
|
||||
|
@ -1717,8 +1717,8 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
|.endif
|
||||
|.endmacro
|
||||
|
|
||||
| math_minmax math_min, gt, pl
|
||||
| math_minmax math_max, lt, le
|
||||
| math_minmax math_min, gt, hs
|
||||
| math_minmax math_max, lt, ls
|
||||
|
|
||||
|//-- String library -----------------------------------------------------
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user