diff options
author | Mike Pall <mike> | 2011-04-04 01:54:56 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-04-04 01:54:56 +0200 |
commit | 6110faadd81e6b8c2ca691c8b98156ebaf2ce4e6 (patch) | |
tree | 1d25c329c1e0e7754a5b3055191ad4ca9a650511 /src | |
parent | dd4a043b78878780a4d2222cebd36a39ed051a8e (diff) | |
download | luajit-6110faadd81e6b8c2ca691c8b98156ebaf2ce4e6.tar.gz luajit-6110faadd81e6b8c2ca691c8b98156ebaf2ce4e6.tar.bz2 luajit-6110faadd81e6b8c2ca691c8b98156ebaf2ce4e6.zip |
ARM: Add basic infrastructure for fast functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildvm_arm.dasc | 83 |
1 files changed, 75 insertions, 8 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index cb054328..aa4eea8c 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
@@ -523,12 +523,17 @@ static void build_subroutines(BuildCtx *ctx) | |||
523 | | | 523 | | |
524 | |.macro .ffunc_1, name | 524 | |.macro .ffunc_1, name |
525 | |->ff_ .. name: | 525 | |->ff_ .. name: |
526 | | NYI | 526 | | ldrd CARG12, [BASE] |
527 | | cmp NARGS8:RC, #8 | ||
528 | | blo ->fff_fallback | ||
527 | |.endmacro | 529 | |.endmacro |
528 | | | 530 | | |
529 | |.macro .ffunc_2, name | 531 | |.macro .ffunc_2, name |
530 | |->ff_ .. name: | 532 | |->ff_ .. name: |
531 | | NYI | 533 | | ldrd CARG12, [BASE] |
534 | | ldrd CARG34, [BASE, #8] | ||
535 | | cmp NARGS8:RC, #16 | ||
536 | | blo ->fff_fallback | ||
532 | |.endmacro | 537 | |.endmacro |
533 | | | 538 | | |
534 | |.macro .ffunc_n, name | 539 | |.macro .ffunc_n, name |
@@ -617,13 +622,36 @@ static void build_subroutines(BuildCtx *ctx) | |||
617 | | NYI | 622 | | NYI |
618 | | | 623 | | |
619 | |->fff_restv: | 624 | |->fff_restv: |
620 | | NYI | 625 | | // CARG12 = TValue result. |
621 | | | 626 | | ldr PC, [BASE, FRAME_PC] |
627 | | strd CARG12, [BASE, #-8] | ||
622 | |->fff_res1: | 628 | |->fff_res1: |
623 | | NYI | 629 | | // PC = return. |
624 | | | 630 | | mov RC, #(1+1)*8 |
625 | |->fff_res: | 631 | |->fff_res: |
626 | | NYI | 632 | | // RC = (nresults+1)*8, PC = return. |
633 | | ands CARG1, PC, #FRAME_TYPE | ||
634 | | ldreq INS, [PC, #-4] | ||
635 | | str RC, SAVE_MULTRES | ||
636 | | sub RA, BASE, #8 | ||
637 | | bne ->vm_return | ||
638 | | decode_RB8 RB, INS | ||
639 | |5: | ||
640 | | cmp RB, RC // More results expected? | ||
641 | | bhi >6 | ||
642 | | decode_RA8 CARG1, INS | ||
643 | | ins_next1 | ||
644 | | ins_next2 | ||
645 | | // Adjust BASE. KBASE is assumed to be set for the calling frame. | ||
646 | | sub BASE, RA, CARG1 | ||
647 | | ins_next3 | ||
648 | | | ||
649 | |6: // Fill up results with nil. | ||
650 | | add CARG2, RA, RC | ||
651 | | mvn CARG1, #~LJ_TNIL | ||
652 | | add RC, RC, #8 | ||
653 | | str CARG1, [CARG2, #-4] | ||
654 | | b <5 | ||
627 | | | 655 | | |
628 | |.macro math_extern, func | 656 | |.macro math_extern, func |
629 | | .ffunc math_ .. func | 657 | | .ffunc math_ .. func |
@@ -755,7 +783,46 @@ static void build_subroutines(BuildCtx *ctx) | |||
755 | |//----------------------------------------------------------------------- | 783 | |//----------------------------------------------------------------------- |
756 | | | 784 | | |
757 | |->fff_fallback: // Call fast function fallback handler. | 785 | |->fff_fallback: // Call fast function fallback handler. |
758 | | NYI | 786 | | // BASE = new base, RC = nargs*8 |
787 | | ldr CARG3, [BASE, FRAME_FUNC] | ||
788 | | ldr CARG2, L->maxstack | ||
789 | | add CARG1, BASE, NARGS8:RC | ||
790 | | ldr PC, [BASE, FRAME_PC] // Fallback may overwrite PC. | ||
791 | | str CARG1, L->top | ||
792 | | ldr CARG3, CFUNC:CARG3->f | ||
793 | | str BASE, L->base | ||
794 | | add CARG1, CARG1, #8*LUA_MINSTACK | ||
795 | | str PC, SAVE_PC // Redundant (but a defined value). | ||
796 | | cmp CARG1, CARG2 | ||
797 | | mov CARG1, L | ||
798 | | bhi >5 // Need to grow stack. | ||
799 | | blx CARG3 // (lua_State *L) | ||
800 | | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | ||
801 | | cmp CRET1, #0 | ||
802 | | lsl RC, CRET1, #3 | ||
803 | | sub RA, BASE, #8 | ||
804 | | bgt ->fff_res // Returned nresults+1? | ||
805 | |1: // Returned 0 or -1: retry fast path. | ||
806 | | ldr CARG1, L->top | ||
807 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | ||
808 | | sub NARGS8:RC, CARG1, BASE | ||
809 | | bne >2 // Returned -1? | ||
810 | | ins_callt // Returned 0: retry fast path. | ||
811 | | | ||
812 | |2: // Reconstruct previous base for vmeta_call during tailcall. | ||
813 | | ands CARG1, PC, #FRAME_TYPE | ||
814 | | bic CARG2, PC, #FRAME_TYPEP | ||
815 | | ldreq INS, [PC, #-4] | ||
816 | | andeq CARG2, MASKR8, INS, lsr #5 // Conditional decode_RA8. | ||
817 | | sub RB, BASE, CARG2 | ||
818 | | b ->vm_call_dispatch // Resolve again for tailcall. | ||
819 | | | ||
820 | |5: // Grow stack for fallback handler. | ||
821 | | mov CARG2, #LUA_MINSTACK | ||
822 | | bl extern lj_state_growstack // (lua_State *L, int n) | ||
823 | | ldr BASE, L->base | ||
824 | | cmp CARG1, CARG1 // Set zero-flag to force retry. | ||
825 | | b <1 | ||
759 | | | 826 | | |
760 | |->fff_gcstep: // Call GC step function. | 827 | |->fff_gcstep: // Call GC step function. |
761 | | NYI | 828 | | NYI |