mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
LJ_GC64: Introduce IRT_PGC.
Contributed by Peter Cawley.
This commit is contained in:
parent
475a6ae33f
commit
1931b38da5
@ -1055,7 +1055,7 @@ static void asm_bufhdr(ASMState *as, IRIns *ir)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
|
Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
|
||||||
/* Passing ir isn't strictly correct, but it's an IRT_P32, too. */
|
/* Passing ir isn't strictly correct, but it's an IRT_PGC, too. */
|
||||||
emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p));
|
emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p));
|
||||||
emit_loadofs(as, ir, tmp, sb, offsetof(SBuf, b));
|
emit_loadofs(as, ir, tmp, sb, offsetof(SBuf, b));
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
|
|||||||
/* Emit BUFHDR for the global temporary buffer. */
|
/* Emit BUFHDR for the global temporary buffer. */
|
||||||
static TRef recff_bufhdr(jit_State *J)
|
static TRef recff_bufhdr(jit_State *J)
|
||||||
{
|
{
|
||||||
return emitir(IRT(IR_BUFHDR, IRT_P32),
|
return emitir(IRT(IR_BUFHDR, IRT_PGC),
|
||||||
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd)
|
|||||||
ix.tab = tr;
|
ix.tab = tr;
|
||||||
copyTV(J->L, &ix.tabv, &rd->argv[0]);
|
copyTV(J->L, &ix.tabv, &rd->argv[0]);
|
||||||
lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */
|
lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */
|
||||||
fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META);
|
fref = emitir(IRT(IR_FREF, IRT_PGC), tr, IRFL_TAB_META);
|
||||||
mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt;
|
mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt;
|
||||||
emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref);
|
emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref);
|
||||||
if (!tref_isnil(mt))
|
if (!tref_isnil(mt))
|
||||||
@ -289,7 +289,7 @@ int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv)
|
|||||||
if (strV(tv)->len == 1) {
|
if (strV(tv)->len == 1) {
|
||||||
emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv)));
|
emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv)));
|
||||||
} else {
|
} else {
|
||||||
TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0));
|
TRef trptr = emitir(IRT(IR_STRREF, IRT_PGC), tr, lj_ir_kint(J, 0));
|
||||||
TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY);
|
TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY);
|
||||||
emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#'));
|
emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#'));
|
||||||
}
|
}
|
||||||
@ -814,7 +814,7 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
|
|||||||
/* Also handle empty range here, to avoid extra traces. */
|
/* Also handle empty range here, to avoid extra traces. */
|
||||||
TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart);
|
TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart);
|
||||||
emitir(IRTGI(IR_GE), trslen, tr0);
|
emitir(IRTGI(IR_GE), trslen, tr0);
|
||||||
trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart);
|
trptr = emitir(IRT(IR_STRREF, IRT_PGC), trstr, trstart);
|
||||||
J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen);
|
J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen);
|
||||||
} else { /* Range underflow: return empty string. */
|
} else { /* Range underflow: return empty string. */
|
||||||
emitir(IRTGI(IR_LT), trend, trstart);
|
emitir(IRTGI(IR_LT), trend, trstart);
|
||||||
@ -830,7 +830,7 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
|
|||||||
rd->nres = len;
|
rd->nres = len;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i));
|
TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i));
|
||||||
tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp);
|
tmp = emitir(IRT(IR_STRREF, IRT_PGC), trstr, tmp);
|
||||||
J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY);
|
J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY);
|
||||||
}
|
}
|
||||||
} else { /* Empty range or range underflow: return no results. */
|
} else { /* Empty range or range underflow: return no results. */
|
||||||
@ -852,7 +852,7 @@ static void LJ_FASTCALL recff_string_char(jit_State *J, RecordFFData *rd)
|
|||||||
if (i > 1) { /* Concatenate the strings, if there's more than one. */
|
if (i > 1) { /* Concatenate the strings, if there's more than one. */
|
||||||
TRef hdr = recff_bufhdr(J), tr = hdr;
|
TRef hdr = recff_bufhdr(J), tr = hdr;
|
||||||
for (i = 0; J->base[i] != 0; i++)
|
for (i = 0; J->base[i] != 0; i++)
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, J->base[i]);
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, J->base[i]);
|
||||||
J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
||||||
}
|
}
|
||||||
UNUSED(rd);
|
UNUSED(rd);
|
||||||
@ -869,14 +869,14 @@ static void LJ_FASTCALL recff_string_rep(jit_State *J, RecordFFData *rd)
|
|||||||
emitir(IRTGI(vrep > 1 ? IR_GT : IR_LE), rep, lj_ir_kint(J, 1));
|
emitir(IRTGI(vrep > 1 ? IR_GT : IR_LE), rep, lj_ir_kint(J, 1));
|
||||||
if (vrep > 1) {
|
if (vrep > 1) {
|
||||||
TRef hdr2 = recff_bufhdr(J);
|
TRef hdr2 = recff_bufhdr(J);
|
||||||
TRef tr2 = emitir(IRT(IR_BUFPUT, IRT_P32), hdr2, sep);
|
TRef tr2 = emitir(IRT(IR_BUFPUT, IRT_PGC), hdr2, sep);
|
||||||
tr2 = emitir(IRT(IR_BUFPUT, IRT_P32), tr2, str);
|
tr2 = emitir(IRT(IR_BUFPUT, IRT_PGC), tr2, str);
|
||||||
str2 = emitir(IRT(IR_BUFSTR, IRT_STR), tr2, hdr2);
|
str2 = emitir(IRT(IR_BUFSTR, IRT_STR), tr2, hdr2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tr = hdr = recff_bufhdr(J);
|
tr = hdr = recff_bufhdr(J);
|
||||||
if (str2) {
|
if (str2) {
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, str);
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, str);
|
||||||
str = str2;
|
str = str2;
|
||||||
rep = emitir(IRTI(IR_ADD), rep, lj_ir_kint(J, -1));
|
rep = emitir(IRTI(IR_ADD), rep, lj_ir_kint(J, -1));
|
||||||
}
|
}
|
||||||
@ -927,8 +927,8 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd)
|
|||||||
if ((J->base[2] && tref_istruecond(J->base[3])) ||
|
if ((J->base[2] && tref_istruecond(J->base[3])) ||
|
||||||
(emitir(IRTG(IR_EQ, IRT_STR), trpat, lj_ir_kstr(J, pat)),
|
(emitir(IRTG(IR_EQ, IRT_STR), trpat, lj_ir_kstr(J, pat)),
|
||||||
!lj_str_haspattern(pat))) { /* Search for fixed string. */
|
!lj_str_haspattern(pat))) { /* Search for fixed string. */
|
||||||
TRef trsptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart);
|
TRef trsptr = emitir(IRT(IR_STRREF, IRT_PGC), trstr, trstart);
|
||||||
TRef trpptr = emitir(IRT(IR_STRREF, IRT_P32), trpat, tr0);
|
TRef trpptr = emitir(IRT(IR_STRREF, IRT_PGC), trpat, tr0);
|
||||||
TRef trslen = emitir(IRTI(IR_SUB), trlen, trstart);
|
TRef trslen = emitir(IRTI(IR_SUB), trlen, trstart);
|
||||||
TRef trplen = emitir(IRTI(IR_FLOAD), trpat, IRFL_STR_LEN);
|
TRef trplen = emitir(IRTI(IR_FLOAD), trpat, IRFL_STR_LEN);
|
||||||
TRef tr = lj_ir_call(J, IRCALL_lj_str_find, trsptr, trpptr, trslen, trplen);
|
TRef tr = lj_ir_call(J, IRCALL_lj_str_find, trsptr, trpptr, trslen, trplen);
|
||||||
@ -936,13 +936,13 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd)
|
|||||||
if (lj_str_find(strdata(str)+(MSize)start, strdata(pat),
|
if (lj_str_find(strdata(str)+(MSize)start, strdata(pat),
|
||||||
str->len-(MSize)start, pat->len)) {
|
str->len-(MSize)start, pat->len)) {
|
||||||
TRef pos;
|
TRef pos;
|
||||||
emitir(IRTG(IR_NE, IRT_P32), tr, trp0);
|
emitir(IRTG(IR_NE, IRT_PGC), tr, trp0);
|
||||||
pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_P32), trstr, tr0));
|
pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_PGC), trstr, tr0));
|
||||||
J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1));
|
J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1));
|
||||||
J->base[1] = emitir(IRTI(IR_ADD), pos, trplen);
|
J->base[1] = emitir(IRTI(IR_ADD), pos, trplen);
|
||||||
rd->nres = 2;
|
rd->nres = 2;
|
||||||
} else {
|
} else {
|
||||||
emitir(IRTG(IR_EQ, IRT_P32), tr, trp0);
|
emitir(IRTG(IR_EQ, IRT_PGC), tr, trp0);
|
||||||
J->base[0] = TREF_NIL;
|
J->base[0] = TREF_NIL;
|
||||||
}
|
}
|
||||||
} else { /* Search for pattern. */
|
} else { /* Search for pattern. */
|
||||||
@ -969,7 +969,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
|
|||||||
IRCallID id;
|
IRCallID id;
|
||||||
switch (STRFMT_TYPE(sf)) {
|
switch (STRFMT_TYPE(sf)) {
|
||||||
case STRFMT_LIT:
|
case STRFMT_LIT:
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr,
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
|
||||||
lj_ir_kstr(J, lj_str_new(J->L, fs.str, fs.len)));
|
lj_ir_kstr(J, lj_str_new(J->L, fs.str, fs.len)));
|
||||||
break;
|
break;
|
||||||
case STRFMT_INT:
|
case STRFMT_INT:
|
||||||
@ -978,7 +978,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
|
|||||||
if (!tref_isinteger(tra))
|
if (!tref_isinteger(tra))
|
||||||
goto handle_num;
|
goto handle_num;
|
||||||
if (sf == STRFMT_INT) { /* Shortcut for plain %d. */
|
if (sf == STRFMT_INT) { /* Shortcut for plain %d. */
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr,
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
|
||||||
emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_INT));
|
emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_INT));
|
||||||
} else {
|
} else {
|
||||||
#if LJ_HASFFI
|
#if LJ_HASFFI
|
||||||
@ -1008,7 +1008,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sf == STRFMT_STR) /* Shortcut for plain %s. */
|
if (sf == STRFMT_STR) /* Shortcut for plain %s. */
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, tra);
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, tra);
|
||||||
else if ((sf & STRFMT_T_QUOTED))
|
else if ((sf & STRFMT_T_QUOTED))
|
||||||
tr = lj_ir_call(J, IRCALL_lj_strfmt_putquoted, tr, tra);
|
tr = lj_ir_call(J, IRCALL_lj_strfmt_putquoted, tr, tra);
|
||||||
else
|
else
|
||||||
@ -1017,7 +1017,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
|
|||||||
case STRFMT_CHAR:
|
case STRFMT_CHAR:
|
||||||
tra = lj_opt_narrow_toint(J, tra);
|
tra = lj_opt_narrow_toint(J, tra);
|
||||||
if (sf == STRFMT_CHAR) /* Shortcut for plain %c. */
|
if (sf == STRFMT_CHAR) /* Shortcut for plain %c. */
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr,
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
|
||||||
emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_CHAR));
|
emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_CHAR));
|
||||||
else
|
else
|
||||||
tr = lj_ir_call(J, IRCALL_lj_strfmt_putfchar, tr, trsf, tra);
|
tr = lj_ir_call(J, IRCALL_lj_strfmt_putfchar, tr, trsf, tra);
|
||||||
@ -1125,7 +1125,7 @@ static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd)
|
|||||||
ptrdiff_t i = rd->data == 0 ? 1 : 0;
|
ptrdiff_t i = rd->data == 0 ? 1 : 0;
|
||||||
for (; J->base[i]; i++) {
|
for (; J->base[i]; i++) {
|
||||||
TRef str = lj_ir_tostr(J, J->base[i]);
|
TRef str = lj_ir_tostr(J, J->base[i]);
|
||||||
TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero);
|
TRef buf = emitir(IRT(IR_STRREF, IRT_PGC), str, zero);
|
||||||
TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN);
|
TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN);
|
||||||
if (tref_isk(len) && IR(tref_ref(len))->i == 1) {
|
if (tref_isk(len) && IR(tref_ref(len))->i == 1) {
|
||||||
IRIns *irs = IR(tref_ref(str));
|
IRIns *irs = IR(tref_ref(str));
|
||||||
|
@ -318,9 +318,10 @@ IRTDEF(IRTENUM)
|
|||||||
|
|
||||||
/* Native pointer type and the corresponding integer type. */
|
/* Native pointer type and the corresponding integer type. */
|
||||||
IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32,
|
IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32,
|
||||||
|
IRT_PGC = LJ_GC64 ? IRT_P64 : IRT_P32,
|
||||||
|
IRT_IGC = LJ_GC64 ? IRT_I64 : IRT_INT,
|
||||||
IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT,
|
IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT,
|
||||||
IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32,
|
IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32,
|
||||||
/* TODO_GC64: major changes required for all uses of IRT_P32. */
|
|
||||||
|
|
||||||
/* Additional flags. */
|
/* Additional flags. */
|
||||||
IRT_MARK = 0x20, /* Marker for misc. purposes. */
|
IRT_MARK = 0x20, /* Marker for misc. purposes. */
|
||||||
|
@ -123,39 +123,39 @@ typedef struct CCallInfo {
|
|||||||
/* Function definitions for CALL* instructions. */
|
/* Function definitions for CALL* instructions. */
|
||||||
#define IRCALLDEF(_) \
|
#define IRCALLDEF(_) \
|
||||||
_(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \
|
_(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \
|
||||||
_(ANY, lj_str_find, 4, N, P32, 0) \
|
_(ANY, lj_str_find, 4, N, PGC, 0) \
|
||||||
_(ANY, lj_str_new, 3, S, STR, CCI_L) \
|
_(ANY, lj_str_new, 3, S, STR, CCI_L) \
|
||||||
_(ANY, lj_strscan_num, 2, FN, INT, 0) \
|
_(ANY, lj_strscan_num, 2, FN, INT, 0) \
|
||||||
_(ANY, lj_strfmt_int, 2, FN, STR, CCI_L) \
|
_(ANY, lj_strfmt_int, 2, FN, STR, CCI_L) \
|
||||||
_(ANY, lj_strfmt_num, 2, FN, STR, CCI_L) \
|
_(ANY, lj_strfmt_num, 2, FN, STR, CCI_L) \
|
||||||
_(ANY, lj_strfmt_char, 2, FN, STR, CCI_L) \
|
_(ANY, lj_strfmt_char, 2, FN, STR, CCI_L) \
|
||||||
_(ANY, lj_strfmt_putint, 2, FL, P32, 0) \
|
_(ANY, lj_strfmt_putint, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_strfmt_putnum, 2, FL, P32, 0) \
|
_(ANY, lj_strfmt_putnum, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_strfmt_putquoted, 2, FL, P32, 0) \
|
_(ANY, lj_strfmt_putquoted, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_strfmt_putfxint, 3, L, P32, XA_64) \
|
_(ANY, lj_strfmt_putfxint, 3, L, PGC, XA_64) \
|
||||||
_(ANY, lj_strfmt_putfnum_int, 3, L, P32, XA_FP) \
|
_(ANY, lj_strfmt_putfnum_int, 3, L, PGC, XA_FP) \
|
||||||
_(ANY, lj_strfmt_putfnum_uint, 3, L, P32, XA_FP) \
|
_(ANY, lj_strfmt_putfnum_uint, 3, L, PGC, XA_FP) \
|
||||||
_(ANY, lj_strfmt_putfnum, 3, L, P32, XA_FP) \
|
_(ANY, lj_strfmt_putfnum, 3, L, PGC, XA_FP) \
|
||||||
_(ANY, lj_strfmt_putfstr, 3, L, P32, 0) \
|
_(ANY, lj_strfmt_putfstr, 3, L, PGC, 0) \
|
||||||
_(ANY, lj_strfmt_putfchar, 3, L, P32, 0) \
|
_(ANY, lj_strfmt_putfchar, 3, L, PGC, 0) \
|
||||||
_(ANY, lj_buf_putmem, 3, S, P32, 0) \
|
_(ANY, lj_buf_putmem, 3, S, PGC, 0) \
|
||||||
_(ANY, lj_buf_putstr, 2, FL, P32, 0) \
|
_(ANY, lj_buf_putstr, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_buf_putchar, 2, FL, P32, 0) \
|
_(ANY, lj_buf_putchar, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_buf_putstr_reverse, 2, FL, P32, 0) \
|
_(ANY, lj_buf_putstr_reverse, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_buf_putstr_lower, 2, FL, P32, 0) \
|
_(ANY, lj_buf_putstr_lower, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_buf_putstr_upper, 2, FL, P32, 0) \
|
_(ANY, lj_buf_putstr_upper, 2, FL, PGC, 0) \
|
||||||
_(ANY, lj_buf_putstr_rep, 3, L, P32, 0) \
|
_(ANY, lj_buf_putstr_rep, 3, L, PGC, 0) \
|
||||||
_(ANY, lj_buf_puttab, 5, L, P32, 0) \
|
_(ANY, lj_buf_puttab, 5, L, PGC, 0) \
|
||||||
_(ANY, lj_buf_tostr, 1, FL, STR, 0) \
|
_(ANY, lj_buf_tostr, 1, FL, STR, 0) \
|
||||||
_(ANY, lj_tab_new_ah, 3, A, TAB, CCI_L) \
|
_(ANY, lj_tab_new_ah, 3, A, TAB, CCI_L) \
|
||||||
_(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
|
_(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
|
||||||
_(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \
|
_(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \
|
||||||
_(ANY, lj_tab_clear, 1, FS, NIL, 0) \
|
_(ANY, lj_tab_clear, 1, FS, NIL, 0) \
|
||||||
_(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \
|
_(ANY, lj_tab_newkey, 3, S, PGC, CCI_L) \
|
||||||
_(ANY, lj_tab_len, 1, FL, INT, 0) \
|
_(ANY, lj_tab_len, 1, FL, INT, 0) \
|
||||||
_(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \
|
_(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \
|
||||||
_(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \
|
_(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \
|
||||||
_(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \
|
_(ANY, lj_mem_newgco, 2, FS, PGC, CCI_L) \
|
||||||
_(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64) \
|
_(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64) \
|
||||||
_(ANY, lj_vm_modi, 2, FN, INT, 0) \
|
_(ANY, lj_vm_modi, 2, FN, INT, 0) \
|
||||||
_(ANY, sinh, 1, N, NUM, XA_FP) \
|
_(ANY, sinh, 1, N, NUM, XA_FP) \
|
||||||
|
@ -502,7 +502,7 @@ LJFOLDF(kfold_strref_snew)
|
|||||||
PHIBARRIER(ir);
|
PHIBARRIER(ir);
|
||||||
fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */
|
fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */
|
||||||
fins->op1 = str;
|
fins->op1 = str;
|
||||||
fins->ot = IRT(IR_STRREF, IRT_P32);
|
fins->ot = IRT(IR_STRREF, IRT_PGC);
|
||||||
return RETRYFOLD;
|
return RETRYFOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,8 +643,8 @@ static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr)
|
|||||||
GCproto *pt = funcproto(fn);
|
GCproto *pt = funcproto(fn);
|
||||||
/* Too many closures created? Probably not a monomorphic function. */
|
/* Too many closures created? Probably not a monomorphic function. */
|
||||||
if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
|
if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
|
||||||
TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC);
|
TRef trpt = emitir(IRT(IR_FLOAD, IRT_PGC), tr, IRFL_FUNC_PC);
|
||||||
emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt)));
|
emitir(IRTG(IR_EQ, IRT_PGC), trpt, lj_ir_kptr(J, proto_bc(pt)));
|
||||||
(void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
|
(void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
@ -905,7 +905,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
|||||||
cTValue *mo;
|
cTValue *mo;
|
||||||
if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) {
|
if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) {
|
||||||
/* Specialize to the C library namespace object. */
|
/* Specialize to the C library namespace object. */
|
||||||
emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
|
emitir(IRTG(IR_EQ, IRT_PGC), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
|
||||||
} else {
|
} else {
|
||||||
/* Specialize to the type of userdata. */
|
/* Specialize to the type of userdata. */
|
||||||
TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE);
|
TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE);
|
||||||
@ -1252,8 +1252,8 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
|
|||||||
if ((MSize)k < t->asize) { /* Currently an array key? */
|
if ((MSize)k < t->asize) { /* Currently an array key? */
|
||||||
TRef arrayref;
|
TRef arrayref;
|
||||||
rec_idx_abc(J, asizeref, ikey, t->asize);
|
rec_idx_abc(J, asizeref, ikey, t->asize);
|
||||||
arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY);
|
arrayref = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_ARRAY);
|
||||||
return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey);
|
return emitir(IRT(IR_AREF, IRT_PGC), arrayref, ikey);
|
||||||
} else { /* Currently not in array (may be an array extension)? */
|
} else { /* Currently not in array (may be an array extension)? */
|
||||||
emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */
|
emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */
|
||||||
if (k == 0 && tref_isk(key))
|
if (k == 0 && tref_isk(key))
|
||||||
@ -1293,13 +1293,13 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
|
|||||||
*rbguard = J->guardemit;
|
*rbguard = J->guardemit;
|
||||||
hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
|
hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
|
||||||
emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
|
emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
|
||||||
node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE);
|
node = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_NODE);
|
||||||
kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
|
kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
|
||||||
return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot);
|
return emitir(IRTG(IR_HREFK, IRT_PGC), node, kslot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Fall back to a regular hash lookup. */
|
/* Fall back to a regular hash lookup. */
|
||||||
return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key);
|
return emitir(IRT(IR_HREF, IRT_PGC), ix->tab, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine whether a key is NOT one of the fast metamethod names. */
|
/* Determine whether a key is NOT one of the fast metamethod names. */
|
||||||
@ -1382,7 +1382,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
|||||||
IRType t = itype2irt(oldv);
|
IRType t = itype2irt(oldv);
|
||||||
TRef res;
|
TRef res;
|
||||||
if (oldv == niltvg(J2G(J))) {
|
if (oldv == niltvg(J2G(J))) {
|
||||||
emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
emitir(IRTG(IR_EQ, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||||
res = TREF_NIL;
|
res = TREF_NIL;
|
||||||
} else {
|
} else {
|
||||||
res = emitir(IRTG(loadop, t), xref, 0);
|
res = emitir(IRTG(loadop, t), xref, 0);
|
||||||
@ -1412,7 +1412,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
|||||||
if (hasmm)
|
if (hasmm)
|
||||||
emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */
|
emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */
|
||||||
else if (xrefop == IR_HREF)
|
else if (xrefop == IR_HREF)
|
||||||
emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32),
|
emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PGC),
|
||||||
xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||||
if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) {
|
if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) {
|
||||||
lua_assert(hasmm);
|
lua_assert(hasmm);
|
||||||
@ -1423,7 +1423,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
|||||||
TRef key = ix->key;
|
TRef key = ix->key;
|
||||||
if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
|
if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
|
||||||
key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
|
key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
|
||||||
xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key);
|
xref = emitir(IRT(IR_NEWREF, IRT_PGC), ix->tab, key);
|
||||||
keybarrier = 0; /* NEWREF already takes care of the key barrier. */
|
keybarrier = 0; /* NEWREF already takes care of the key barrier. */
|
||||||
#ifdef LUAJIT_ENABLE_TABLE_BUMP
|
#ifdef LUAJIT_ENABLE_TABLE_BUMP
|
||||||
if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */
|
if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */
|
||||||
@ -1433,7 +1433,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
|||||||
} else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
|
} else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
|
||||||
/* Cannot derive that the previous value was non-nil, must do checks. */
|
/* Cannot derive that the previous value was non-nil, must do checks. */
|
||||||
if (xrefop == IR_HREF) /* Guard against store to niltv. */
|
if (xrefop == IR_HREF) /* Guard against store to niltv. */
|
||||||
emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
emitir(IRTG(IR_NE, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||||
if (ix->idxchain) { /* Metamethod lookup required? */
|
if (ix->idxchain) { /* Metamethod lookup required? */
|
||||||
/* A check for NULL metatable is cheaper (hoistable) than a load. */
|
/* A check for NULL metatable is cheaper (hoistable) than a load. */
|
||||||
if (!mt) {
|
if (!mt) {
|
||||||
@ -1455,7 +1455,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
|||||||
emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
|
emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
|
||||||
/* Invalidate neg. metamethod cache for stores with certain string keys. */
|
/* Invalidate neg. metamethod cache for stores with certain string keys. */
|
||||||
if (!nommstr(J, ix->key)) {
|
if (!nommstr(J, ix->key)) {
|
||||||
TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM);
|
TRef fref = emitir(IRT(IR_FREF, IRT_PGC), ix->tab, IRFL_TAB_NOMM);
|
||||||
emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0));
|
emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0));
|
||||||
}
|
}
|
||||||
J->needsnap = 1;
|
J->needsnap = 1;
|
||||||
@ -1541,15 +1541,15 @@ noconstify:
|
|||||||
/* Note: this effectively limits LJ_MAX_UPVAL to 127. */
|
/* Note: this effectively limits LJ_MAX_UPVAL to 127. */
|
||||||
uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
|
uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
|
||||||
if (!uvp->closed) {
|
if (!uvp->closed) {
|
||||||
uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv));
|
uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_PGC), fn, uv));
|
||||||
/* In current stack? */
|
/* In current stack? */
|
||||||
if (uvval(uvp) >= tvref(J->L->stack) &&
|
if (uvval(uvp) >= tvref(J->L->stack) &&
|
||||||
uvval(uvp) < tvref(J->L->maxstack)) {
|
uvval(uvp) < tvref(J->L->maxstack)) {
|
||||||
int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
|
int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
|
||||||
if (slot >= 0) { /* Aliases an SSA slot? */
|
if (slot >= 0) { /* Aliases an SSA slot? */
|
||||||
emitir(IRTG(IR_EQ, IRT_P32),
|
emitir(IRTG(IR_EQ, IRT_PGC),
|
||||||
REF_BASE,
|
REF_BASE,
|
||||||
emitir(IRT(IR_ADD, IRT_P32), uref,
|
emitir(IRT(IR_ADD, IRT_PGC), uref,
|
||||||
lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8)));
|
lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8)));
|
||||||
slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
|
slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
@ -1561,12 +1561,12 @@ noconstify:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emitir(IRTG(IR_UGT, IRT_P32),
|
emitir(IRTG(IR_UGT, IRT_PGC),
|
||||||
emitir(IRT(IR_SUB, IRT_P32), uref, REF_BASE),
|
emitir(IRT(IR_SUB, IRT_PGC), uref, REF_BASE),
|
||||||
lj_ir_kint(J, (J->baseslot + J->maxslot) * 8));
|
lj_ir_kint(J, (J->baseslot + J->maxslot) * 8));
|
||||||
} else {
|
} else {
|
||||||
needbarrier = 1;
|
needbarrier = 1;
|
||||||
uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv));
|
uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_PGC), fn, uv));
|
||||||
}
|
}
|
||||||
if (val == 0) { /* Upvalue load */
|
if (val == 0) { /* Upvalue load */
|
||||||
IRType t = itype2irt(uvval(uvp));
|
IRType t = itype2irt(uvval(uvp));
|
||||||
@ -1733,11 +1733,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
|
|||||||
else
|
else
|
||||||
emitir(IRTGI(IR_EQ), fr,
|
emitir(IRTGI(IR_EQ), fr,
|
||||||
lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
|
lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
|
||||||
vbase = emitir(IRTI(IR_SUB), REF_BASE, fr);
|
vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
|
||||||
vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8));
|
vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
|
||||||
for (i = 0; i < nload; i++) {
|
for (i = 0; i < nload; i++) {
|
||||||
IRType t = itype2irt(&J->L->base[i-1-nvararg]);
|
IRType t = itype2irt(&J->L->base[i-1-nvararg]);
|
||||||
TRef aref = emitir(IRT(IR_AREF, IRT_P32),
|
TRef aref = emitir(IRT(IR_AREF, IRT_PGC),
|
||||||
vbase, lj_ir_kint(J, (int32_t)i));
|
vbase, lj_ir_kint(J, (int32_t)i));
|
||||||
TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
||||||
if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
|
if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
|
||||||
@ -1783,10 +1783,10 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
|
|||||||
}
|
}
|
||||||
if (idx != 0 && idx <= nvararg) {
|
if (idx != 0 && idx <= nvararg) {
|
||||||
IRType t;
|
IRType t;
|
||||||
TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr);
|
TRef aref, vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
|
||||||
vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8));
|
vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
|
||||||
t = itype2irt(&J->L->base[idx-2-nvararg]);
|
t = itype2irt(&J->L->base[idx-2-nvararg]);
|
||||||
aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx);
|
aref = emitir(IRT(IR_AREF, IRT_PGC), vbase, tridx);
|
||||||
tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
||||||
if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
|
if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
|
||||||
}
|
}
|
||||||
@ -1840,10 +1840,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xbase = ++trp;
|
xbase = ++trp;
|
||||||
tr = hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
|
tr = hdr = emitir(IRT(IR_BUFHDR, IRT_PGC),
|
||||||
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
||||||
do {
|
do {
|
||||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, *trp++);
|
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, *trp++);
|
||||||
} while (trp <= top);
|
} while (trp <= top);
|
||||||
tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
||||||
J->maxslot = (BCReg)(xbase - J->base);
|
J->maxslot = (BCReg)(xbase - J->base);
|
||||||
@ -2481,7 +2481,7 @@ void lj_record_setup(jit_State *J)
|
|||||||
J->bc_extent = ~(MSize)0;
|
J->bc_extent = ~(MSize)0;
|
||||||
|
|
||||||
/* Emit instructions for fixed references. Also triggers initial IR alloc. */
|
/* Emit instructions for fixed references. Also triggers initial IR alloc. */
|
||||||
emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno);
|
emitir_raw(IRT(IR_BASE, IRT_PGC), J->parent, J->exitno);
|
||||||
for (i = 0; i <= 2; i++) {
|
for (i = 0; i <= 2; i++) {
|
||||||
IRIns *ir = IR(REF_NIL-i);
|
IRIns *ir = IR(REF_NIL-i);
|
||||||
ir->i = 0;
|
ir->i = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user