diff options
Diffstat (limited to '')
-rw-r--r-- | src/vm_x86.dasc | 78 |
1 files changed, 19 insertions, 59 deletions
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc index 8ed55fd2..8bbeaa2b 100644 --- a/src/vm_x86.dasc +++ b/src/vm_x86.dasc | |||
@@ -115,6 +115,7 @@ | |||
115 | |.type NODE, Node | 115 | |.type NODE, Node |
116 | |.type NARGS, int | 116 | |.type NARGS, int |
117 | |.type TRACE, GCtrace | 117 | |.type TRACE, GCtrace |
118 | |.type SBUF, SBuf | ||
118 | | | 119 | | |
119 | |// Stack layout while in interpreter. Must match with lj_frame.h. | 120 | |// Stack layout while in interpreter. Must match with lj_frame.h. |
120 | |//----------------------------------------------------------------------- | 121 | |//----------------------------------------------------------------------- |
@@ -2258,6 +2259,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
2258 | |.endif | 2259 | |.endif |
2259 | | mov SAVE_PC, PC | 2260 | | mov SAVE_PC, PC |
2260 | | call extern lj_str_new // (lua_State *L, char *str, size_t l) | 2261 | | call extern lj_str_new // (lua_State *L, char *str, size_t l) |
2262 | |->fff_resstr: | ||
2261 | | // GCstr * returned in eax (RD). | 2263 | | // GCstr * returned in eax (RD). |
2262 | | mov BASE, L:RB->base | 2264 | | mov BASE, L:RB->base |
2263 | | mov PC, [BASE-4] | 2265 | | mov PC, [BASE-4] |
@@ -2373,69 +2375,27 @@ static void build_subroutines(BuildCtx *ctx) | |||
2373 | | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.b)] | 2375 | | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.b)] |
2374 | | jmp ->fff_newstr | 2376 | | jmp ->fff_newstr |
2375 | | | 2377 | | |
2376 | |.ffunc_1 string_reverse | 2378 | |.macro ffstring_op, name |
2379 | | .ffunc_1 string_ .. name | ||
2377 | | ffgccheck | 2380 | | ffgccheck |
2378 | | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | 2381 | | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback |
2379 | | mov STR:RB, [BASE] | 2382 | | mov L:RB, SAVE_L |
2380 | | mov RC, STR:RB->len | 2383 | | lea SBUF:FCARG1, [DISPATCH+DISPATCH_GL(tmpbuf)] |
2381 | | test RC, RC | 2384 | | mov L:RB->base, BASE |
2382 | | jz ->fff_emptystr // Zero length string? | 2385 | | mov STR:FCARG2, [BASE] // Caveat: FCARG2 == BASE |
2383 | | mov TMP2, PC // Need another temp register. | 2386 | | mov RC, SBUF:FCARG1->b |
2384 | | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.b)] | 2387 | | mov SBUF:FCARG1->L, L:RB |
2385 | | lea RA, [PC+RC] | 2388 | | mov SBUF:FCARG1->p, RC |
2386 | | cmp [DISPATCH+DISPATCH_GL(tmpbuf.e)], RA; jb ->fff_fallback_1 | 2389 | | mov SAVE_PC, PC |
2387 | | add RB, #STR | 2390 | | call extern lj_buf_putstr_ .. name |
2388 | |.if X64 | 2391 | | mov FCARG1, eax |
2389 | | mov TMP3, RC | 2392 | | call extern lj_buf_tostr |
2390 | |.else | 2393 | | jmp ->fff_resstr |
2391 | | mov ARG3, RC | ||
2392 | |.endif | ||
2393 | |1: | ||
2394 | | movzx RA, byte [RB] | ||
2395 | | add RB, 1 | ||
2396 | | sub RC, 1 | ||
2397 | | mov [PC+RC], RAL | ||
2398 | | jnz <1 | ||
2399 | | mov RD, PC | ||
2400 | | mov PC, TMP2 | ||
2401 | | jmp ->fff_newstr | ||
2402 | | | ||
2403 | |.macro ffstring_case, name, lo, hi | ||
2404 | | .ffunc_1 name | ||
2405 | | ffgccheck | ||
2406 | | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | ||
2407 | | mov TMP2, PC // Need another temp register. | ||
2408 | | mov STR:RB, [BASE] | ||
2409 | | mov RC, STR:RB->len | ||
2410 | | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.b)] | ||
2411 | | lea RA, [PC+RC] | ||
2412 | | cmp [DISPATCH+DISPATCH_GL(tmpbuf.e)], RA; jb ->fff_fallback_1 | ||
2413 | | add RB, #STR | ||
2414 | |.if X64 | ||
2415 | | mov TMP3, RC | ||
2416 | |.else | ||
2417 | | mov ARG3, RC | ||
2418 | |.endif | ||
2419 | | jmp >3 | ||
2420 | |1: // ASCII case conversion. Yes, this is suboptimal code (do you care?). | ||
2421 | | movzx RA, byte [RB+RC] | ||
2422 | | cmp RA, lo | ||
2423 | | jb >2 | ||
2424 | | cmp RA, hi | ||
2425 | | ja >2 | ||
2426 | | xor RA, 0x20 | ||
2427 | |2: | ||
2428 | | mov [PC+RC], RAL | ||
2429 | |3: | ||
2430 | | sub RC, 1 | ||
2431 | | jns <1 | ||
2432 | | mov RD, PC | ||
2433 | | mov PC, TMP2 | ||
2434 | | jmp ->fff_newstr | ||
2435 | |.endmacro | 2394 | |.endmacro |
2436 | | | 2395 | | |
2437 | |ffstring_case string_lower, 0x41, 0x5a | 2396 | |ffstring_op reverse |
2438 | |ffstring_case string_upper, 0x61, 0x7a | 2397 | |ffstring_op lower |
2398 | |ffstring_op upper | ||
2439 | | | 2399 | | |
2440 | |//-- Bit library -------------------------------------------------------- | 2400 | |//-- Bit library -------------------------------------------------------- |
2441 | | | 2401 | | |