aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-04-27 15:52:32 +0200
committerMike Pall <mike>2013-04-27 15:52:32 +0200
commitc77680824f1be8daaf438f9474785dbebddfb077 (patch)
treeaf7ed72a39b3ac2110537bdd71f55d63ee151586
parent64d2883ab4fdd3090d8a428aafc9a2bb3a1ec724 (diff)
downloadluajit-c77680824f1be8daaf438f9474785dbebddfb077.tar.gz
luajit-c77680824f1be8daaf438f9474785dbebddfb077.tar.bz2
luajit-c77680824f1be8daaf438f9474785dbebddfb077.zip
Compile table.concat().
-rw-r--r--src/lib_table.c2
-rw-r--r--src/lj_ffrecord.c27
-rw-r--r--src/lj_ircall.h1
3 files changed, 29 insertions, 1 deletions
diff --git a/src/lib_table.c b/src/lib_table.c
index 011b9fdf..4f5d9d0d 100644
--- a/src/lib_table.c
+++ b/src/lib_table.c
@@ -129,7 +129,7 @@ LJLIB_LUA(table_remove) /*
129 end 129 end
130*/ 130*/
131 131
132LJLIB_CF(table_concat) 132LJLIB_CF(table_concat) LJLIB_REC(.)
133{ 133{
134 GCtab *t = lj_lib_checktab(L, 1); 134 GCtab *t = lj_lib_checktab(L, 1);
135 GCstr *sep = lj_lib_optstr(L, 2); 135 GCstr *sep = lj_lib_optstr(L, 2);
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index d66aaa53..5f69ea14 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -825,6 +825,33 @@ static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd)
825 } /* else: Interpreter will throw. */ 825 } /* else: Interpreter will throw. */
826} 826}
827 827
828static void LJ_FASTCALL recff_table_concat(jit_State *J, RecordFFData *rd)
829{
830 TRef tab = J->base[0];
831 if (tref_istab(tab)) {
832 TRef sep = 0, tri = 0, tre = 0;
833 TRef hdr, tr;
834 if (J->base[1]) {
835 sep = lj_ir_tostr(J, J->base[1]);
836 if (J->base[2]) {
837 tri = lj_opt_narrow_toint(J, J->base[2]);
838 if (J->base[3])
839 tre = lj_opt_narrow_toint(J, J->base[3]);
840 }
841 } else {
842 sep = lj_ir_knull(J, IRT_STR);
843 }
844 if (!tri) tri = lj_ir_kint(J, 1);
845 if (!tre) tre = lj_ir_call(J, IRCALL_lj_tab_len, tab);
846 hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
847 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
848 tr = lj_ir_call(J, IRCALL_lj_buf_puttab, hdr, tab, sep, tri, tre);
849 emitir(IRTG(IR_NE, IRT_PTR), tr, lj_ir_kptr(J, NULL));
850 J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
851 } /* else: Interpreter will throw. */
852 UNUSED(rd);
853}
854
828/* -- I/O library fast functions ------------------------------------------ */ 855/* -- I/O library fast functions ------------------------------------------ */
829 856
830/* Get FILE* for I/O function. Any I/O error aborts recording, so there's 857/* Get FILE* for I/O function. Any I/O error aborts recording, so there's
diff --git a/src/lj_ircall.h b/src/lj_ircall.h
index f652befd..8713e3f0 100644
--- a/src/lj_ircall.h
+++ b/src/lj_ircall.h
@@ -115,6 +115,7 @@ typedef struct CCallInfo {
115 _(ANY, lj_buf_putstr_lower, 2, FL, P32, 0) \ 115 _(ANY, lj_buf_putstr_lower, 2, FL, P32, 0) \
116 _(ANY, lj_buf_putstr_upper, 2, FL, P32, 0) \ 116 _(ANY, lj_buf_putstr_upper, 2, FL, P32, 0) \
117 _(ANY, lj_buf_putstr_rep, 3, L, P32, 0) \ 117 _(ANY, lj_buf_putstr_rep, 3, L, P32, 0) \
118 _(ANY, lj_buf_puttab, 5, L, P32, 0) \
118 _(ANY, lj_buf_tostr, 1, FL, STR, 0) \ 119 _(ANY, lj_buf_tostr, 1, FL, STR, 0) \
119 _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ 120 _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
120 _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ 121 _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \