diff options
author | Mike Pall <mike> | 2011-04-10 16:59:38 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-04-10 16:59:38 +0200 |
commit | 040c8c5737ccc2071a03da0217157ee8d4571d56 (patch) | |
tree | e05e3f410a4fd675cd2944dce566b3e12eeef1a1 /src | |
parent | da1ef8c3b06c64573faf03633cf70f704413cae1 (diff) | |
download | luajit-040c8c5737ccc2071a03da0217157ee8d4571d56.tar.gz luajit-040c8c5737ccc2071a03da0217157ee8d4571d56.tar.bz2 luajit-040c8c5737ccc2071a03da0217157ee8d4571d56.zip |
ARM: Add string.* fast functions and GC steps.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildvm_arm.dasc | 172 |
1 files changed, 159 insertions, 13 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index aefe308d..7a5196d1 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
@@ -777,8 +777,12 @@ static void build_subroutines(BuildCtx *ctx) | |||
777 | | bhs ->fff_fallback | 777 | | bhs ->fff_fallback |
778 | |.endmacro | 778 | |.endmacro |
779 | | | 779 | | |
780 | |// Inlined GC threshold check. Caveat: uses CARG1 and CARG2. | ||
780 | |.macro ffgccheck | 781 | |.macro ffgccheck |
781 | | NYI | 782 | | ldr CARG1, [DISPATCH, #DISPATCH_GL(gc.total)] |
783 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(gc.threshold)] | ||
784 | | cmp CARG1, CARG2 | ||
785 | | blge ->fff_gcstep | ||
782 | |.endmacro | 786 | |.endmacro |
783 | | | 787 | | |
784 | |//-- Base library: checks ----------------------------------------------- | 788 | |//-- Base library: checks ----------------------------------------------- |
@@ -897,13 +901,14 @@ static void build_subroutines(BuildCtx *ctx) | |||
897 | | beq ->fff_restv | 901 | | beq ->fff_restv |
898 | | // Handle numbers inline, unless a number base metatable is present. | 902 | | // Handle numbers inline, unless a number base metatable is present. |
899 | | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] | 903 | | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] |
900 | | mov CARG1, L | 904 | | str BASE, L->base |
901 | | checktp CARG2, LJ_TISNUM | 905 | | checktp CARG2, LJ_TISNUM |
902 | | cmpls CARG4, #0 | 906 | | cmpls CARG4, #0 |
907 | | str PC, SAVE_PC // Redundant (but a defined value). | ||
903 | | bhi ->fff_fallback | 908 | | bhi ->fff_fallback |
904 | | str BASE, L->base | 909 | | ffgccheck |
905 | | mov CARG2, BASE | 910 | | mov CARG1, L |
906 | | str PC, SAVE_PC | 911 | | mov CARG2, BASE |
907 | | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) | 912 | | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) |
908 | | // Returns GCstr *. | 913 | | // Returns GCstr *. |
909 | | ldr BASE, L->base | 914 | | ldr BASE, L->base |
@@ -1214,26 +1219,156 @@ static void build_subroutines(BuildCtx *ctx) | |||
1214 | |//-- String library ----------------------------------------------------- | 1219 | |//-- String library ----------------------------------------------------- |
1215 | | | 1220 | | |
1216 | |.ffunc_1 string_len | 1221 | |.ffunc_1 string_len |
1217 | | NYI | 1222 | | checkstr CARG2, ->fff_fallback |
1223 | | ldr CARG1, STR:CARG1->len | ||
1224 | | mvn CARG2, #~LJ_TISNUM | ||
1225 | | b ->fff_restv | ||
1218 | | | 1226 | | |
1219 | |.ffunc string_byte // Only handle the 1-arg case here. | 1227 | |.ffunc string_byte // Only handle the 1-arg case here. |
1220 | | NYI | 1228 | | ldrd CARG12, [BASE] |
1229 | | ldr PC, [BASE, FRAME_PC] | ||
1230 | | cmp NARGS8:RC, #8 | ||
1231 | | checktpeq CARG2, LJ_TSTR // Need exactly 1 argument. | ||
1232 | | bne ->fff_fallback | ||
1233 | | ldr CARG3, STR:CARG1->len | ||
1234 | | ldrb CARG1, STR:CARG1[1] // Access is always ok (NUL at end). | ||
1235 | | mvn CARG2, #~LJ_TISNUM | ||
1236 | | cmp CARG3, #0 | ||
1237 | | moveq RC, #(0+1)*8 | ||
1238 | | movne RC, #(1+1)*8 | ||
1239 | | strd CARG12, [BASE, #-8] | ||
1240 | | b ->fff_res | ||
1221 | | | 1241 | | |
1222 | |.ffunc string_char // Only handle the 1-arg case here. | 1242 | |.ffunc string_char // Only handle the 1-arg case here. |
1223 | | NYI | 1243 | | ffgccheck |
1244 | | ldrd CARG12, [BASE] | ||
1245 | | ldr PC, [BASE, FRAME_PC] | ||
1246 | | cmp NARGS8:RC, #8 // Need exactly 1 argument. | ||
1247 | | checktpeq CARG2, LJ_TISNUM | ||
1248 | | bicseq CARG4, CARG1, #255 | ||
1249 | | mov CARG3, #1 | ||
1250 | | bne ->fff_fallback | ||
1251 | | str CARG1, TMPD | ||
1252 | | mov CARG2, TMPDp // Points to stack. Little-endian. | ||
1253 | |->fff_newstr: | ||
1254 | | // CARG2 = str, CARG3 = len. | ||
1255 | | str BASE, L->base | ||
1256 | | mov CARG1, L | ||
1257 | | str PC, SAVE_PC | ||
1258 | | bl extern lj_str_new // (lua_State *L, char *str, size_t l) | ||
1259 | | // Returns GCstr *. | ||
1260 | | ldr BASE, L->base | ||
1261 | | mvn CARG2, #~LJ_TSTR | ||
1262 | | b ->fff_restv | ||
1224 | | | 1263 | | |
1225 | |.ffunc string_sub | 1264 | |.ffunc string_sub |
1226 | | NYI | 1265 | | ffgccheck |
1266 | | ldrd CARG12, [BASE] | ||
1267 | | ldrd CARG34, [BASE, #16] | ||
1268 | | cmp NARGS8:RC, #16 | ||
1269 | | mvn RB, #0 | ||
1270 | | beq >1 | ||
1271 | | blo ->fff_fallback | ||
1272 | | checktp CARG4, LJ_TISNUM | ||
1273 | | mov RB, CARG3 | ||
1274 | | bne ->fff_fallback | ||
1275 | |1: | ||
1276 | | ldr CARG34, [BASE, #8] | ||
1277 | | checktp CARG2, LJ_TSTR | ||
1278 | | ldreq CARG2, STR:CARG1->len | ||
1279 | | checktpeq CARG4, LJ_TISNUM | ||
1280 | | bne ->fff_fallback | ||
1281 | | // CARG1 = str, CARG2 = str->len, CARG3 = start, RB = end | ||
1282 | | add CARG4, CARG2, #1 | ||
1283 | | cmp CARG3, #0 // if (start < 0) start += len+1 | ||
1284 | | addlt CARG3, CARG3, CARG4 | ||
1285 | | cmp CARG3, #1 // if (start < 1) start = 1 | ||
1286 | | movlt CARG3, #1 | ||
1287 | | cmp RB, #0 // if (end < 0) end += len+1 | ||
1288 | | addlt RB, RB, CARG4 | ||
1289 | | bic RB, RB, RB, asr #31 // if (end < 0) end = 0 | ||
1290 | | cmp RB, CARG2 // if (end > len) end = len | ||
1291 | | add CARG1, STR:CARG1, #sizeof(GCstr)-1 | ||
1292 | | movgt RB, CARG2 | ||
1293 | | add CARG2, CARG1, CARG3 | ||
1294 | | subs CARG3, RB, CARG3 // len = start - end | ||
1295 | | add CARG3, CARG3, #1 // len += 1 | ||
1296 | | bge ->fff_newstr | ||
1297 | |->fff_emptystr: | ||
1298 | | sub STR:CARG1, DISPATCH, #-DISPATCH_GL(strempty) | ||
1299 | | mvn CARG2, #~LJ_TSTR | ||
1300 | | b ->fff_restv | ||
1227 | | | 1301 | | |
1228 | |.ffunc string_rep // Only handle the 1-char case inline. | 1302 | |.ffunc string_rep // Only handle the 1-char case inline. |
1229 | | NYI | 1303 | | ffgccheck |
1304 | | ldrd CARG12, [BASE] | ||
1305 | | ldrd CARG34, [BASE, #8] | ||
1306 | | cmp NARGS8:RC, #16 | ||
1307 | | blo ->fff_fallback | ||
1308 | | checktp CARG2, LJ_TSTR | ||
1309 | | checktpeq CARG4, LJ_TISNUM | ||
1310 | | bne ->fff_fallback | ||
1311 | | subs CARG4, CARG3, #1 | ||
1312 | | ldr CARG2, STR:CARG1->len | ||
1313 | | blt ->fff_emptystr // Count <= 0? | ||
1314 | | cmp CARG2, #1 | ||
1315 | | blo ->fff_emptystr // Zero-length string? | ||
1316 | | bne ->fff_fallback // Fallback for > 1-char strings. | ||
1317 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ||
1318 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | ||
1319 | | ldr CARG1, STR:CARG1[1] | ||
1320 | | cmp RB, CARG3 | ||
1321 | | blo ->fff_fallback | ||
1322 | |1: // Fill buffer with char. | ||
1323 | | strb CARG1, [CARG2, CARG4] | ||
1324 | | subs CARG4, CARG4, #1 | ||
1325 | | bge <1 | ||
1326 | | b ->fff_newstr | ||
1230 | | | 1327 | | |
1231 | |.ffunc string_reverse | 1328 | |.ffunc string_reverse |
1232 | | NYI | 1329 | | ffgccheck |
1330 | | ldrd CARG12, [BASE] | ||
1331 | | cmp NARGS8:RC, #8 | ||
1332 | | blo ->fff_fallback | ||
1333 | | checkstr CARG2, ->fff_fallback | ||
1334 | | ldr CARG3, STR:CARG1->len | ||
1335 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ||
1336 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | ||
1337 | | mov CARG4, CARG3 | ||
1338 | | add CARG1, STR:CARG1, #sizeof(GCstr) | ||
1339 | | cmp RB, CARG3 | ||
1340 | | blo ->fff_fallback | ||
1341 | |1: // Reverse string copy. | ||
1342 | | ldrb RB, [CARG1], #1 | ||
1343 | | subs CARG4, CARG4, #1 | ||
1344 | | blt ->fff_newstr | ||
1345 | | strb RB, [CARG2, CARG4] | ||
1346 | | b <1 | ||
1233 | | | 1347 | | |
1234 | |.macro ffstring_case, name, lo | 1348 | |.macro ffstring_case, name, lo |
1235 | | .ffunc name | 1349 | | .ffunc name |
1236 | | NYI | 1350 | | ffgccheck |
1351 | | ldrd CARG12, [BASE] | ||
1352 | | cmp NARGS8:RC, #8 | ||
1353 | | blo ->fff_fallback | ||
1354 | | checkstr CARG2, ->fff_fallback | ||
1355 | | ldr CARG3, STR:CARG1->len | ||
1356 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ||
1357 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | ||
1358 | | mov CARG4, #0 | ||
1359 | | add CARG1, STR:CARG1, #sizeof(GCstr) | ||
1360 | | cmp RB, CARG3 | ||
1361 | | blo ->fff_fallback | ||
1362 | |1: // ASCII case conversion. | ||
1363 | | ldrb RB, [CARG1, CARG4] | ||
1364 | | cmp CARG4, CARG3 | ||
1365 | | bhs ->fff_newstr | ||
1366 | | sub RC, RB, #lo | ||
1367 | | cmp RC, #26 | ||
1368 | | eorlo RB, RB, #0x20 | ||
1369 | | strb RB, [CARG2, CARG4] | ||
1370 | | add CARG4, CARG4, #1 | ||
1371 | | b <1 | ||
1237 | |.endmacro | 1372 | |.endmacro |
1238 | | | 1373 | | |
1239 | |ffstring_case string_lower, 65 | 1374 | |ffstring_case string_lower, 65 |
@@ -1397,7 +1532,18 @@ static void build_subroutines(BuildCtx *ctx) | |||
1397 | | b <1 | 1532 | | b <1 |
1398 | | | 1533 | | |
1399 | |->fff_gcstep: // Call GC step function. | 1534 | |->fff_gcstep: // Call GC step function. |
1400 | | NYI | 1535 | | // BASE = new base, RC = nargs*8 |
1536 | | mov RA, lr | ||
1537 | | str BASE, L->base | ||
1538 | | add CARG2, BASE, NARGS8:RC | ||
1539 | | str PC, SAVE_PC // Redundant (but a defined value). | ||
1540 | | str CARG2, L->top | ||
1541 | | mov CARG1, L | ||
1542 | | bl extern lj_gc_step // (lua_State *L) | ||
1543 | | ldr BASE, L->base | ||
1544 | | mov lr, RA // Help return address predictor. | ||
1545 | | ldr CFUNC:CARG3, [BASE, FRAME_FUNC] | ||
1546 | | bx lr | ||
1401 | | | 1547 | | |
1402 | |//----------------------------------------------------------------------- | 1548 | |//----------------------------------------------------------------------- |
1403 | |//-- Special dispatch targets ------------------------------------------- | 1549 | |//-- Special dispatch targets ------------------------------------------- |