mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 03:02:49 +02:00
Update LuaJIT to the latest 2.1.0 source (0bee44c)
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#if LJ_HASJIT
|
||||
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_buf.h"
|
||||
#include "lj_ir.h"
|
||||
#include "lj_jit.h"
|
||||
#include "lj_iropt.h"
|
||||
@@ -223,7 +223,7 @@ static void loop_subst_snap(jit_State *J, SnapShot *osnap,
|
||||
}
|
||||
J->guardemit.irt = 0;
|
||||
/* Setup new snapshot. */
|
||||
snap->mapofs = (uint16_t)nmapofs;
|
||||
snap->mapofs = (uint32_t)nmapofs;
|
||||
snap->ref = (IRRef1)J->cur.nins;
|
||||
snap->nslots = nslots;
|
||||
snap->topslot = osnap->topslot;
|
||||
@@ -251,12 +251,19 @@ static void loop_subst_snap(jit_State *J, SnapShot *osnap,
|
||||
nmap += nn;
|
||||
while (omap < nextmap) /* Copy PC + frame links. */
|
||||
*nmap++ = *omap++;
|
||||
J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap);
|
||||
J->cur.nsnapmap = (uint32_t)(nmap - J->cur.snapmap);
|
||||
}
|
||||
|
||||
typedef struct LoopState {
|
||||
jit_State *J;
|
||||
IRRef1 *subst;
|
||||
MSize sizesubst;
|
||||
} LoopState;
|
||||
|
||||
/* Unroll loop. */
|
||||
static void loop_unroll(jit_State *J)
|
||||
static void loop_unroll(LoopState *lps)
|
||||
{
|
||||
jit_State *J = lps->J;
|
||||
IRRef1 phi[LJ_MAX_PHI];
|
||||
uint32_t nphi = 0;
|
||||
IRRef1 *subst;
|
||||
@@ -265,13 +272,13 @@ static void loop_unroll(jit_State *J)
|
||||
SnapEntry *loopmap, *psentinel;
|
||||
IRRef ins, invar;
|
||||
|
||||
/* Use temp buffer for substitution table.
|
||||
/* Allocate substitution table.
|
||||
** Only non-constant refs in [REF_BIAS,invar) are valid indexes.
|
||||
** Caveat: don't call into the VM or run the GC or the buffer may be gone.
|
||||
*/
|
||||
invar = J->cur.nins;
|
||||
subst = (IRRef1 *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf,
|
||||
(invar-REF_BIAS)*sizeof(IRRef1)) - REF_BIAS;
|
||||
lps->sizesubst = invar - REF_BIAS;
|
||||
lps->subst = lj_mem_newvec(J->L, lps->sizesubst, IRRef1);
|
||||
subst = lps->subst - REF_BIAS;
|
||||
subst[REF_BASE] = REF_BASE;
|
||||
|
||||
/* LOOP separates the pre-roll from the loop body. */
|
||||
@@ -362,7 +369,7 @@ static void loop_unroll(jit_State *J)
|
||||
}
|
||||
}
|
||||
if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */
|
||||
J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs;
|
||||
J->cur.nsnapmap = (uint32_t)J->cur.snap[--J->cur.nsnap].mapofs;
|
||||
lua_assert(J->cur.nsnapmap <= J->sizesnapmap);
|
||||
*psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */
|
||||
|
||||
@@ -376,7 +383,7 @@ static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap)
|
||||
SnapShot *snap = &J->cur.snap[nsnap-1];
|
||||
SnapEntry *map = J->cur.snapmap;
|
||||
map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */
|
||||
J->cur.nsnapmap = (uint16_t)nsnapmap;
|
||||
J->cur.nsnapmap = (uint32_t)nsnapmap;
|
||||
J->cur.nsnap = nsnap;
|
||||
J->guardemit.irt = 0;
|
||||
lj_ir_rollback(J, ins);
|
||||
@@ -396,7 +403,7 @@ static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap)
|
||||
static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
UNUSED(L); UNUSED(dummy);
|
||||
loop_unroll((jit_State *)ud);
|
||||
loop_unroll((LoopState *)ud);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -406,7 +413,13 @@ int lj_opt_loop(jit_State *J)
|
||||
IRRef nins = J->cur.nins;
|
||||
SnapNo nsnap = J->cur.nsnap;
|
||||
MSize nsnapmap = J->cur.nsnapmap;
|
||||
int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt);
|
||||
LoopState lps;
|
||||
int errcode;
|
||||
lps.J = J;
|
||||
lps.subst = NULL;
|
||||
lps.sizesubst = 0;
|
||||
errcode = lj_vm_cpcall(J->L, NULL, &lps, cploop_opt);
|
||||
lj_mem_freevec(J2G(J), lps.subst, lps.sizesubst, IRRef1);
|
||||
if (LJ_UNLIKELY(errcode)) {
|
||||
lua_State *L = J->L;
|
||||
if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */
|
||||
|
||||
Reference in New Issue
Block a user