Compare commits

..

10 Commits

Author SHA1 Message Date
Mike Pall
659a61693a Merge branch 'master' into v2.1 2026-03-04 11:20:47 +01:00
Mike Pall
89f268b3f7 Fix edge cases when recording string.byte/sub.
Thanks to Sergey Kaplun. #1443
2026-03-04 11:18:28 +01:00
Mike Pall
a553b3de24 Add ffi.abi("dualnum").
Thanks to Sergey Kaplun. #1442
2026-02-27 00:33:30 +01:00
Mike Pall
fc3d17eb40 Merge branch 'master' into v2.1 2026-02-24 22:17:01 +01:00
Mike Pall
02e2999558 FFI: Fix constructor index resolution in JIT compiler.
Reported by Vladimir Davydov and Sergey Kaplun. #1441
2026-02-24 22:13:15 +01:00
Mike Pall
1c3b5a4d72 DUALNUM: Fix recording of loops broken by previous change.
Thanks to Nicholas Davies. #1432 #1433 #1438
2026-02-16 18:00:33 +01:00
Mike Pall
26fd1a7d67 Merge branch 'master' into v2.1 2026-02-13 14:24:23 +01:00
Mike Pall
5db4b03aea Fix compiler warning.
Thanks to Holger Hoffstätte. #1436
2026-02-13 14:21:42 +01:00
Mike Pall
233ad24035 Fix G->jit_base relocation on stack resize.
Reported by f32y. #1435
2026-02-11 23:16:59 +01:00
Mike Pall
54cce2e171 Prevent recording of loops with -0 step or NaN values.
Thanks to Sergey Kaplun. #1432 #1433
2026-02-11 23:14:13 +01:00
7 changed files with 18 additions and 5 deletions

View File

@@ -468,6 +468,8 @@ otherwise. The following parameters are currently defined:
<td class="abiparam">uwp</td><td class="abidesc">Universal Windows Platform</td></tr>
<tr class="even">
<td class="abiparam">gc64</td><td class="abidesc">64 bit GC references</td></tr>
<tr class="odd">
<td class="abiparam">dualnum</td><td class="abidesc">Dual-number mode</td></tr>
</table>
<h3 id="ffi_os"><tt>ffi.os</tt></h3>

View File

@@ -758,6 +758,9 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.)
#endif
#if LJ_GC64
"\004gc64"
#endif
#if LJ_DUALNUM
"\007dualnum"
#endif
) >= 0;
setboolV(L->top-1, b);

View File

@@ -81,7 +81,7 @@ static const char *clib_extname(lua_State *L, const char *name)
/* Check for a recognized ld script line. */
static const char *clib_check_lds(lua_State *L, const char *buf)
{
char *p, *e;
const char *p, *e;
if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) &&
(p = strchr(buf, '('))) {
while (*++p == ' ') ;

View File

@@ -895,6 +895,8 @@ again:
}
J->base[0] = lj_ir_kint(J, (int32_t)fct->size);
return; /* Interpreter will throw for newindex. */
} else if (cd && cd->ctypeid == CTID_CTYPEID) {
/* Only resolve constants and metamethods for constructors. */
} else if (ctype_isbitfield(fct->info)) {
if (ofs)
ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs));

View File

@@ -854,7 +854,7 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
}
trstart = recff_string_start(J, str, &start, trstart, trlen, tr0);
if (rd->data) { /* Return string.sub result. */
if (end - start >= 0) {
if (start <= end) {
/* Also handle empty range here, to avoid extra traces. */
TRef trptr, trslen = emitir(IRTGI(IR_SUBOV), trend, trstart);
emitir(IRTGI(IR_GE), trslen, tr0);
@@ -865,8 +865,8 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
J->base[0] = lj_ir_kstr(J, &J2G(J)->strempty);
}
} else { /* Return string.byte result(s). */
ptrdiff_t i, len = end - start;
if (len > 0) {
if (start < end) {
ptrdiff_t i, len = end - start;
TRef trslen = emitir(IRTGI(IR_SUBOV), trend, trstart);
emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len));
if (J->baseslot + len > LJ_MAX_JSLOTS)

View File

@@ -526,6 +526,12 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
LoopEvent ev;
TRef stop;
IRType t;
/* Avoid semantic mismatches and always failing guards. */
if ((tvisnum(&tv[FORL_IDX]) && tvisnan(&tv[FORL_IDX])) ||
(tvisnum(&tv[FORL_STOP]) && tvisnan(&tv[FORL_STOP])) ||
(tvisnum(&tv[FORL_STEP]) && tvisnan(&tv[FORL_STEP])) ||
tvismzero(&tv[FORL_STEP]))
lj_trace_err(J, LJ_TRERR_GFAIL);
if (isforl) { /* Handle FORL/JFORL opcodes. */
TRef idx = tr[FORL_IDX];
if (mref(J->scev.pc, const BCIns) == fori && tref_ref(idx) == J->scev.idx) {

View File

@@ -72,7 +72,7 @@ static void resizestack(lua_State *L, MSize n)
while (oldsize < realsize) /* Clear new slots. */
setnilV(st + oldsize++);
L->stacksize = realsize;
if ((size_t)(mref(G(L)->jit_base, char) - (char *)oldst) < oldsize)
if ((size_t)(mref(G(L)->jit_base, char) - (char *)oldst) < (size_t)oldsize * sizeof(TValue))
setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta);
L->base = (TValue *)((char *)L->base + delta);
L->top = (TValue *)((char *)L->top + delta);