aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-04-26 18:40:39 +0200
committerMike Pall <mike>2013-04-26 18:40:39 +0200
commitf9421f2b9f0959bc80eff064a0f13970c4e35cc1 (patch)
tree68e44457ede555d214cab3532386b1fa85736184
parent47fa9a8d8ff7123e160abfc18c88589bbb7f4b58 (diff)
downloadluajit-f9421f2b9f0959bc80eff064a0f13970c4e35cc1.tar.gz
luajit-f9421f2b9f0959bc80eff064a0f13970c4e35cc1.tar.bz2
luajit-f9421f2b9f0959bc80eff064a0f13970c4e35cc1.zip
Replace string.len with bytecode builtin.
-rw-r--r--src/host/buildvm_libbc.h32
-rw-r--r--src/lib_string.c11
-rw-r--r--src/lj_dispatch.h2
-rw-r--r--src/lj_ffrecord.c6
-rw-r--r--src/vm_arm.dasc6
-rw-r--r--src/vm_mips.dasc7
-rw-r--r--src/vm_ppc.dasc5
-rw-r--r--src/vm_x86.dasc9
8 files changed, 24 insertions, 54 deletions
diff --git a/src/host/buildvm_libbc.h b/src/host/buildvm_libbc.h
index ec2a55f8..e96c8a53 100644
--- a/src/host/buildvm_libbc.h
+++ b/src/host/buildvm_libbc.h
@@ -4,25 +4,27 @@ static const int libbc_endian = 0;
4 4
5static const uint8_t libbc_code[] = { 5static const uint8_t libbc_code[] = {
60,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, 60,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0,
70,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,2,9,0,0,0,15, 70,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3,
816,0,12,0,16,1,9,0,41,2,1,0,21,3,0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0, 816,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3,
959,8,5,0,66,6,3,2,10,6,0,0,88,7,1,128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10, 90,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1,
100,0,0,16,16,0,12,0,16,1,9,0,43,2,0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0, 10128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,0,16,16,0,12,0,16,1,9,0,43,2,
1118,8,5,0,18,9,6,0,66,7,3,2,10,7,0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127, 110,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0,
1275,0,1,0,0,1,2,0,0,0,3,16,0,12,0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12, 120,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12,
130,21,2,0,0,11,1,0,0,88,3,7,128,8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2, 130,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,
140,76,3,2,0,88,3,18,128,16,1,14,0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3, 148,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,
1512,128,59,3,1,0,22,4,1,1,18,5,2,0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64, 150,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,
169,8,0,79,4,252,127,43,4,0,0,64,4,2,0,76,3,2,0,75,0,1,0,0,2,0 160,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,
172,0,76,3,2,0,75,0,1,0,0,2,0
17}; 18};
18 19
19static const struct { const char *name; int ofs; } libbc_map[] = { 20static const struct { const char *name; int ofs; } libbc_map[] = {
20{"math_deg",0}, 21{"math_deg",0},
21{"math_rad",25}, 22{"math_rad",25},
22{"table_foreachi",50}, 23{"string_len",50},
23{"table_foreach",117}, 24{"table_foreachi",69},
24{"table_getn",188}, 25{"table_foreach",136},
25{"table_remove",207}, 26{"table_getn",207},
26{NULL,336} 27{"table_remove",226},
28{NULL,355}
27}; 29};
28 30
diff --git a/src/lib_string.c b/src/lib_string.c
index f3c29aa7..db2c275d 100644
--- a/src/lib_string.c
+++ b/src/lib_string.c
@@ -32,11 +32,12 @@
32 32
33#define LJLIB_MODULE_string 33#define LJLIB_MODULE_string
34 34
35LJLIB_ASM(string_len) LJLIB_REC(.) 35LJLIB_LUA(string_len) /*
36{ 36 function(s)
37 lj_lib_checkstr(L, 1); 37 CHECK_str(s)
38 return FFH_RETRY; 38 return #s
39} 39 end
40*/
40 41
41LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) 42LJLIB_ASM(string_byte) LJLIB_REC(string_range 0)
42{ 43{
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h
index 1368594a..e744e3f8 100644
--- a/src/lj_dispatch.h
+++ b/src/lj_dispatch.h
@@ -61,7 +61,7 @@ typedef uint16_t HotCount;
61#define HOTCOUNT_CALL 1 61#define HOTCOUNT_CALL 1
62 62
63/* This solves a circular dependency problem -- bump as needed. Sigh. */ 63/* This solves a circular dependency problem -- bump as needed. Sigh. */
64#define GG_NUM_ASMFF 59 64#define GG_NUM_ASMFF 58
65 65
66#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) 66#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF)
67#define GG_LEN_SDISP BC_FUNCF 67#define GG_LEN_SDISP BC_FUNCF
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index a6ce2df7..1560d3f5 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -646,12 +646,6 @@ static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd)
646 646
647/* -- String library fast functions --------------------------------------- */ 647/* -- String library fast functions --------------------------------------- */
648 648
649static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd)
650{
651 J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN);
652 UNUSED(rd);
653}
654
655/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ 649/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */
656static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) 650static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
657{ 651{
diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc
index 5a15c409..5c149bc4 100644
--- a/src/vm_arm.dasc
+++ b/src/vm_arm.dasc
@@ -1706,12 +1706,6 @@ static void build_subroutines(BuildCtx *ctx)
1706 | 1706 |
1707 |//-- String library ----------------------------------------------------- 1707 |//-- String library -----------------------------------------------------
1708 | 1708 |
1709 |.ffunc_1 string_len
1710 | checkstr CARG2, ->fff_fallback
1711 | ldr CARG1, STR:CARG1->len
1712 | mvn CARG2, #~LJ_TISNUM
1713 | b ->fff_restv
1714 |
1715 |.ffunc string_byte // Only handle the 1-arg case here. 1709 |.ffunc string_byte // Only handle the 1-arg case here.
1716 | ldrd CARG12, [BASE] 1710 | ldrd CARG12, [BASE]
1717 | ldr PC, [BASE, FRAME_PC] 1711 | ldr PC, [BASE, FRAME_PC]
diff --git a/src/vm_mips.dasc b/src/vm_mips.dasc
index fa53a554..962e9290 100644
--- a/src/vm_mips.dasc
+++ b/src/vm_mips.dasc
@@ -1619,13 +1619,6 @@ static void build_subroutines(BuildCtx *ctx)
1619 | 1619 |
1620 |//-- String library ----------------------------------------------------- 1620 |//-- String library -----------------------------------------------------
1621 | 1621 |
1622 |.ffunc_1 string_len
1623 | li AT, LJ_TSTR
1624 | bne CARG3, AT, ->fff_fallback
1625 |. nop
1626 | b ->fff_resi
1627 |. lw CRET1, STR:CARG1->len
1628 |
1629 |.ffunc string_byte // Only handle the 1-arg case here. 1622 |.ffunc string_byte // Only handle the 1-arg case here.
1630 | lw CARG3, HI(BASE) 1623 | lw CARG3, HI(BASE)
1631 | lw STR:CARG1, LO(BASE) 1624 | lw STR:CARG1, LO(BASE)
diff --git a/src/vm_ppc.dasc b/src/vm_ppc.dasc
index ac399900..19211825 100644
--- a/src/vm_ppc.dasc
+++ b/src/vm_ppc.dasc
@@ -2045,11 +2045,6 @@ static void build_subroutines(BuildCtx *ctx)
2045 | 2045 |
2046 |//-- String library ----------------------------------------------------- 2046 |//-- String library -----------------------------------------------------
2047 | 2047 |
2048 |.ffunc_1 string_len
2049 | checkstr CARG3; bne ->fff_fallback
2050 | lwz CRET1, STR:CARG1->len
2051 | b ->fff_resi
2052 |
2053 |.ffunc string_byte // Only handle the 1-arg case here. 2048 |.ffunc string_byte // Only handle the 1-arg case here.
2054 | cmplwi NARGS8:RC, 8 2049 | cmplwi NARGS8:RC, 8
2055 | lwz CARG3, 0(BASE) 2050 | lwz CARG3, 0(BASE)
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index 68e23847..3f2959be 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -2202,15 +2202,6 @@ static void build_subroutines(BuildCtx *ctx)
2202 | 2202 |
2203 |//-- String library ----------------------------------------------------- 2203 |//-- String library -----------------------------------------------------
2204 | 2204 |
2205 |.ffunc_1 string_len
2206 | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback
2207 | mov STR:RB, [BASE]
2208 |.if DUALNUM
2209 | mov RB, dword STR:RB->len; jmp ->fff_resi
2210 |.else
2211 | cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0
2212 |.endif
2213 |
2214 |.ffunc string_byte // Only handle the 1-arg case here. 2205 |.ffunc string_byte // Only handle the 1-arg case here.
2215 | cmp NARGS:RD, 1+1; jne ->fff_fallback 2206 | cmp NARGS:RD, 1+1; jne ->fff_fallback
2216 | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback 2207 | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback