]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Replace string.len with bytecode builtin.
authorMike Pall <mike>
Fri, 26 Apr 2013 16:40:39 +0000 (18:40 +0200)
committerMike Pall <mike>
Fri, 26 Apr 2013 16:40:39 +0000 (18:40 +0200)
src/host/buildvm_libbc.h
src/lib_string.c
src/lj_dispatch.h
src/lj_ffrecord.c
src/vm_arm.dasc
src/vm_mips.dasc
src/vm_ppc.dasc
src/vm_x86.dasc

index ec2a55f874ae32bcf37225801fb523ccd4e30742..e96c8a5382c5202d3381ccd4028a1e62ba07c7f7 100644 (file)
@@ -4,25 +4,27 @@ static const int libbc_endian = 0;
 
 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,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,
-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,
-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,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,
-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,
-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,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,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,
-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,
-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,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,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,
+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,
+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,
+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,
+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,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,
+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,
+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,
+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[] = {
 {"math_deg",0},
 {"math_rad",25},
-{"table_foreachi",50},
-{"table_foreach",117},
-{"table_getn",188},
-{"table_remove",207},
-{NULL,336}
+{"string_len",50},
+{"table_foreachi",69},
+{"table_foreach",136},
+{"table_getn",207},
+{"table_remove",226},
+{NULL,355}
 };
 
index f3c29aa7474deb0489ddab1826e8c26a640b7bf1..db2c275df6b3f56c072c01bee43f73b0c27935ff 100644 (file)
 
 #define LJLIB_MODULE_string
 
-LJLIB_ASM(string_len)          LJLIB_REC(.)
-{
-  lj_lib_checkstr(L, 1);
-  return FFH_RETRY;
-}
+LJLIB_LUA(string_len) /*
+  function(s)
+    CHECK_str(s)
+    return #s
+  end
+*/
 
 LJLIB_ASM(string_byte)         LJLIB_REC(string_range 0)
 {
index 1368594a17a33d523218a738cbe58518ff0a0897..e744e3f8ea8222b735c6144e0901e500c94f6444 100644 (file)
@@ -61,7 +61,7 @@ typedef uint16_t HotCount;
 #define HOTCOUNT_CALL          1
 
 /* 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_SDISP   BC_FUNCF
index a6ce2df7ee974b279f91a1e5cb53269c13e94de9..1560d3f5e93fb8a6176310161909a7de5ad8ef29 100644 (file)
@@ -646,12 +646,6 @@ static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd)
 
 /* -- 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). */
 static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
 {
index 5a15c409b8080cbded4ba0f33403f31a9bf5c876..5c149bc4eb61fabc97a583e3b56c0cfc629f73b6 100644 (file)
@@ -1706,12 +1706,6 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |//-- 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.
   |  ldrd CARG12, [BASE]
   |    ldr PC, [BASE, FRAME_PC]
index fa53a5545eb97af400bc33ea528f8634dd62a651..962e92903a58cb894fcdc996a69b7f56eb2747ff 100644 (file)
@@ -1619,13 +1619,6 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |//-- 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.
   |  lw CARG3, HI(BASE)
   |   lw STR:CARG1, LO(BASE)
index ac399900033190c3c051dd67e07bba71d2f126a2..19211825aaa4986866be920be725ce3676b93b9b 100644 (file)
@@ -2045,11 +2045,6 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |//-- 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.
   |  cmplwi NARGS8:RC, 8
   |   lwz CARG3, 0(BASE)
index 68e23847d95a5f02bd59af3bc0468744914b4a46..3f2959be8a1a75b960df1ff72a1fd7fc2e9e24ec 100644 (file)
@@ -2202,15 +2202,6 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |//-- 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.
   |  cmp NARGS:RD, 1+1;  jne ->fff_fallback
   |  cmp dword [BASE+4], LJ_TSTR;  jne ->fff_fallback