Add IR_FLOAD with REF_NIL for field loads from GG_State.
Contributed by Peter Cawley.
This commit is contained in:
parent
cfa188f134
commit
786dbb2ebd
@ -162,8 +162,8 @@ lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \
|
||||
lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h
|
||||
lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_buf.h lj_gc.h lj_str.h lj_ir.h \
|
||||
lj_jit.h lj_ircall.h lj_iropt.h lj_vm.h
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_buf.h lj_gc.h lj_str.h lj_dispatch.h \
|
||||
lj_bc.h lj_jit.h lj_ir.h lj_ircall.h lj_iropt.h lj_vm.h
|
||||
lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_buf.h lj_str.h lj_tab.h \
|
||||
lj_func.h lj_state.h lj_bc.h lj_ctype.h lj_strfmt.h lj_lex.h lj_parse.h \
|
||||
|
@ -997,22 +997,26 @@ static ARMIns asm_fxstoreins(IRIns *ir)
|
||||
|
||||
static void asm_fload(ASMState *as, IRIns *ir)
|
||||
{
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
ARMIns ai = asm_fxloadins(ir);
|
||||
int32_t ofs;
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx);
|
||||
return;
|
||||
if (ir->op1 == REF_NIL) {
|
||||
lua_assert(!ra_used(ir)); /* We can end up here if DCE is turned off. */
|
||||
} else {
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
ARMIns ai = asm_fxloadins(ir);
|
||||
int32_t ofs;
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
if ((ai & 0x04000000))
|
||||
emit_lso(as, ai, dest, idx, ofs);
|
||||
else
|
||||
emit_lsox(as, ai, dest, idx, ofs);
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
if ((ai & 0x04000000))
|
||||
emit_lso(as, ai, dest, idx, ofs);
|
||||
else
|
||||
emit_lsox(as, ai, dest, idx, ofs);
|
||||
}
|
||||
|
||||
static void asm_fstore(ASMState *as, IRIns *ir)
|
||||
|
@ -896,17 +896,23 @@ static MIPSIns asm_fxstoreins(IRIns *ir)
|
||||
static void asm_fload(ASMState *as, IRIns *ir)
|
||||
{
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
MIPSIns mi = asm_fxloadins(ir);
|
||||
Reg idx;
|
||||
int32_t ofs;
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs);
|
||||
return;
|
||||
if (ir->op1 == REF_NIL) {
|
||||
idx = RID_JGL;
|
||||
ofs = ir->op2 - 32768;
|
||||
} else {
|
||||
idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
lua_assert(!irt_isfp(ir->t));
|
||||
emit_tsi(as, mi, dest, idx, ofs);
|
||||
}
|
||||
|
@ -804,17 +804,23 @@ static PPCIns asm_fxstoreins(IRIns *ir)
|
||||
static void asm_fload(ASMState *as, IRIns *ir)
|
||||
{
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
PPCIns pi = asm_fxloadins(ir);
|
||||
Reg idx;
|
||||
int32_t ofs;
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_tai(as, PPCI_ADDI, dest, idx, ofs);
|
||||
return;
|
||||
if (ir->op1 == REF_NIL) {
|
||||
idx = RID_JGL;
|
||||
ofs = ir->op2 - 32768;
|
||||
} else {
|
||||
idx = ra_alloc1(as, ir->op1, RSET_GPR);
|
||||
if (ir->op2 == IRFL_TAB_ARRAY) {
|
||||
ofs = asm_fuseabase(as, ir->op1);
|
||||
if (ofs) { /* Turn the t->array load into an add for colocated arrays. */
|
||||
emit_tai(as, PPCI_ADDI, dest, idx, ofs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
}
|
||||
ofs = field_ofs[ir->op2];
|
||||
lua_assert(!irt_isi8(ir->t));
|
||||
emit_tai(as, pi, dest, idx, ofs);
|
||||
}
|
||||
|
@ -205,8 +205,13 @@ static void asm_fuseahuref(ASMState *as, IRRef ref, RegSet allow)
|
||||
static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow)
|
||||
{
|
||||
lua_assert(ir->o == IR_FLOAD || ir->o == IR_FREF);
|
||||
as->mrm.ofs = field_ofs[ir->op2];
|
||||
as->mrm.idx = RID_NONE;
|
||||
if (ir->op1 == REF_NIL) {
|
||||
as->mrm.ofs = (int32_t)ir->op2 + ptr2addr(J2GG(as->J));
|
||||
as->mrm.base = RID_NONE;
|
||||
return;
|
||||
}
|
||||
as->mrm.ofs = field_ofs[ir->op2];
|
||||
if (irref_isk(ir->op1)) {
|
||||
as->mrm.ofs += IR(ir->op1)->i;
|
||||
as->mrm.base = RID_NONE;
|
||||
@ -369,6 +374,10 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
|
||||
return RID_MRM;
|
||||
}
|
||||
}
|
||||
if (ir->o == IR_FLOAD && ir->op1 == REF_NIL) {
|
||||
asm_fusefref(as, ir, RSET_EMPTY);
|
||||
return RID_MRM;
|
||||
}
|
||||
if (!(as->freeset & allow) && !irref_isk(ref) &&
|
||||
(allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref)))
|
||||
goto fusespill;
|
||||
|
@ -145,6 +145,14 @@ TRef lj_ir_call(jit_State *J, IRCallID id, ...)
|
||||
return emitir(CCI_OPTYPE(ci), tr, id);
|
||||
}
|
||||
|
||||
/* Load field of type t from GG_State + offset. */
|
||||
LJ_FUNC TRef lj_ir_ggfload(jit_State *J, IRType t, uintptr_t ofs)
|
||||
{
|
||||
lua_assert(ofs >= IRFL__MAX && ofs < REF_BIAS);
|
||||
lj_ir_set(J, IRT(IR_FLOAD, t), REF_NIL, ofs);
|
||||
return lj_opt_fold(J);
|
||||
}
|
||||
|
||||
/* -- Interning of constants ---------------------------------------------- */
|
||||
|
||||
/*
|
||||
|
@ -36,6 +36,8 @@ static LJ_AINLINE IRRef lj_ir_nextins(jit_State *J)
|
||||
return ref;
|
||||
}
|
||||
|
||||
LJ_FUNC TRef lj_ir_ggfload(jit_State *J, IRType t, uintptr_t ofs);
|
||||
|
||||
/* Interning of constants. */
|
||||
LJ_FUNC TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k);
|
||||
LJ_FUNC void lj_ir_k64_freeall(jit_State *J);
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "lj_err.h"
|
||||
#include "lj_buf.h"
|
||||
#include "lj_dispatch.h"
|
||||
#include "lj_ir.h"
|
||||
#include "lj_jit.h"
|
||||
#include "lj_ircall.h"
|
||||
@ -448,6 +449,11 @@ static void split_ir(jit_State *J)
|
||||
case IR_STRTO:
|
||||
hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref);
|
||||
break;
|
||||
case IR_FLOAD:
|
||||
lua_assert(ir->op1 == REF_NIL);
|
||||
hi = lj_ir_kint(J, *(int32_t*)((char*)J2GG(J) + ir->op2 + LJ_LE*4));
|
||||
nir->op2 += LJ_BE*4;
|
||||
break;
|
||||
case IR_XLOAD: {
|
||||
IRIns inslo = *nir; /* Save/undo the emit of the lo XLOAD. */
|
||||
J->cur.nins--;
|
||||
|
Loading…
Reference in New Issue
Block a user