aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-04-04 01:56:41 +0200
committerMike Pall <mike>2011-04-04 01:56:41 +0200
commit6511941348ffc5e672b411cd471d01567d3e0c30 (patch)
treead10c92bc70cc1c7519ddbaf197f0abb41740bab /src
parent5b146f61b566e88a8d141dcab3c3ffb0399c7639 (diff)
downloadluajit-6511941348ffc5e672b411cd471d01567d3e0c30.tar.gz
luajit-6511941348ffc5e672b411cd471d01567d3e0c30.tar.bz2
luajit-6511941348ffc5e672b411cd471d01567d3e0c30.zip
ARM: Add fast functions pairs()/next() and ipairs() + iterator.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_arm.dasc87
1 files changed, 82 insertions, 5 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc
index bcfc5387..f3d32473 100644
--- a/src/buildvm_arm.dasc
+++ b/src/buildvm_arm.dasc
@@ -596,17 +596,94 @@ static void build_subroutines(BuildCtx *ctx)
596 | 596 |
597 |//-- Base library: iterators ------------------------------------------- 597 |//-- Base library: iterators -------------------------------------------
598 | 598 |
599 |.ffunc next 599 |.ffunc_1 next
600 | NYI 600 | mvn CARG4, #~LJ_TNIL
601 | checktab CARG2, ->fff_fallback
602 | strd CARG34, [BASE, NARGS8:RC] // Set missing 2nd arg to nil.
603 | ldr PC, [BASE, FRAME_PC]
604 | mov CARG2, CARG1
605 | str BASE, L->base // Add frame since C call can throw.
606 | mov CARG1, L
607 | str BASE, L->top // Dummy frame length is ok.
608 | add CARG3, BASE, #8
609 | str PC, SAVE_PC
610 | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key)
611 | // Returns 0 at end of traversal.
612 | cmp CRET1, #0
613 | mvneq CRET2, #~LJ_TNIL
614 | beq ->fff_restv // End of traversal: return nil.
615 | ldrd CARG12, [BASE, #8] // Copy key and value to results.
616 | ldrd CARG34, [BASE, #16]
617 | mov RC, #(2+1)*8
618 | strd CARG12, [BASE, #-8]
619 | strd CARG34, [BASE]
620 | b ->fff_res
601 | 621 |
602 |.ffunc_1 pairs 622 |.ffunc_1 pairs
603 | NYI 623 | checktab CARG2, ->fff_fallback
624#ifdef LUAJIT_ENABLE_LUA52COMPAT
625 | ldr TAB:RB, TAB:CARG1->metatable
626#endif
627 | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0]
628 | ldr PC, [BASE, FRAME_PC]
629#ifdef LUAJIT_ENABLE_LUA52COMPAT
630 | cmp TAB:RB, #0
631 | bne ->fff_fallback
632#endif
633 | mvn CARG2, #~LJ_TNIL
634 | mov RC, #(3+1)*8
635 | strd CFUNC:CARG34, [BASE, #-8]
636 | str CARG2, [BASE, #12]
637 | b ->fff_res
604 | 638 |
605 |.ffunc_2 ipairs_aux 639 |.ffunc_2 ipairs_aux
606 | NYI 640 | checktp CARG2, LJ_TTAB
641 | checktpeq CARG4, LJ_TISNUM
642 | bne ->fff_fallback
643 | ldr RB, TAB:CARG1->asize
644 | ldr RC, TAB:CARG1->array
645 | add CARG3, CARG3, #1
646 | ldr PC, [BASE, FRAME_PC]
647 | cmp CARG3, RB
648 | add RC, RC, CARG3, lsl #3
649 | strd CARG34, [BASE, #-8]
650 | ldrdlo CARG12, [RC]
651 | mov RC, #(0+1)*8
652 | bhs >2 // Not in array part?
653 |1:
654 | checktp CARG2, LJ_TNIL
655 | movne RC, #(2+1)*8
656 | strdne CARG12, [BASE]
657 | b ->fff_res
658 |2: // Check for empty hash part first. Otherwise call C function.
659 | ldr RB, TAB:CARG1->hmask
660 | mov CARG2, CARG3
661 | cmp RB, #0
662 | beq ->fff_res
663 | bl extern lj_tab_getinth // (GCtab *t, int32_t key)
664 | // Returns cTValue * or NULL.
665 | cmp CRET1, #0
666 | beq ->fff_res
667 | ldrd CARG12, [CRET1]
668 | b <1
607 | 669 |
608 |.ffunc_1 ipairs 670 |.ffunc_1 ipairs
609 | NYI 671 | checktab CARG2, ->fff_fallback
672#ifdef LUAJIT_ENABLE_LUA52COMPAT
673 | ldr TAB:RB, TAB:CARG1->metatable
674#endif
675 | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0]
676 | ldr PC, [BASE, FRAME_PC]
677#ifdef LUAJIT_ENABLE_LUA52COMPAT
678 | cmp TAB:RB, #0
679 | bne ->fff_fallback
680#endif
681 | mov CARG1, #0
682 | mvn CARG2, #~LJ_TISNUM
683 | mov RC, #(3+1)*8
684 | strd CFUNC:CARG34, [BASE, #-8]
685 | strd CARG12, [BASE, #8]
686 | b ->fff_res
610 | 687 |
611 |//-- Base library: catch errors ---------------------------------------- 688 |//-- Base library: catch errors ----------------------------------------
612 | 689 |