diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h index 420f0ed2..8339367b 100644 --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h @@ -484,6 +484,7 @@ static void asm_retf(ASMState *as, IRIns *ir) int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ /* Need to force a spill on REF_BASE now to update the stack slot. */ emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); emit_setgl(as, base, jit_base); @@ -2088,7 +2089,8 @@ static void asm_head_root_base(ASMState *as) IRIns *ir; asm_head_lreg(as); ir = IR(REF_BASE); - if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); ra_destreg(as, ir, RID_BASE); } @@ -2098,7 +2100,8 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) IRIns *ir; asm_head_lreg(as); ir = IR(REF_BASE); - if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); if (ra_hasspill(irp->s)) { rset_clear(allow, ra_dest(as, ir, allow)); } else { diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h index b45776d4..bc521596 100644 --- a/src/lj_asm_mips.h +++ b/src/lj_asm_mips.h @@ -375,6 +375,7 @@ static void asm_retf(ASMState *as, IRIns *ir) int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guard(as, MIPSI_BNE, RID_TMP, @@ -1697,7 +1698,7 @@ static void asm_head_root_base(ASMState *as) if (as->loopinv) as->mctop--; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_move(as, r, RID_BASE); @@ -1712,7 +1713,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) if (as->loopinv) as->mctop--; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ diff --git a/src/lj_asm_ppc.h b/src/lj_asm_ppc.h index ce5cab10..676bfcbf 100644 --- a/src/lj_asm_ppc.h +++ b/src/lj_asm_ppc.h @@ -362,6 +362,7 @@ static void asm_retf(ASMState *as, IRIns *ir) int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guardcc(as, CC_NE); @@ -1868,7 +1869,7 @@ static void asm_head_root_base(ASMState *as) Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_mr(as, r, RID_BASE); @@ -1882,7 +1883,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index 398d34ef..3e87ba18 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h @@ -638,6 +638,7 @@ static void asm_retf(ASMState *as, IRIns *ir) int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guardcc(as, CC_NE); @@ -2508,7 +2509,7 @@ static void asm_head_root_base(ASMState *as) Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_rr(as, XO_MOV, r, RID_BASE); @@ -2522,7 +2523,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); - if (rset_test(as->modset, r)) + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ diff --git a/src/lj_cparse.c b/src/lj_cparse.c index 05767e61..fd998adc 100644 --- a/src/lj_cparse.c +++ b/src/lj_cparse.c @@ -1244,7 +1244,7 @@ static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr) sinfo |= (info & (CTF_QUAL|CTF_VLA)); /* Merge pseudo-qualifiers. */ /* Check for size overflow and determine alignment. */ - if (sz >= 0x20000000u || bofs + csz < bofs) { + if (sz >= 0x20000000u || bofs + csz < bofs || (info & CTF_VLA)) { if (!(sz == CTSIZE_INVALID && ctype_isarray(info) && !(sinfo & CTF_UNION))) cp_err(cp, LJ_ERR_FFI_INVSIZE); diff --git a/src/lj_record.c b/src/lj_record.c index 650763fe..5bd2d5db 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -764,7 +764,7 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) (J->parent == 0 && J->exitno == 0 && !bc_isret(bc_op(J->cur.startins))))) { /* NYI: specialize to frame type and return directly, not via RET*. */ - for (i = -1; i < (ptrdiff_t)rbase; i++) + for (i = 0; i < (ptrdiff_t)rbase; i++) J->base[i] = 0; /* Purge dead slots. */ J->maxslot = rbase + (BCReg)gotresults; lj_record_stop(J, LJ_TRLINK_RETURN, 0); /* Return to interpreter. */ diff --git a/src/xedkbuild.bat b/src/xedkbuild.bat index adbce8be..240ec878 100644 --- a/src/xedkbuild.bat +++ b/src/xedkbuild.bat @@ -54,8 +54,8 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if errorlevel 1 goto :BAD @rem ---- Cross compiler ---- -@set "LJCOMPILE=%XEDK%\bin\win32\cl /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC" -@set "LJLIB=%XEDK%\bin\win32\lib /nologo" +@set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC +@set LJLIB="%XEDK%\bin\win32\lib" /nologo @set "INCLUDE=%XEDK%\include\xbox" @if "%1" neq "debug" goto :NODEBUG