Replace string.len with bytecode builtin.

This commit is contained in:
Mike Pall 2013-04-26 18:40:39 +02:00
parent 47fa9a8d8f
commit f9421f2b9f
8 changed files with 24 additions and 54 deletions

View File

@ -4,25 +4,27 @@ static const int libbc_endian = 0;
static const uint8_t libbc_code[] = { static const uint8_t libbc_code[] = {
0,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, 0,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,
0,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, 0,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,
16,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, 16,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,
59,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, 0,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,
0,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, 128,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,
18,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, 0,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,
75,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, 0,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,
0,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, 0,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,
0,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, 8,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,
12,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, 0,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,
9,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 0,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,
2,0,76,3,2,0,75,0,1,0,0,2,0
}; };
static const struct { const char *name; int ofs; } libbc_map[] = { static const struct { const char *name; int ofs; } libbc_map[] = {
{"math_deg",0}, {"math_deg",0},
{"math_rad",25}, {"math_rad",25},
{"table_foreachi",50}, {"string_len",50},
{"table_foreach",117}, {"table_foreachi",69},
{"table_getn",188}, {"table_foreach",136},
{"table_remove",207}, {"table_getn",207},
{NULL,336} {"table_remove",226},
{NULL,355}
}; };

View File

@ -32,11 +32,12 @@
#define LJLIB_MODULE_string #define LJLIB_MODULE_string
LJLIB_ASM(string_len) LJLIB_REC(.) LJLIB_LUA(string_len) /*
{ function(s)
lj_lib_checkstr(L, 1); CHECK_str(s)
return FFH_RETRY; return #s
} end
*/
LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) LJLIB_ASM(string_byte) LJLIB_REC(string_range 0)
{ {

View File

@ -61,7 +61,7 @@ typedef uint16_t HotCount;
#define HOTCOUNT_CALL 1 #define HOTCOUNT_CALL 1
/* This solves a circular dependency problem -- bump as needed. Sigh. */ /* This solves a circular dependency problem -- bump as needed. Sigh. */
#define GG_NUM_ASMFF 59 #define GG_NUM_ASMFF 58
#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF)
#define GG_LEN_SDISP BC_FUNCF #define GG_LEN_SDISP BC_FUNCF

View File

@ -646,12 +646,6 @@ static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd)
/* -- String library fast functions --------------------------------------- */ /* -- String library fast functions --------------------------------------- */
static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd)
{
J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN);
UNUSED(rd);
}
/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ /* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */
static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
{ {

View File

@ -1706,12 +1706,6 @@ static void build_subroutines(BuildCtx *ctx)
| |
|//-- String library ----------------------------------------------------- |//-- String library -----------------------------------------------------
| |
|.ffunc_1 string_len
| checkstr CARG2, ->fff_fallback
| ldr CARG1, STR:CARG1->len
| mvn CARG2, #~LJ_TISNUM
| b ->fff_restv
|
|.ffunc string_byte // Only handle the 1-arg case here. |.ffunc string_byte // Only handle the 1-arg case here.
| ldrd CARG12, [BASE] | ldrd CARG12, [BASE]
| ldr PC, [BASE, FRAME_PC] | ldr PC, [BASE, FRAME_PC]

View File

@ -1619,13 +1619,6 @@ static void build_subroutines(BuildCtx *ctx)
| |
|//-- String library ----------------------------------------------------- |//-- String library -----------------------------------------------------
| |
|.ffunc_1 string_len
| li AT, LJ_TSTR
| bne CARG3, AT, ->fff_fallback
|. nop
| b ->fff_resi
|. lw CRET1, STR:CARG1->len
|
|.ffunc string_byte // Only handle the 1-arg case here. |.ffunc string_byte // Only handle the 1-arg case here.
| lw CARG3, HI(BASE) | lw CARG3, HI(BASE)
| lw STR:CARG1, LO(BASE) | lw STR:CARG1, LO(BASE)

View File

@ -2045,11 +2045,6 @@ static void build_subroutines(BuildCtx *ctx)
| |
|//-- String library ----------------------------------------------------- |//-- String library -----------------------------------------------------
| |
|.ffunc_1 string_len
| checkstr CARG3; bne ->fff_fallback
| lwz CRET1, STR:CARG1->len
| b ->fff_resi
|
|.ffunc string_byte // Only handle the 1-arg case here. |.ffunc string_byte // Only handle the 1-arg case here.
| cmplwi NARGS8:RC, 8 | cmplwi NARGS8:RC, 8
| lwz CARG3, 0(BASE) | lwz CARG3, 0(BASE)

View File

@ -2202,15 +2202,6 @@ static void build_subroutines(BuildCtx *ctx)
| |
|//-- String library ----------------------------------------------------- |//-- String library -----------------------------------------------------
| |
|.ffunc_1 string_len
| cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback
| mov STR:RB, [BASE]
|.if DUALNUM
| mov RB, dword STR:RB->len; jmp ->fff_resi
|.else
| cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0
|.endif
|
|.ffunc string_byte // Only handle the 1-arg case here. |.ffunc string_byte // Only handle the 1-arg case here.
| cmp NARGS:RD, 1+1; jne ->fff_fallback | cmp NARGS:RD, 1+1; jne ->fff_fallback
| cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback