aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-04-08 02:42:04 +0200
committerMike Pall <mike>2011-04-08 02:42:04 +0200
commit1f4f805c9692a13d259d30d728e6748526f543d3 (patch)
treeec12a038782c982e5e3c65ca87131bafabd90399 /src
parent0046f955eb42125e5c1ddd485d1ee86f1e6a2208 (diff)
downloadluajit-1f4f805c9692a13d259d30d728e6748526f543d3.tar.gz
luajit-1f4f805c9692a13d259d30d728e6748526f543d3.tar.bz2
luajit-1f4f805c9692a13d259d30d728e6748526f543d3.zip
ARM: Add getmetatable(), setmetatable() and tonumber() fast functions.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_arm.dasc62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc
index 81b03fea..bd121561 100644
--- a/src/buildvm_arm.dasc
+++ b/src/buildvm_arm.dasc
@@ -723,18 +723,72 @@ static void build_subroutines(BuildCtx *ctx)
723 |//-- Base library: getters and setters --------------------------------- 723 |//-- Base library: getters and setters ---------------------------------
724 | 724 |
725 |.ffunc_1 getmetatable 725 |.ffunc_1 getmetatable
726 | NYI 726 | checktp CARG2, LJ_TTAB
727 | cmnne CARG2, #-LJ_TUDATA
728 | bne >6
729 |1: // Field metatable must be at same offset for GCtab and GCudata!
730 | ldr TAB:RB, TAB:CARG1->metatable
731 |2:
732 | mvn CARG2, #~LJ_TNIL
733 | ldr STR:RC, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])]
734 | cmp TAB:RB, #0
735 | beq ->fff_restv
736 | ldr CARG3, TAB:RB->hmask
737 | ldr CARG4, STR:RC->hash
738 | ldr NODE:INS, TAB:RB->node
739 | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask
740 | add CARG3, CARG3, CARG3, lsl #1
741 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8
742 |3: // Rearranged logic, because we expect _not_ to find the key.
743 | ldrd CARG34, NODE:INS->key // STALL: early NODE:INS.
744 | ldrd CARG12, NODE:INS->val
745 | ldr NODE:INS, NODE:INS->next
746 | cmp CARG3, STR:RC
747 | checktpeq CARG4, LJ_TSTR
748 | beq >5
749 | cmp NODE:INS, #0
750 | bne <3
751 |4:
752 | mov CARG1, RB // Use metatable as default result.
753 | mvn CARG2, #~LJ_TTAB
754 | b ->fff_restv
755 |5:
756 | checktp CARG2, LJ_TNIL
757 | bne ->fff_restv
758 | b <4
759 |
760 |6:
761 | checktp CARG2, LJ_TISNUM
762 | mvnhs CARG2, CARG2
763 | movlo CARG2, #~LJ_TISNUM
764 | add CARG4, DISPATCH, CARG2, lsl #2
765 | ldr TAB:RB, [CARG4, #DISPATCH_GL(gcroot[GCROOT_BASEMT])]
766 | b <2
727 | 767 |
728 |.ffunc_2 setmetatable 768 |.ffunc_2 setmetatable
729 | NYI 769 | // Fast path: no mt for table yet and not clearing the mt.
770 | checktp CARG2, LJ_TTAB
771 | ldreq TAB:RB, TAB:CARG1->metatable
772 | checktpeq CARG4, LJ_TTAB
773 | ldrbeq CARG4, TAB:CARG1->marked
774 | cmpeq TAB:RB, #0
775 | bne ->fff_fallback
776 | tst CARG4, #LJ_GC_BLACK // isblack(table)
777 | str TAB:CARG3, TAB:CARG1->metatable
778 | beq ->fff_restv
779 | barrierback TAB:CARG1, CARG4, CARG3
780 | b ->fff_restv
730 | 781 |
731 |.ffunc rawget 782 |.ffunc rawget
732 | NYI 783 | NYI
733 | 784 |
734 |//-- Base library: conversions ------------------------------------------ 785 |//-- Base library: conversions ------------------------------------------
735 | 786 |
736 |.ffunc tonumber 787 |.ffunc_1 tonumber
737 | NYI 788 | // Only handles the number case inline (without a base argument).
789 | checktp CARG2, LJ_TISNUM
790 | bls ->fff_restv
791 | b ->fff_fallback
738 | 792 |
739 |.ffunc_1 tostring 793 |.ffunc_1 tostring
740 | // Only handles the string or number case inline. 794 | // Only handles the string or number case inline.