aboutsummaryrefslogtreecommitdiff
path: root/src/lj_ffrecord.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_ffrecord.c')
-rw-r--r--src/lj_ffrecord.c38
1 files changed, 19 insertions, 19 deletions
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));