mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-11 00:44:08 +00:00
Support LJ_GC64 in the IR
This commit is contained in:
parent
6eaffef68d
commit
5a6fbbe0e7
11
src/lj_asm.c
11
src/lj_asm.c
@ -704,6 +704,11 @@ static void ra_left(ASMState *as, Reg dest, IRRef lref)
|
|||||||
} else if (ir->o == IR_KINT64) {
|
} else if (ir->o == IR_KINT64) {
|
||||||
emit_loadk64(as, dest, ir);
|
emit_loadk64(as, dest, ir);
|
||||||
return;
|
return;
|
||||||
|
#if LJ_GC64
|
||||||
|
} else if (ir->o == IR_KGC || ir->o == IR_KPTR || ir->o == IR_KKPTR) {
|
||||||
|
emit_loadk64(as, dest, ir);
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
} else if (ir->o != IR_KPRI) {
|
} else if (ir->o != IR_KPRI) {
|
||||||
lua_assert(ir->o == IR_KINT || ir->o == IR_KGC ||
|
lua_assert(ir->o == IR_KINT || ir->o == IR_KGC ||
|
||||||
@ -1933,7 +1938,7 @@ static void asm_tail_link(ASMState *as)
|
|||||||
emit_addptr(as, RID_BASE, 8*(int32_t)baseslot);
|
emit_addptr(as, RID_BASE, 8*(int32_t)baseslot);
|
||||||
|
|
||||||
if (as->J->ktrace) { /* Patch ktrace slot with the final GCtrace pointer. */
|
if (as->J->ktrace) { /* Patch ktrace slot with the final GCtrace pointer. */
|
||||||
setgcref(IR(as->J->ktrace)->gcr, obj2gco(as->J->curfinal));
|
setgcref(IR(as->J->ktrace)[LJ_GC64].gcr, obj2gco(as->J->curfinal));
|
||||||
IR(as->J->ktrace)->o = IR_KGC;
|
IR(as->J->ktrace)->o = IR_KGC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1965,8 +1970,12 @@ static void asm_setup_regsp(ASMState *as)
|
|||||||
for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) {
|
for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) {
|
||||||
ir->prev = REGSP_INIT;
|
ir->prev = REGSP_INIT;
|
||||||
if (irt_is64(ir->t) && ir->o != IR_KNULL) {
|
if (irt_is64(ir->t) && ir->o != IR_KNULL) {
|
||||||
|
#if LJ_GC64
|
||||||
|
ir->i = 0; /* Will become non-zero if assigned a rip-rel address. */
|
||||||
|
#else
|
||||||
/* Make life easier for backends by putting address of constant in i. */
|
/* Make life easier for backends by putting address of constant in i. */
|
||||||
ir->i = (int32_t)(intptr_t)(ir+1);
|
ir->i = (int32_t)(intptr_t)(ir+1);
|
||||||
|
#endif
|
||||||
ir++;
|
ir++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
src/lj_ir.c
29
src/lj_ir.c
@ -177,6 +177,12 @@ static LJ_AINLINE IRRef ir_nextk64(jit_State *J)
|
|||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LJ_GC64
|
||||||
|
#define ir_nextkgc ir_nextk64
|
||||||
|
#else
|
||||||
|
#define ir_nextkgc ir_nextk
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Intern int32_t constant. */
|
/* Intern int32_t constant. */
|
||||||
TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k)
|
TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k)
|
||||||
{
|
{
|
||||||
@ -260,15 +266,14 @@ TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t)
|
|||||||
{
|
{
|
||||||
IRIns *ir, *cir = J->cur.ir;
|
IRIns *ir, *cir = J->cur.ir;
|
||||||
IRRef ref;
|
IRRef ref;
|
||||||
lua_assert(!LJ_GC64); /* TODO_GC64: major changes required. */
|
|
||||||
lua_assert(!isdead(J2G(J), o));
|
lua_assert(!isdead(J2G(J), o));
|
||||||
for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev)
|
for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev)
|
||||||
if (ir_kgc(&cir[ref]) == o)
|
if (ir_kgc(&cir[ref]) == o)
|
||||||
goto found;
|
goto found;
|
||||||
ref = ir_nextk(J);
|
ref = ir_nextkgc(J);
|
||||||
ir = IR(ref);
|
ir = IR(ref);
|
||||||
/* NOBARRIER: Current trace is a GC root. */
|
/* NOBARRIER: Current trace is a GC root. */
|
||||||
setgcref(ir->gcr, o);
|
setgcref(ir[LJ_GC64].gcr, o);
|
||||||
ir->t.irt = (uint8_t)t;
|
ir->t.irt = (uint8_t)t;
|
||||||
ir->o = IR_KGC;
|
ir->o = IR_KGC;
|
||||||
ir->prev = J->chain[IR_KGC];
|
ir->prev = J->chain[IR_KGC];
|
||||||
@ -280,33 +285,39 @@ found:
|
|||||||
/* Allocate GCtrace constant placeholder (no interning). */
|
/* Allocate GCtrace constant placeholder (no interning). */
|
||||||
TRef lj_ir_ktrace(jit_State *J)
|
TRef lj_ir_ktrace(jit_State *J)
|
||||||
{
|
{
|
||||||
IRRef ref = ir_nextk(J);
|
IRRef ref = ir_nextkgc(J);
|
||||||
IRIns *ir = IR(ref);
|
IRIns *ir = IR(ref);
|
||||||
lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
|
lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
|
||||||
ir->t.irt = IRT_P64;
|
ir->t.irt = IRT_P64;
|
||||||
ir->o = IR_KNULL; /* Not IR_KGC yet, but same size. */
|
ir->o = LJ_GC64 ? IR_KNUM : IR_KNULL; /* Not IR_KGC yet, but same size. */
|
||||||
ir->prev = 0;
|
ir->prev = 0;
|
||||||
return TREF(ref, IRT_P64);
|
return TREF(ref, IRT_P64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Intern 32 bit pointer constant. */
|
/* Intern pointer constant. */
|
||||||
TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr)
|
TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr)
|
||||||
{
|
{
|
||||||
IRIns *ir, *cir = J->cur.ir;
|
IRIns *ir, *cir = J->cur.ir;
|
||||||
IRRef ref;
|
IRRef ref;
|
||||||
|
#if LJ_64 && !LJ_GC64
|
||||||
lua_assert((void *)(uintptr_t)u32ptr(ptr) == ptr);
|
lua_assert((void *)(uintptr_t)u32ptr(ptr) == ptr);
|
||||||
|
#endif
|
||||||
for (ref = J->chain[op]; ref; ref = cir[ref].prev)
|
for (ref = J->chain[op]; ref; ref = cir[ref].prev)
|
||||||
if (ir_kptr(&cir[ref]) == ptr)
|
if (ir_kptr(&cir[ref]) == ptr)
|
||||||
goto found;
|
goto found;
|
||||||
|
#if LJ_GC64
|
||||||
|
ref = ir_nextk64(J);
|
||||||
|
#else
|
||||||
ref = ir_nextk(J);
|
ref = ir_nextk(J);
|
||||||
|
#endif
|
||||||
ir = IR(ref);
|
ir = IR(ref);
|
||||||
setmref(ir->ptr, ptr);
|
setmref(ir[LJ_GC64].ptr, ptr);
|
||||||
ir->t.irt = IRT_P32;
|
ir->t.irt = IRT_PGC;
|
||||||
ir->o = op;
|
ir->o = op;
|
||||||
ir->prev = J->chain[op];
|
ir->prev = J->chain[op];
|
||||||
J->chain[op] = (IRRef1)ref;
|
J->chain[op] = (IRRef1)ref;
|
||||||
found:
|
found:
|
||||||
return TREF(ref, IRT_P32);
|
return TREF(ref, IRT_PGC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Intern typed NULL constant. */
|
/* Intern typed NULL constant. */
|
||||||
|
@ -557,8 +557,7 @@ typedef union IRIns {
|
|||||||
TValue tv; /* TValue constant (overlaps entire slot). */
|
TValue tv; /* TValue constant (overlaps entire slot). */
|
||||||
} IRIns;
|
} IRIns;
|
||||||
|
|
||||||
/* TODO_GC64: major changes required. */
|
#define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)[LJ_GC64].gcr))
|
||||||
#define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr))
|
|
||||||
#define ir_kstr(ir) (gco2str(ir_kgc((ir))))
|
#define ir_kstr(ir) (gco2str(ir_kgc((ir))))
|
||||||
#define ir_ktab(ir) (gco2tab(ir_kgc((ir))))
|
#define ir_ktab(ir) (gco2tab(ir_kgc((ir))))
|
||||||
#define ir_kfunc(ir) (gco2func(ir_kgc((ir))))
|
#define ir_kfunc(ir) (gco2func(ir_kgc((ir))))
|
||||||
@ -568,7 +567,8 @@ typedef union IRIns {
|
|||||||
#define ir_k64(ir) \
|
#define ir_k64(ir) \
|
||||||
check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, &(ir)[1].tv)
|
check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, &(ir)[1].tv)
|
||||||
#define ir_kptr(ir) \
|
#define ir_kptr(ir) \
|
||||||
check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void))
|
check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, \
|
||||||
|
mref((ir)[LJ_GC64].ptr, void))
|
||||||
|
|
||||||
/* A store or any other op with a non-weak guard has a side-effect. */
|
/* A store or any other op with a non-weak guard has a side-effect. */
|
||||||
static LJ_AINLINE int ir_sideeff(IRIns *ir)
|
static LJ_AINLINE int ir_sideeff(IRIns *ir)
|
||||||
|
Loading…
Reference in New Issue
Block a user