diff options
Diffstat (limited to 'src/vm_arm.dasc')
-rw-r--r-- | src/vm_arm.dasc | 138 |
1 files changed, 105 insertions, 33 deletions
diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc index 114416a4..1d4b60f4 100644 --- a/src/vm_arm.dasc +++ b/src/vm_arm.dasc | |||
@@ -615,6 +615,16 @@ static void build_subroutines(BuildCtx *ctx) | |||
615 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | 615 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. |
616 | | b ->vm_call_dispatch_f | 616 | | b ->vm_call_dispatch_f |
617 | | | 617 | | |
618 | |->vmeta_tgetr: | ||
619 | | .IOS mov RC, BASE | ||
620 | | bl extern lj_tab_getinth // (GCtab *t, int32_t key) | ||
621 | | // Returns cTValue * or NULL. | ||
622 | | .IOS mov BASE, RC | ||
623 | | cmp CRET1, #0 | ||
624 | | ldrdne CARG12, [CRET1] | ||
625 | | mvneq CARG2, #~LJ_TNIL | ||
626 | | b ->BC_TGETR_Z | ||
627 | | | ||
618 | |//----------------------------------------------------------------------- | 628 | |//----------------------------------------------------------------------- |
619 | | | 629 | | |
620 | |->vmeta_tsets1: | 630 | |->vmeta_tsets1: |
@@ -672,6 +682,15 @@ static void build_subroutines(BuildCtx *ctx) | |||
672 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | 682 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. |
673 | | b ->vm_call_dispatch_f | 683 | | b ->vm_call_dispatch_f |
674 | | | 684 | | |
685 | |->vmeta_tsetr: | ||
686 | | str BASE, L->base | ||
687 | | .IOS mov RC, BASE | ||
688 | | str PC, SAVE_PC | ||
689 | | bl extern lj_tab_setinth // (lua_State *L, GCtab *t, int32_t key) | ||
690 | | // Returns TValue *. | ||
691 | | .IOS mov BASE, RC | ||
692 | | b ->BC_TSETR_Z | ||
693 | | | ||
675 | |//-- Comparison metamethods --------------------------------------------- | 694 | |//-- Comparison metamethods --------------------------------------------- |
676 | | | 695 | | |
677 | |->vmeta_comp: | 696 | |->vmeta_comp: |
@@ -736,6 +755,17 @@ static void build_subroutines(BuildCtx *ctx) | |||
736 | | b <3 | 755 | | b <3 |
737 | |.endif | 756 | |.endif |
738 | | | 757 | | |
758 | |->vmeta_istype: | ||
759 | | sub PC, PC, #4 | ||
760 | | str BASE, L->base | ||
761 | | mov CARG1, L | ||
762 | | lsr CARG2, RA, #3 | ||
763 | | mov CARG3, RC | ||
764 | | str PC, SAVE_PC | ||
765 | | bl extern lj_meta_istype // (lua_State *L, BCReg ra, BCReg tp) | ||
766 | | .IOS ldr BASE, L->base | ||
767 | | b ->cont_nop | ||
768 | | | ||
739 | |//-- Arithmetic metamethods --------------------------------------------- | 769 | |//-- Arithmetic metamethods --------------------------------------------- |
740 | | | 770 | | |
741 | |->vmeta_arith_vn: | 771 | |->vmeta_arith_vn: |
@@ -1501,19 +1531,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1501 | | math_extern2 atan2 | 1531 | | math_extern2 atan2 |
1502 | | math_extern2 fmod | 1532 | | math_extern2 fmod |
1503 | | | 1533 | | |
1504 | |->ff_math_deg: | ||
1505 | |.if FPU | ||
1506 | | .ffunc_d math_rad | ||
1507 | | vldr d1, CFUNC:CARG3->upvalue[0] | ||
1508 | | vmul.f64 d0, d0, d1 | ||
1509 | | b ->fff_resd | ||
1510 | |.else | ||
1511 | | .ffunc_n math_rad | ||
1512 | | ldrd CARG34, CFUNC:CARG3->upvalue[0] | ||
1513 | | bl extern __aeabi_dmul | ||
1514 | | b ->fff_restv | ||
1515 | |.endif | ||
1516 | | | ||
1517 | |.if HFABI | 1534 | |.if HFABI |
1518 | | .ffunc math_ldexp | 1535 | | .ffunc math_ldexp |
1519 | | ldr CARG4, [BASE, #4] | 1536 | | ldr CARG4, [BASE, #4] |
@@ -1784,10 +1801,11 @@ static void build_subroutines(BuildCtx *ctx) | |||
1784 | | cmp CARG2, #1 | 1801 | | cmp CARG2, #1 |
1785 | | blo ->fff_emptystr // Zero-length string? | 1802 | | blo ->fff_emptystr // Zero-length string? |
1786 | | bne ->fff_fallback // Fallback for > 1-char strings. | 1803 | | bne ->fff_fallback // Fallback for > 1-char strings. |
1787 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | 1804 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.b)] |
1788 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | 1805 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.e)] |
1789 | | ldr CARG1, STR:CARG1[1] | 1806 | | ldr CARG1, STR:CARG1[1] |
1790 | | cmp RB, CARG3 | 1807 | | add INS, CARG2, CARG3 |
1808 | | cmp RB, INS | ||
1791 | | blo ->fff_fallback | 1809 | | blo ->fff_fallback |
1792 | |1: // Fill buffer with char. | 1810 | |1: // Fill buffer with char. |
1793 | | strb CARG1, [CARG2, CARG4] | 1811 | | strb CARG1, [CARG2, CARG4] |
@@ -1802,11 +1820,12 @@ static void build_subroutines(BuildCtx *ctx) | |||
1802 | | blo ->fff_fallback | 1820 | | blo ->fff_fallback |
1803 | | checkstr CARG2, ->fff_fallback | 1821 | | checkstr CARG2, ->fff_fallback |
1804 | | ldr CARG3, STR:CARG1->len | 1822 | | ldr CARG3, STR:CARG1->len |
1805 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | 1823 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.b)] |
1806 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | 1824 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.e)] |
1807 | | mov CARG4, CARG3 | 1825 | | mov CARG4, CARG3 |
1808 | | add CARG1, STR:CARG1, #sizeof(GCstr) | 1826 | | add CARG1, STR:CARG1, #sizeof(GCstr) |
1809 | | cmp RB, CARG3 | 1827 | | add INS, CARG2, CARG3 |
1828 | | cmp RB, INS | ||
1810 | | blo ->fff_fallback | 1829 | | blo ->fff_fallback |
1811 | |1: // Reverse string copy. | 1830 | |1: // Reverse string copy. |
1812 | | ldrb RB, [CARG1], #1 | 1831 | | ldrb RB, [CARG1], #1 |
@@ -1823,11 +1842,12 @@ static void build_subroutines(BuildCtx *ctx) | |||
1823 | | blo ->fff_fallback | 1842 | | blo ->fff_fallback |
1824 | | checkstr CARG2, ->fff_fallback | 1843 | | checkstr CARG2, ->fff_fallback |
1825 | | ldr CARG3, STR:CARG1->len | 1844 | | ldr CARG3, STR:CARG1->len |
1826 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | 1845 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.b)] |
1827 | | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | 1846 | | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.e)] |
1828 | | mov CARG4, #0 | 1847 | | mov CARG4, #0 |
1829 | | add CARG1, STR:CARG1, #sizeof(GCstr) | 1848 | | add CARG1, STR:CARG1, #sizeof(GCstr) |
1830 | | cmp RB, CARG3 | 1849 | | add INS, CARG2, CARG3 |
1850 | | cmp RB, INS | ||
1831 | | blo ->fff_fallback | 1851 | | blo ->fff_fallback |
1832 | |1: // ASCII case conversion. | 1852 | |1: // ASCII case conversion. |
1833 | | ldrb RB, [CARG1, CARG4] | 1853 | | ldrb RB, [CARG1, CARG4] |
@@ -1844,17 +1864,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1844 | |ffstring_case string_lower, 65 | 1864 | |ffstring_case string_lower, 65 |
1845 | |ffstring_case string_upper, 97 | 1865 | |ffstring_case string_upper, 97 |
1846 | | | 1866 | | |
1847 | |//-- Table library ------------------------------------------------------ | ||
1848 | | | ||
1849 | |.ffunc_1 table_getn | ||
1850 | | checktab CARG2, ->fff_fallback | ||
1851 | | .IOS mov RA, BASE | ||
1852 | | bl extern lj_tab_len // (GCtab *t) | ||
1853 | | // Returns uint32_t (but less than 2^31). | ||
1854 | | .IOS mov BASE, RA | ||
1855 | | mvn CARG2, #~LJ_TISNUM | ||
1856 | | b ->fff_restv | ||
1857 | | | ||
1858 | |//-- Bit library -------------------------------------------------------- | 1867 | |//-- Bit library -------------------------------------------------------- |
1859 | | | 1868 | | |
1860 | |// FP number to bit conversion for soft-float. Clobbers r0-r3. | 1869 | |// FP number to bit conversion for soft-float. Clobbers r0-r3. |
@@ -2834,6 +2843,25 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
2834 | | ins_next | 2843 | | ins_next |
2835 | break; | 2844 | break; |
2836 | 2845 | ||
2846 | case BC_ISTYPE: | ||
2847 | | // RA = src*8, RC = -type | ||
2848 | | ldrd CARG12, [BASE, RA] | ||
2849 | | ins_next1 | ||
2850 | | cmn CARG2, RC | ||
2851 | | ins_next2 | ||
2852 | | bne ->vmeta_istype | ||
2853 | | ins_next3 | ||
2854 | break; | ||
2855 | case BC_ISNUM: | ||
2856 | | // RA = src*8, RC = -(TISNUM-1) | ||
2857 | | ldrd CARG12, [BASE, RA] | ||
2858 | | ins_next1 | ||
2859 | | checktp CARG2, LJ_TISNUM | ||
2860 | | ins_next2 | ||
2861 | | bhs ->vmeta_istype | ||
2862 | | ins_next3 | ||
2863 | break; | ||
2864 | |||
2837 | /* -- Unary ops --------------------------------------------------------- */ | 2865 | /* -- Unary ops --------------------------------------------------------- */ |
2838 | 2866 | ||
2839 | case BC_MOV: | 2867 | case BC_MOV: |
@@ -3504,6 +3532,24 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3504 | | bne <1 // 'no __index' flag set: done. | 3532 | | bne <1 // 'no __index' flag set: done. |
3505 | | b ->vmeta_tgetb | 3533 | | b ->vmeta_tgetb |
3506 | break; | 3534 | break; |
3535 | case BC_TGETR: | ||
3536 | | decode_RB8 RB, INS | ||
3537 | | decode_RC8 RC, INS | ||
3538 | | // RA = dst*8, RB = table*8, RC = key*8 | ||
3539 | | ldr TAB:CARG1, [BASE, RB] | ||
3540 | | ldr CARG2, [BASE, RC] | ||
3541 | | ldr CARG4, TAB:CARG1->array | ||
3542 | | ldr CARG3, TAB:CARG1->asize | ||
3543 | | add CARG4, CARG4, CARG2, lsl #3 | ||
3544 | | cmp CARG2, CARG3 // In array part? | ||
3545 | | bhs ->vmeta_tgetr | ||
3546 | | ldrd CARG12, [CARG4] | ||
3547 | |->BC_TGETR_Z: | ||
3548 | | ins_next1 | ||
3549 | | ins_next2 | ||
3550 | | strd CARG12, [BASE, RA] | ||
3551 | | ins_next3 | ||
3552 | break; | ||
3507 | 3553 | ||
3508 | case BC_TSETV: | 3554 | case BC_TSETV: |
3509 | | decode_RB8 RB, INS | 3555 | | decode_RB8 RB, INS |
@@ -3674,6 +3720,32 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3674 | | barrierback TAB:CARG1, INS, CARG3 | 3720 | | barrierback TAB:CARG1, INS, CARG3 |
3675 | | b <2 | 3721 | | b <2 |
3676 | break; | 3722 | break; |
3723 | case BC_TSETR: | ||
3724 | | decode_RB8 RB, INS | ||
3725 | | decode_RC8 RC, INS | ||
3726 | | // RA = dst*8, RB = table*8, RC = key*8 | ||
3727 | | ldr TAB:CARG2, [BASE, RB] | ||
3728 | | ldr CARG3, [BASE, RC] | ||
3729 | | ldrb INS, TAB:CARG2->marked | ||
3730 | | ldr CARG1, TAB:CARG2->array | ||
3731 | | ldr CARG4, TAB:CARG2->asize | ||
3732 | | tst INS, #LJ_GC_BLACK // isblack(table) | ||
3733 | | add CARG1, CARG1, CARG3, lsl #3 | ||
3734 | | bne >7 | ||
3735 | |2: | ||
3736 | | cmp CARG3, CARG4 // In array part? | ||
3737 | | bhs ->vmeta_tsetr | ||
3738 | |->BC_TSETR_Z: | ||
3739 | | ldrd CARG34, [BASE, RA] | ||
3740 | | ins_next1 | ||
3741 | | ins_next2 | ||
3742 | | strd CARG34, [CARG1] | ||
3743 | | ins_next3 | ||
3744 | | | ||
3745 | |7: // Possible table write barrier for the value. Skip valiswhite check. | ||
3746 | | barrierback TAB:CARG2, INS, RB | ||
3747 | | b <2 | ||
3748 | break; | ||
3677 | 3749 | ||
3678 | case BC_TSETM: | 3750 | case BC_TSETM: |
3679 | | // RA = base*8 (table at base-1), RC = num_const (start index) | 3751 | | // RA = base*8 (table at base-1), RC = num_const (start index) |