aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2016-05-20 22:41:42 +0200
committerMike Pall <mike>2016-05-20 22:41:42 +0200
commit1931b38da5a9ea075df73a966630308d3988bb96 (patch)
tree3b6d014f6256a78eb2fd270489b8d7dd2183e01e
parent475a6ae33fc4b28d4c1c7a5f663ea933e0ccbdfd (diff)
downloadluajit-1931b38da5a9ea075df73a966630308d3988bb96.tar.gz
luajit-1931b38da5a9ea075df73a966630308d3988bb96.tar.bz2
luajit-1931b38da5a9ea075df73a966630308d3988bb96.zip
LJ_GC64: Introduce IRT_PGC.
Contributed by Peter Cawley.
-rw-r--r--src/lj_asm.c2
-rw-r--r--src/lj_ffrecord.c38
-rw-r--r--src/lj_ir.h3
-rw-r--r--src/lj_ircall.h40
-rw-r--r--src/lj_opt_fold.c2
-rw-r--r--src/lj_record.c56
6 files changed, 71 insertions, 70 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 94d7bfc4..9cddd0c9 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1055,7 +1055,7 @@ static void asm_bufhdr(ASMState *as, IRIns *ir)
1055 } 1055 }
1056 } else { 1056 } else {
1057 Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb)); 1057 Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
1058 /* Passing ir isn't strictly correct, but it's an IRT_P32, too. */ 1058 /* Passing ir isn't strictly correct, but it's an IRT_PGC, too. */
1059 emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p)); 1059 emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p));
1060 emit_loadofs(as, ir, tmp, sb, offsetof(SBuf, b)); 1060 emit_loadofs(as, ir, tmp, sb, offsetof(SBuf, b));
1061 } 1061 }
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index 942ecdb2..56497778 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -173,7 +173,7 @@ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
173/* Emit BUFHDR for the global temporary buffer. */ 173/* Emit BUFHDR for the global temporary buffer. */
174static TRef recff_bufhdr(jit_State *J) 174static TRef recff_bufhdr(jit_State *J)
175{ 175{
176 return emitir(IRT(IR_BUFHDR, IRT_P32), 176 return emitir(IRT(IR_BUFHDR, IRT_PGC),
177 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET); 177 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
178} 178}
179 179
@@ -223,7 +223,7 @@ static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd)
223 ix.tab = tr; 223 ix.tab = tr;
224 copyTV(J->L, &ix.tabv, &rd->argv[0]); 224 copyTV(J->L, &ix.tabv, &rd->argv[0]);
225 lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */ 225 lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */
226 fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META); 226 fref = emitir(IRT(IR_FREF, IRT_PGC), tr, IRFL_TAB_META);
227 mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt; 227 mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt;
228 emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref); 228 emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref);
229 if (!tref_isnil(mt)) 229 if (!tref_isnil(mt))
@@ -289,7 +289,7 @@ int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv)
289 if (strV(tv)->len == 1) { 289 if (strV(tv)->len == 1) {
290 emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv))); 290 emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv)));
291 } else { 291 } else {
292 TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0)); 292 TRef trptr = emitir(IRT(IR_STRREF, IRT_PGC), tr, lj_ir_kint(J, 0));
293 TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY); 293 TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY);
294 emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#')); 294 emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#'));
295 } 295 }
@@ -814,7 +814,7 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
814 /* Also handle empty range here, to avoid extra traces. */ 814 /* Also handle empty range here, to avoid extra traces. */
815 TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart); 815 TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart);
816 emitir(IRTGI(IR_GE), trslen, tr0); 816 emitir(IRTGI(IR_GE), trslen, tr0);
817 trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); 817 trptr = emitir(IRT(IR_STRREF, IRT_PGC), trstr, trstart);
818 J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen); 818 J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen);
819 } else { /* Range underflow: return empty string. */ 819 } else { /* Range underflow: return empty string. */
820 emitir(IRTGI(IR_LT), trend, trstart); 820 emitir(IRTGI(IR_LT), trend, trstart);
@@ -830,7 +830,7 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
830 rd->nres = len; 830 rd->nres = len;
831 for (i = 0; i < len; i++) { 831 for (i = 0; i < len; i++) {
832 TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i)); 832 TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i));
833 tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp); 833 tmp = emitir(IRT(IR_STRREF, IRT_PGC), trstr, tmp);
834 J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY); 834 J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY);
835 } 835 }
836 } else { /* Empty range or range underflow: return no results. */ 836 } 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)
852 if (i > 1) { /* Concatenate the strings, if there's more than one. */ 852 if (i > 1) { /* Concatenate the strings, if there's more than one. */
853 TRef hdr = recff_bufhdr(J), tr = hdr; 853 TRef hdr = recff_bufhdr(J), tr = hdr;
854 for (i = 0; J->base[i] != 0; i++) 854 for (i = 0; J->base[i] != 0; i++)
855 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, J->base[i]); 855 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, J->base[i]);
856 J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr); 856 J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
857 } 857 }
858 UNUSED(rd); 858 UNUSED(rd);
@@ -869,14 +869,14 @@ static void LJ_FASTCALL recff_string_rep(jit_State *J, RecordFFData *rd)
869 emitir(IRTGI(vrep > 1 ? IR_GT : IR_LE), rep, lj_ir_kint(J, 1)); 869 emitir(IRTGI(vrep > 1 ? IR_GT : IR_LE), rep, lj_ir_kint(J, 1));
870 if (vrep > 1) { 870 if (vrep > 1) {
871 TRef hdr2 = recff_bufhdr(J); 871 TRef hdr2 = recff_bufhdr(J);
872 TRef tr2 = emitir(IRT(IR_BUFPUT, IRT_P32), hdr2, sep); 872 TRef tr2 = emitir(IRT(IR_BUFPUT, IRT_PGC), hdr2, sep);
873 tr2 = emitir(IRT(IR_BUFPUT, IRT_P32), tr2, str); 873 tr2 = emitir(IRT(IR_BUFPUT, IRT_PGC), tr2, str);
874 str2 = emitir(IRT(IR_BUFSTR, IRT_STR), tr2, hdr2); 874 str2 = emitir(IRT(IR_BUFSTR, IRT_STR), tr2, hdr2);
875 } 875 }
876 } 876 }
877 tr = hdr = recff_bufhdr(J); 877 tr = hdr = recff_bufhdr(J);
878 if (str2) { 878 if (str2) {
879 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, str); 879 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, str);
880 str = str2; 880 str = str2;
881 rep = emitir(IRTI(IR_ADD), rep, lj_ir_kint(J, -1)); 881 rep = emitir(IRTI(IR_ADD), rep, lj_ir_kint(J, -1));
882 } 882 }
@@ -927,8 +927,8 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd)
927 if ((J->base[2] && tref_istruecond(J->base[3])) || 927 if ((J->base[2] && tref_istruecond(J->base[3])) ||
928 (emitir(IRTG(IR_EQ, IRT_STR), trpat, lj_ir_kstr(J, pat)), 928 (emitir(IRTG(IR_EQ, IRT_STR), trpat, lj_ir_kstr(J, pat)),
929 !lj_str_haspattern(pat))) { /* Search for fixed string. */ 929 !lj_str_haspattern(pat))) { /* Search for fixed string. */
930 TRef trsptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); 930 TRef trsptr = emitir(IRT(IR_STRREF, IRT_PGC), trstr, trstart);
931 TRef trpptr = emitir(IRT(IR_STRREF, IRT_P32), trpat, tr0); 931 TRef trpptr = emitir(IRT(IR_STRREF, IRT_PGC), trpat, tr0);
932 TRef trslen = emitir(IRTI(IR_SUB), trlen, trstart); 932 TRef trslen = emitir(IRTI(IR_SUB), trlen, trstart);
933 TRef trplen = emitir(IRTI(IR_FLOAD), trpat, IRFL_STR_LEN); 933 TRef trplen = emitir(IRTI(IR_FLOAD), trpat, IRFL_STR_LEN);
934 TRef tr = lj_ir_call(J, IRCALL_lj_str_find, trsptr, trpptr, trslen, trplen); 934 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)
936 if (lj_str_find(strdata(str)+(MSize)start, strdata(pat), 936 if (lj_str_find(strdata(str)+(MSize)start, strdata(pat),
937 str->len-(MSize)start, pat->len)) { 937 str->len-(MSize)start, pat->len)) {
938 TRef pos; 938 TRef pos;
939 emitir(IRTG(IR_NE, IRT_P32), tr, trp0); 939 emitir(IRTG(IR_NE, IRT_PGC), tr, trp0);
940 pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_P32), trstr, tr0)); 940 pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_PGC), trstr, tr0));
941 J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1)); 941 J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1));
942 J->base[1] = emitir(IRTI(IR_ADD), pos, trplen); 942 J->base[1] = emitir(IRTI(IR_ADD), pos, trplen);
943 rd->nres = 2; 943 rd->nres = 2;
944 } else { 944 } else {
945 emitir(IRTG(IR_EQ, IRT_P32), tr, trp0); 945 emitir(IRTG(IR_EQ, IRT_PGC), tr, trp0);
946 J->base[0] = TREF_NIL; 946 J->base[0] = TREF_NIL;
947 } 947 }
948 } else { /* Search for pattern. */ 948 } else { /* Search for pattern. */
@@ -969,7 +969,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
969 IRCallID id; 969 IRCallID id;
970 switch (STRFMT_TYPE(sf)) { 970 switch (STRFMT_TYPE(sf)) {
971 case STRFMT_LIT: 971 case STRFMT_LIT:
972 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, 972 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
973 lj_ir_kstr(J, lj_str_new(J->L, fs.str, fs.len))); 973 lj_ir_kstr(J, lj_str_new(J->L, fs.str, fs.len)));
974 break; 974 break;
975 case STRFMT_INT: 975 case STRFMT_INT:
@@ -978,7 +978,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
978 if (!tref_isinteger(tra)) 978 if (!tref_isinteger(tra))
979 goto handle_num; 979 goto handle_num;
980 if (sf == STRFMT_INT) { /* Shortcut for plain %d. */ 980 if (sf == STRFMT_INT) { /* Shortcut for plain %d. */
981 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, 981 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
982 emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_INT)); 982 emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_INT));
983 } else { 983 } else {
984#if LJ_HASFFI 984#if LJ_HASFFI
@@ -1008,7 +1008,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
1008 return; 1008 return;
1009 } 1009 }
1010 if (sf == STRFMT_STR) /* Shortcut for plain %s. */ 1010 if (sf == STRFMT_STR) /* Shortcut for plain %s. */
1011 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, tra); 1011 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, tra);
1012 else if ((sf & STRFMT_T_QUOTED)) 1012 else if ((sf & STRFMT_T_QUOTED))
1013 tr = lj_ir_call(J, IRCALL_lj_strfmt_putquoted, tr, tra); 1013 tr = lj_ir_call(J, IRCALL_lj_strfmt_putquoted, tr, tra);
1014 else 1014 else
@@ -1017,7 +1017,7 @@ static void LJ_FASTCALL recff_string_format(jit_State *J, RecordFFData *rd)
1017 case STRFMT_CHAR: 1017 case STRFMT_CHAR:
1018 tra = lj_opt_narrow_toint(J, tra); 1018 tra = lj_opt_narrow_toint(J, tra);
1019 if (sf == STRFMT_CHAR) /* Shortcut for plain %c. */ 1019 if (sf == STRFMT_CHAR) /* Shortcut for plain %c. */
1020 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, 1020 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr,
1021 emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_CHAR)); 1021 emitir(IRT(IR_TOSTR, IRT_STR), tra, IRTOSTR_CHAR));
1022 else 1022 else
1023 tr = lj_ir_call(J, IRCALL_lj_strfmt_putfchar, tr, trsf, tra); 1023 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)
1125 ptrdiff_t i = rd->data == 0 ? 1 : 0; 1125 ptrdiff_t i = rd->data == 0 ? 1 : 0;
1126 for (; J->base[i]; i++) { 1126 for (; J->base[i]; i++) {
1127 TRef str = lj_ir_tostr(J, J->base[i]); 1127 TRef str = lj_ir_tostr(J, J->base[i]);
1128 TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero); 1128 TRef buf = emitir(IRT(IR_STRREF, IRT_PGC), str, zero);
1129 TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN); 1129 TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN);
1130 if (tref_isk(len) && IR(tref_ref(len))->i == 1) { 1130 if (tref_isk(len) && IR(tref_ref(len))->i == 1) {
1131 IRIns *irs = IR(tref_ref(str)); 1131 IRIns *irs = IR(tref_ref(str));
diff --git a/src/lj_ir.h b/src/lj_ir.h
index cd8df59d..8a655b64 100644
--- a/src/lj_ir.h
+++ b/src/lj_ir.h
@@ -318,9 +318,10 @@ IRTDEF(IRTENUM)
318 318
319 /* Native pointer type and the corresponding integer type. */ 319 /* Native pointer type and the corresponding integer type. */
320 IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, 320 IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32,
321 IRT_PGC = LJ_GC64 ? IRT_P64 : IRT_P32,
322 IRT_IGC = LJ_GC64 ? IRT_I64 : IRT_INT,
321 IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, 323 IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT,
322 IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, 324 IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32,
323 /* TODO_GC64: major changes required for all uses of IRT_P32. */
324 325
325 /* Additional flags. */ 326 /* Additional flags. */
326 IRT_MARK = 0x20, /* Marker for misc. purposes. */ 327 IRT_MARK = 0x20, /* Marker for misc. purposes. */
diff --git a/src/lj_ircall.h b/src/lj_ircall.h
index aa625915..f2a6ecec 100644
--- a/src/lj_ircall.h
+++ b/src/lj_ircall.h
@@ -123,39 +123,39 @@ typedef struct CCallInfo {
123/* Function definitions for CALL* instructions. */ 123/* Function definitions for CALL* instructions. */
124#define IRCALLDEF(_) \ 124#define IRCALLDEF(_) \
125 _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ 125 _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \
126 _(ANY, lj_str_find, 4, N, P32, 0) \ 126 _(ANY, lj_str_find, 4, N, PGC, 0) \
127 _(ANY, lj_str_new, 3, S, STR, CCI_L) \ 127 _(ANY, lj_str_new, 3, S, STR, CCI_L) \
128 _(ANY, lj_strscan_num, 2, FN, INT, 0) \ 128 _(ANY, lj_strscan_num, 2, FN, INT, 0) \
129 _(ANY, lj_strfmt_int, 2, FN, STR, CCI_L) \ 129 _(ANY, lj_strfmt_int, 2, FN, STR, CCI_L) \
130 _(ANY, lj_strfmt_num, 2, FN, STR, CCI_L) \ 130 _(ANY, lj_strfmt_num, 2, FN, STR, CCI_L) \
131 _(ANY, lj_strfmt_char, 2, FN, STR, CCI_L) \ 131 _(ANY, lj_strfmt_char, 2, FN, STR, CCI_L) \
132 _(ANY, lj_strfmt_putint, 2, FL, P32, 0) \ 132 _(ANY, lj_strfmt_putint, 2, FL, PGC, 0) \
133 _(ANY, lj_strfmt_putnum, 2, FL, P32, 0) \ 133 _(ANY, lj_strfmt_putnum, 2, FL, PGC, 0) \
134 _(ANY, lj_strfmt_putquoted, 2, FL, P32, 0) \ 134 _(ANY, lj_strfmt_putquoted, 2, FL, PGC, 0) \
135 _(ANY, lj_strfmt_putfxint, 3, L, P32, XA_64) \ 135 _(ANY, lj_strfmt_putfxint, 3, L, PGC, XA_64) \
136 _(ANY, lj_strfmt_putfnum_int, 3, L, P32, XA_FP) \ 136 _(ANY, lj_strfmt_putfnum_int, 3, L, PGC, XA_FP) \
137 _(ANY, lj_strfmt_putfnum_uint, 3, L, P32, XA_FP) \ 137 _(ANY, lj_strfmt_putfnum_uint, 3, L, PGC, XA_FP) \
138 _(ANY, lj_strfmt_putfnum, 3, L, P32, XA_FP) \ 138 _(ANY, lj_strfmt_putfnum, 3, L, PGC, XA_FP) \
139 _(ANY, lj_strfmt_putfstr, 3, L, P32, 0) \ 139 _(ANY, lj_strfmt_putfstr, 3, L, PGC, 0) \
140 _(ANY, lj_strfmt_putfchar, 3, L, P32, 0) \ 140 _(ANY, lj_strfmt_putfchar, 3, L, PGC, 0) \
141 _(ANY, lj_buf_putmem, 3, S, P32, 0) \ 141 _(ANY, lj_buf_putmem, 3, S, PGC, 0) \
142 _(ANY, lj_buf_putstr, 2, FL, P32, 0) \ 142 _(ANY, lj_buf_putstr, 2, FL, PGC, 0) \
143 _(ANY, lj_buf_putchar, 2, FL, P32, 0) \ 143 _(ANY, lj_buf_putchar, 2, FL, PGC, 0) \
144 _(ANY, lj_buf_putstr_reverse, 2, FL, P32, 0) \ 144 _(ANY, lj_buf_putstr_reverse, 2, FL, PGC, 0) \
145 _(ANY, lj_buf_putstr_lower, 2, FL, P32, 0) \ 145 _(ANY, lj_buf_putstr_lower, 2, FL, PGC, 0) \
146 _(ANY, lj_buf_putstr_upper, 2, FL, P32, 0) \ 146 _(ANY, lj_buf_putstr_upper, 2, FL, PGC, 0) \
147 _(ANY, lj_buf_putstr_rep, 3, L, P32, 0) \ 147 _(ANY, lj_buf_putstr_rep, 3, L, PGC, 0) \
148 _(ANY, lj_buf_puttab, 5, L, P32, 0) \ 148 _(ANY, lj_buf_puttab, 5, L, PGC, 0) \
149 _(ANY, lj_buf_tostr, 1, FL, STR, 0) \ 149 _(ANY, lj_buf_tostr, 1, FL, STR, 0) \
150 _(ANY, lj_tab_new_ah, 3, A, TAB, CCI_L) \ 150 _(ANY, lj_tab_new_ah, 3, A, TAB, CCI_L) \
151 _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ 151 _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
152 _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ 152 _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \
153 _(ANY, lj_tab_clear, 1, FS, NIL, 0) \ 153 _(ANY, lj_tab_clear, 1, FS, NIL, 0) \
154 _(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \ 154 _(ANY, lj_tab_newkey, 3, S, PGC, CCI_L) \
155 _(ANY, lj_tab_len, 1, FL, INT, 0) \ 155 _(ANY, lj_tab_len, 1, FL, INT, 0) \
156 _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \ 156 _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \
157 _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \ 157 _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \
158 _(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \ 158 _(ANY, lj_mem_newgco, 2, FS, PGC, CCI_L) \
159 _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64) \ 159 _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64) \
160 _(ANY, lj_vm_modi, 2, FN, INT, 0) \ 160 _(ANY, lj_vm_modi, 2, FN, INT, 0) \
161 _(ANY, sinh, 1, N, NUM, XA_FP) \ 161 _(ANY, sinh, 1, N, NUM, XA_FP) \
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c
index e1d13691..95b58a1a 100644
--- a/src/lj_opt_fold.c
+++ b/src/lj_opt_fold.c
@@ -502,7 +502,7 @@ LJFOLDF(kfold_strref_snew)
502 PHIBARRIER(ir); 502 PHIBARRIER(ir);
503 fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */ 503 fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */
504 fins->op1 = str; 504 fins->op1 = str;
505 fins->ot = IRT(IR_STRREF, IRT_P32); 505 fins->ot = IRT(IR_STRREF, IRT_PGC);
506 return RETRYFOLD; 506 return RETRYFOLD;
507 } 507 }
508 } 508 }
diff --git a/src/lj_record.c b/src/lj_record.c
index 568b73aa..f7c53567 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -643,8 +643,8 @@ static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr)
643 GCproto *pt = funcproto(fn); 643 GCproto *pt = funcproto(fn);
644 /* Too many closures created? Probably not a monomorphic function. */ 644 /* Too many closures created? Probably not a monomorphic function. */
645 if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ 645 if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
646 TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); 646 TRef trpt = emitir(IRT(IR_FLOAD, IRT_PGC), tr, IRFL_FUNC_PC);
647 emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); 647 emitir(IRTG(IR_EQ, IRT_PGC), trpt, lj_ir_kptr(J, proto_bc(pt)));
648 (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ 648 (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
649 return tr; 649 return tr;
650 } 650 }
@@ -905,7 +905,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
905 cTValue *mo; 905 cTValue *mo;
906 if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { 906 if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) {
907 /* Specialize to the C library namespace object. */ 907 /* Specialize to the C library namespace object. */
908 emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); 908 emitir(IRTG(IR_EQ, IRT_PGC), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
909 } else { 909 } else {
910 /* Specialize to the type of userdata. */ 910 /* Specialize to the type of userdata. */
911 TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); 911 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,
1252 if ((MSize)k < t->asize) { /* Currently an array key? */ 1252 if ((MSize)k < t->asize) { /* Currently an array key? */
1253 TRef arrayref; 1253 TRef arrayref;
1254 rec_idx_abc(J, asizeref, ikey, t->asize); 1254 rec_idx_abc(J, asizeref, ikey, t->asize);
1255 arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); 1255 arrayref = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_ARRAY);
1256 return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); 1256 return emitir(IRT(IR_AREF, IRT_PGC), arrayref, ikey);
1257 } else { /* Currently not in array (may be an array extension)? */ 1257 } else { /* Currently not in array (may be an array extension)? */
1258 emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ 1258 emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */
1259 if (k == 0 && tref_isk(key)) 1259 if (k == 0 && tref_isk(key))
@@ -1293,13 +1293,13 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
1293 *rbguard = J->guardemit; 1293 *rbguard = J->guardemit;
1294 hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); 1294 hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
1295 emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); 1295 emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
1296 node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); 1296 node = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_NODE);
1297 kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); 1297 kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
1298 return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); 1298 return emitir(IRTG(IR_HREFK, IRT_PGC), node, kslot);
1299 } 1299 }
1300 } 1300 }
1301 /* Fall back to a regular hash lookup. */ 1301 /* Fall back to a regular hash lookup. */
1302 return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); 1302 return emitir(IRT(IR_HREF, IRT_PGC), ix->tab, key);
1303} 1303}
1304 1304
1305/* Determine whether a key is NOT one of the fast metamethod names. */ 1305/* 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)
1382 IRType t = itype2irt(oldv); 1382 IRType t = itype2irt(oldv);
1383 TRef res; 1383 TRef res;
1384 if (oldv == niltvg(J2G(J))) { 1384 if (oldv == niltvg(J2G(J))) {
1385 emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1385 emitir(IRTG(IR_EQ, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1386 res = TREF_NIL; 1386 res = TREF_NIL;
1387 } else { 1387 } else {
1388 res = emitir(IRTG(loadop, t), xref, 0); 1388 res = emitir(IRTG(loadop, t), xref, 0);
@@ -1412,7 +1412,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1412 if (hasmm) 1412 if (hasmm)
1413 emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ 1413 emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */
1414 else if (xrefop == IR_HREF) 1414 else if (xrefop == IR_HREF)
1415 emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), 1415 emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PGC),
1416 xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1416 xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1417 if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { 1417 if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) {
1418 lua_assert(hasmm); 1418 lua_assert(hasmm);
@@ -1423,7 +1423,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1423 TRef key = ix->key; 1423 TRef key = ix->key;
1424 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ 1424 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
1425 key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); 1425 key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
1426 xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); 1426 xref = emitir(IRT(IR_NEWREF, IRT_PGC), ix->tab, key);
1427 keybarrier = 0; /* NEWREF already takes care of the key barrier. */ 1427 keybarrier = 0; /* NEWREF already takes care of the key barrier. */
1428#ifdef LUAJIT_ENABLE_TABLE_BUMP 1428#ifdef LUAJIT_ENABLE_TABLE_BUMP
1429 if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */ 1429 if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */
@@ -1433,7 +1433,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1433 } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { 1433 } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
1434 /* Cannot derive that the previous value was non-nil, must do checks. */ 1434 /* Cannot derive that the previous value was non-nil, must do checks. */
1435 if (xrefop == IR_HREF) /* Guard against store to niltv. */ 1435 if (xrefop == IR_HREF) /* Guard against store to niltv. */
1436 emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1436 emitir(IRTG(IR_NE, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1437 if (ix->idxchain) { /* Metamethod lookup required? */ 1437 if (ix->idxchain) { /* Metamethod lookup required? */
1438 /* A check for NULL metatable is cheaper (hoistable) than a load. */ 1438 /* A check for NULL metatable is cheaper (hoistable) than a load. */
1439 if (!mt) { 1439 if (!mt) {
@@ -1455,7 +1455,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1455 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); 1455 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
1456 /* Invalidate neg. metamethod cache for stores with certain string keys. */ 1456 /* Invalidate neg. metamethod cache for stores with certain string keys. */
1457 if (!nommstr(J, ix->key)) { 1457 if (!nommstr(J, ix->key)) {
1458 TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); 1458 TRef fref = emitir(IRT(IR_FREF, IRT_PGC), ix->tab, IRFL_TAB_NOMM);
1459 emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); 1459 emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0));
1460 } 1460 }
1461 J->needsnap = 1; 1461 J->needsnap = 1;
@@ -1541,15 +1541,15 @@ noconstify:
1541 /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ 1541 /* Note: this effectively limits LJ_MAX_UPVAL to 127. */
1542 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); 1542 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
1543 if (!uvp->closed) { 1543 if (!uvp->closed) {
1544 uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); 1544 uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_PGC), fn, uv));
1545 /* In current stack? */ 1545 /* In current stack? */
1546 if (uvval(uvp) >= tvref(J->L->stack) && 1546 if (uvval(uvp) >= tvref(J->L->stack) &&
1547 uvval(uvp) < tvref(J->L->maxstack)) { 1547 uvval(uvp) < tvref(J->L->maxstack)) {
1548 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); 1548 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
1549 if (slot >= 0) { /* Aliases an SSA slot? */ 1549 if (slot >= 0) { /* Aliases an SSA slot? */
1550 emitir(IRTG(IR_EQ, IRT_P32), 1550 emitir(IRTG(IR_EQ, IRT_PGC),
1551 REF_BASE, 1551 REF_BASE,
1552 emitir(IRT(IR_ADD, IRT_P32), uref, 1552 emitir(IRT(IR_ADD, IRT_PGC), uref,
1553 lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8))); 1553 lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8)));
1554 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ 1554 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
1555 if (val == 0) { 1555 if (val == 0) {
@@ -1561,12 +1561,12 @@ noconstify:
1561 } 1561 }
1562 } 1562 }
1563 } 1563 }
1564 emitir(IRTG(IR_UGT, IRT_P32), 1564 emitir(IRTG(IR_UGT, IRT_PGC),
1565 emitir(IRT(IR_SUB, IRT_P32), uref, REF_BASE), 1565 emitir(IRT(IR_SUB, IRT_PGC), uref, REF_BASE),
1566 lj_ir_kint(J, (J->baseslot + J->maxslot) * 8)); 1566 lj_ir_kint(J, (J->baseslot + J->maxslot) * 8));
1567 } else { 1567 } else {
1568 needbarrier = 1; 1568 needbarrier = 1;
1569 uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); 1569 uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_PGC), fn, uv));
1570 } 1570 }
1571 if (val == 0) { /* Upvalue load */ 1571 if (val == 0) { /* Upvalue load */
1572 IRType t = itype2irt(uvval(uvp)); 1572 IRType t = itype2irt(uvval(uvp));
@@ -1733,11 +1733,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
1733 else 1733 else
1734 emitir(IRTGI(IR_EQ), fr, 1734 emitir(IRTGI(IR_EQ), fr,
1735 lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1))); 1735 lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
1736 vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); 1736 vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
1737 vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); 1737 vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
1738 for (i = 0; i < nload; i++) { 1738 for (i = 0; i < nload; i++) {
1739 IRType t = itype2irt(&J->L->base[i-1-nvararg]); 1739 IRType t = itype2irt(&J->L->base[i-1-nvararg]);
1740 TRef aref = emitir(IRT(IR_AREF, IRT_P32), 1740 TRef aref = emitir(IRT(IR_AREF, IRT_PGC),
1741 vbase, lj_ir_kint(J, (int32_t)i)); 1741 vbase, lj_ir_kint(J, (int32_t)i));
1742 TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); 1742 TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
1743 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ 1743 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)
1783 } 1783 }
1784 if (idx != 0 && idx <= nvararg) { 1784 if (idx != 0 && idx <= nvararg) {
1785 IRType t; 1785 IRType t;
1786 TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); 1786 TRef aref, vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
1787 vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); 1787 vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
1788 t = itype2irt(&J->L->base[idx-2-nvararg]); 1788 t = itype2irt(&J->L->base[idx-2-nvararg]);
1789 aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); 1789 aref = emitir(IRT(IR_AREF, IRT_PGC), vbase, tridx);
1790 tr = emitir(IRTG(IR_VLOAD, t), aref, 0); 1790 tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
1791 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ 1791 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
1792 } 1792 }
@@ -1840,10 +1840,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot)
1840 break; 1840 break;
1841 } 1841 }
1842 xbase = ++trp; 1842 xbase = ++trp;
1843 tr = hdr = emitir(IRT(IR_BUFHDR, IRT_P32), 1843 tr = hdr = emitir(IRT(IR_BUFHDR, IRT_PGC),
1844 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET); 1844 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
1845 do { 1845 do {
1846 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, *trp++); 1846 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, *trp++);
1847 } while (trp <= top); 1847 } while (trp <= top);
1848 tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr); 1848 tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
1849 J->maxslot = (BCReg)(xbase - J->base); 1849 J->maxslot = (BCReg)(xbase - J->base);
@@ -2481,7 +2481,7 @@ void lj_record_setup(jit_State *J)
2481 J->bc_extent = ~(MSize)0; 2481 J->bc_extent = ~(MSize)0;
2482 2482
2483 /* Emit instructions for fixed references. Also triggers initial IR alloc. */ 2483 /* Emit instructions for fixed references. Also triggers initial IR alloc. */
2484 emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); 2484 emitir_raw(IRT(IR_BASE, IRT_PGC), J->parent, J->exitno);
2485 for (i = 0; i <= 2; i++) { 2485 for (i = 0; i <= 2; i++) {
2486 IRIns *ir = IR(REF_NIL-i); 2486 IRIns *ir = IR(REF_NIL-i);
2487 ir->i = 0; 2487 ir->i = 0;