aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2025-12-06 08:38:49 +0100
committerMike Pall <mike>2025-12-06 08:38:49 +0100
commit53d014fea828e67110b88ff2e89dd989b395de58 (patch)
tree8078711a3844bb6a78f240299c873f93c596def4 /src
parent6f21cb8ace60b297cd144c3b6925865b043095d2 (diff)
parent406cf69b3ae0a3ecd5ede2bb97b937b7a5d92074 (diff)
downloadluajit-53d014fea828e67110b88ff2e89dd989b395de58.tar.gz
luajit-53d014fea828e67110b88ff2e89dd989b395de58.tar.bz2
luajit-53d014fea828e67110b88ff2e89dd989b395de58.zip
Merge branch 'master' into v2.1
Diffstat (limited to 'src')
-rw-r--r--src/lj_record.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 536d7171..5c0f00d9 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -382,12 +382,27 @@ static TRef fori_load(jit_State *J, BCReg slot, IRType t, int mode)
382 mode + conv); 382 mode + conv);
383} 383}
384 384
385/* Convert FORI argument to expected target type. */
386static TRef fori_conv(jit_State *J, TRef tr, IRType t)
387{
388 if (t == IRT_INT) {
389 if (!tref_isinteger(tr))
390 return emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK);
391 } else {
392 if (!tref_isnum(tr))
393 return emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT);
394 }
395 return tr;
396}
397
385/* Peek before FORI to find a const initializer. Otherwise load from slot. */ 398/* Peek before FORI to find a const initializer. Otherwise load from slot. */
386static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, 399static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot,
387 IRType t, int mode) 400 IRType t, int mode)
388{ 401{
389 TRef tr = J->base[slot]; 402 TRef tr = J->base[slot];
390 if (!tr) { 403 if (tr) {
404 tr = fori_conv(J, tr, t);
405 } else {
391 tr = find_kinit(J, fori, slot, t); 406 tr = find_kinit(J, fori, slot, t);
392 if (!tr) 407 if (!tr)
393 tr = fori_load(J, slot, t, mode); 408 tr = fori_load(J, slot, t, mode);
@@ -534,13 +549,7 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
534 lj_assertJ(tref_isnumber_str(tr[i]), "bad FORI argument type"); 549 lj_assertJ(tref_isnumber_str(tr[i]), "bad FORI argument type");
535 if (tref_isstr(tr[i])) 550 if (tref_isstr(tr[i]))
536 tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0); 551 tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0);
537 if (t == IRT_INT) { 552 tr[i] = fori_conv(J, tr[i], t);
538 if (!tref_isinteger(tr[i]))
539 tr[i] = emitir(IRTGI(IR_CONV), tr[i], IRCONV_INT_NUM|IRCONV_CHECK);
540 } else {
541 if (!tref_isnum(tr[i]))
542 tr[i] = emitir(IRTN(IR_CONV), tr[i], IRCONV_NUM_INT);
543 }
544 } 553 }
545 tr[FORL_EXT] = tr[FORL_IDX]; 554 tr[FORL_EXT] = tr[FORL_IDX];
546 stop = tr[FORL_STOP]; 555 stop = tr[FORL_STOP];