aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-04-08 03:02:26 +0200
committerMike Pall <mike>2011-04-08 03:03:10 +0200
commit27bf481669c13f37becfc4e4044b1d3557253d4d (patch)
tree394ebc39c139be8818ee42cf83109b14e45efad0 /src
parentb56784aae24bb865a308a0dafd1a067ac0dbe947 (diff)
downloadluajit-27bf481669c13f37becfc4e4044b1d3557253d4d.tar.gz
luajit-27bf481669c13f37becfc4e4044b1d3557253d4d.tar.bz2
luajit-27bf481669c13f37becfc4e4044b1d3557253d4d.zip
ARM: Misc. fixes for interpreter.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_arm.dasc61
-rw-r--r--src/lib_math.c12
2 files changed, 45 insertions, 28 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc
index aa55e549..7280438c 100644
--- a/src/buildvm_arm.dasc
+++ b/src/buildvm_arm.dasc
@@ -484,7 +484,7 @@ static void build_subroutines(BuildCtx *ctx)
484 | str TAB:RB, [CARG2] 484 | str TAB:RB, [CARG2]
485 | str CARG4, [CARG2, #4] 485 | str CARG4, [CARG2, #4]
486 |2: 486 |2:
487 | mvn CARG4, #~LJ_TISNUM 487 | mvn CARG4, #~LJ_TSTR
488 | str STR:RC, TMPDlo 488 | str STR:RC, TMPDlo
489 | str CARG4, TMPDhi 489 | str CARG4, TMPDhi
490 | mov CARG3, TMPDp 490 | mov CARG3, TMPDp
@@ -650,6 +650,8 @@ static void build_subroutines(BuildCtx *ctx)
650 | b >1 650 | b >1
651 | 651 |
652 |->vmeta_unm: 652 |->vmeta_unm:
653 | ldr INS, [PC, #-8]
654 | sub PC, PC, #4
653 | add CARG3, BASE, RC 655 | add CARG3, BASE, RC
654 | add CARG4, BASE, RC 656 | add CARG4, BASE, RC
655 | b >1 657 | b >1
@@ -1239,7 +1241,7 @@ static void build_subroutines(BuildCtx *ctx)
1239 |//-- Bit library -------------------------------------------------------- 1241 |//-- Bit library --------------------------------------------------------
1240 | 1242 |
1241 |.macro .ffunc_bit, name 1243 |.macro .ffunc_bit, name
1242 | .ffunc_n bit_..name 1244 | .ffunc_1 bit_..name
1243 | NYI 1245 | NYI
1244 |.endmacro 1246 |.endmacro
1245 | 1247 |
@@ -1264,7 +1266,7 @@ static void build_subroutines(BuildCtx *ctx)
1264 | NYI 1266 | NYI
1265 | 1267 |
1266 |.macro .ffunc_bit_sh, name, ins, shmod 1268 |.macro .ffunc_bit_sh, name, ins, shmod
1267 | .ffunc_nn bit_..name 1269 | .ffunc_2 bit_..name
1268 | NYI 1270 | NYI
1269 |.endmacro 1271 |.endmacro
1270 | 1272 |
@@ -1706,21 +1708,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
1706 | ins_next1 1708 | ins_next1
1707 | ins_next2 1709 | ins_next2
1708 | checktp CARG2, LJ_TISNUM 1710 | checktp CARG2, LJ_TISNUM
1711 | bhi ->vmeta_unm
1712 | eorne CARG2, CARG2, #0x80000000
1709 | bne >5 1713 | bne >5
1710 | rsbs CARG1, CARG1, #0 1714 | rsbseq CARG1, CARG1, #0
1711 | bvs >4 1715 | ldrdvs CARG12, >9
1712 |9: 1716 |5:
1713 | strd CARG12, [BASE, RA] 1717 | strd CARG12, [BASE, RA]
1714 | ins_next3 1718 | ins_next3
1715 |4: 1719 |
1716 | mov CARG2, #0x01e00000 // 2^31. 1720 |.align 8
1717 | mov CARG1, #0 1721 |9:
1718 | orr CARG2, CARG2, #0x40000000 1722 | .long 0x00000000, 0x41e00000 // 2^31.
1719 | b <9
1720 |5:
1721 | bhi ->vmeta_unm
1722 | add CARG2, CARG2, #0x80000000
1723 | b <9
1724 break; 1723 break;
1725 case BC_LEN: 1724 case BC_LEN:
1726 | // RA = dst*8, RC = src 1725 | // RA = dst*8, RC = src
@@ -1820,10 +1819,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
1820 | 1819 |
1821 |.macro ins_arithfp, fpcall 1820 |.macro ins_arithfp, fpcall
1822 | ins_arithpre 1821 | ins_arithpre
1822 | ins_arithfallback ins_arithcheck_num
1823 ||if (op == BC_MODVN) { 1823 ||if (op == BC_MODVN) {
1824 | ->BC_MODVN_Z: 1824 | ->BC_MODVN_Z:
1825 ||} 1825 ||}
1826 | ins_arithfallback ins_arithcheck_num
1827 | bl fpcall 1826 | bl fpcall
1828 | ins_next1 1827 | ins_next1
1829 | ins_next2 1828 | ins_next2
@@ -1850,6 +1849,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
1850 break; 1849 break;
1851 case BC_MODNV: case BC_MODVV: 1850 case BC_MODNV: case BC_MODVV:
1852 | ins_arithpre 1851 | ins_arithpre
1852 | ins_arithfallback ins_arithcheck_num
1853 | b ->BC_MODVN_Z 1853 | b ->BC_MODVN_Z
1854 break; 1854 break;
1855 case BC_POW: 1855 case BC_POW:
@@ -2087,9 +2087,9 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2087 | str BASE, L->base 2087 | str BASE, L->base
2088 | str PC, SAVE_PC 2088 | str PC, SAVE_PC
2089 | cmp CARG3, CARG4 2089 | cmp CARG3, CARG4
2090 | mov CARG1, L
2090 | bhs >5 2091 | bhs >5
2091 |1: 2092 |1:
2092 | mov CARG1, L
2093 if (op == BC_TNEW) { 2093 if (op == BC_TNEW) {
2094 | lsl CARG2, RC, #21 2094 | lsl CARG2, RC, #21
2095 | lsr CARG3, RC, #11 2095 | lsr CARG3, RC, #11
@@ -2112,6 +2112,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2112 | ins_next3 2112 | ins_next3
2113 |5: 2113 |5:
2114 | bl extern lj_gc_step_fixtop // (lua_State *L) 2114 | bl extern lj_gc_step_fixtop // (lua_State *L)
2115 | mov CARG1, L
2115 | b <1 2116 | b <1
2116 break; 2117 break;
2117 2118
@@ -2146,7 +2147,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2146 | cmp CARG3, CARG2 // In array part? 2147 | cmp CARG3, CARG2 // In array part?
2147 | ldrdlo CARG34, [CARG4] 2148 | ldrdlo CARG34, [CARG4]
2148 | bhs ->vmeta_tgetv 2149 | bhs ->vmeta_tgetv
2149 | ins_next1 2150 | ins_next1 // Overwrites RB!
2150 | checktp CARG4, LJ_TNIL 2151 | checktp CARG4, LJ_TNIL
2151 | beq >5 2152 | beq >5
2152 |1: 2153 |1:
@@ -2161,6 +2162,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2161 | ldrb CARG2, TAB:CARG2->nomm 2162 | ldrb CARG2, TAB:CARG2->nomm
2162 | tst CARG2, #1<<MM_index 2163 | tst CARG2, #1<<MM_index
2163 | bne <1 // 'no __index' flag set: done. 2164 | bne <1 // 'no __index' flag set: done.
2165 | decode_RB8 RB, INS // Restore RB.
2164 | b ->vmeta_tgetv 2166 | b ->vmeta_tgetv
2165 | 2167 |
2166 |9: 2168 |9:
@@ -2283,7 +2285,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2283 | ldrb RA, TAB:RA->nomm 2285 | ldrb RA, TAB:RA->nomm
2284 | tst RA, #1<<MM_newindex 2286 | tst RA, #1<<MM_newindex
2285 | bne <1 // 'no __newindex' flag set: done. 2287 | bne <1 // 'no __newindex' flag set: done.
2286 | ldr INS, [PC, #-4] // Restore RA. 2288 | ldr INS, [PC, #-4] // Restore RA and RB.
2289 | decode_RB8 RB, INS
2287 | decode_RA8 RA, INS 2290 | decode_RA8 RA, INS
2288 | b ->vmeta_tsetv 2291 | b ->vmeta_tsetv
2289 | 2292 |
@@ -2313,9 +2316,11 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2313 | mov TAB:RB, TAB:CARG1 2316 | mov TAB:RB, TAB:CARG1
2314 | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask 2317 | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask
2315 | add CARG3, CARG3, CARG3, lsl #1 2318 | add CARG3, CARG3, CARG3, lsl #1
2319 | mov CARG4, #0
2316 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 2320 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8
2321 | strb CARG4, TAB:RB->nomm // Clear metamethod cache.
2317 |1: 2322 |1:
2318 | ldrd CARG12, NODE:INS->key // STALL: early NODE:INS. 2323 | ldrd CARG12, NODE:INS->key
2319 | ldr CARG4, NODE:INS->val.it 2324 | ldr CARG4, NODE:INS->val.it
2320 | ldr NODE:CARG3, NODE:INS->next 2325 | ldr NODE:CARG3, NODE:INS->next
2321 | cmp CARG1, STR:RC 2326 | cmp CARG1, STR:RC
@@ -2427,8 +2432,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2427 | b ->BC_CALL_Z 2432 | b ->BC_CALL_Z
2428 break; 2433 break;
2429 case BC_CALL: 2434 case BC_CALL:
2430 | // RA = base*8, (RB = nresults+1,) RC = nargs+1
2431 | decode_RC8 NARGS8:RC, INS 2435 | decode_RC8 NARGS8:RC, INS
2436 | // RA = base*8, (RB = nresults+1,) RC = (nargs+1)*8
2432 |->BC_CALL_Z: 2437 |->BC_CALL_Z:
2433 | mov RB, BASE // Save old BASE for vmeta_call. 2438 | mov RB, BASE // Save old BASE for vmeta_call.
2434 | ldrd CARG34, [BASE, RA]! 2439 | ldrd CARG34, [BASE, RA]!
@@ -2568,7 +2573,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2568 break; 2573 break;
2569 2574
2570 case BC_ISNEXT: 2575 case BC_ISNEXT:
2571 | // RA = base*8, RD = target (points to ITERN) 2576 | // RA = base*8, RC = target (points to ITERN)
2572 | add RA, BASE, RA 2577 | add RA, BASE, RA
2573 | add RC, PC, RC, lsl #2 2578 | add RC, PC, RC, lsl #2
2574 | ldrd CFUNC:CARG12, [RA, #-24] 2579 | ldrd CFUNC:CARG12, [RA, #-24]
@@ -2638,12 +2643,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2638 | bne <2 2643 | bne <2
2639 |3: 2644 |3:
2640 | decode_RA8 RA, INS 2645 | decode_RA8 RA, INS
2641 | sub BASE, CARG3, RA 2646 | sub CARG4, CARG3, RA
2642 | decode_RB8 RB, INS 2647 | decode_RB8 RB, INS
2643 | ldr LFUNC:CARG1, [BASE, FRAME_FUNC] 2648 | ldr LFUNC:CARG1, [CARG4, FRAME_FUNC]
2644 |5: 2649 |5:
2645 | cmp RB, RC // More results expected? 2650 | cmp RB, RC // More results expected?
2646 | bhi >6 2651 | bhi >6
2652 | mov BASE, CARG4
2647 | ldr CARG2, LFUNC:CARG1->field_pc 2653 | ldr CARG2, LFUNC:CARG1->field_pc
2648 | ins_next1 2654 | ins_next1
2649 | ins_next2 2655 | ins_next2
@@ -2652,7 +2658,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2652 | 2658 |
2653 |6: // Fill up results with nil. 2659 |6: // Fill up results with nil.
2654 | mvn CARG2, #~LJ_TNIL 2660 | mvn CARG2, #~LJ_TNIL
2655 | sub BASE, BASE, #8 2661 | add BASE, BASE, #8
2656 | add RC, RC, #8 2662 | add RC, RC, #8
2657 | str CARG2, [BASE, #-12] 2663 | str CARG2, [BASE, #-12]
2658 | b <5 2664 | b <5
@@ -2791,6 +2797,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2791 | bhs ->vmeta_for 2797 | bhs ->vmeta_for
2792 | cmp RB, #0 2798 | cmp RB, #0
2793 | strd CARG12, FOR_IDX 2799 | strd CARG12, FOR_IDX
2800 | strd CARG12, FOR_EXT
2794 | blt >8 2801 | blt >8
2795 } else { 2802 } else {
2796 | cmp CARG4, #0 2803 | cmp CARG4, #0
@@ -2906,6 +2913,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2906 | ins_next2 2913 | ins_next2
2907 |2: 2914 |2:
2908 | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. 2915 | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters.
2916 | mvn CARG4, #~LJ_TNIL
2909 | ble >3 2917 | ble >3
2910 if (op == BC_JFUNCF) { 2918 if (op == BC_JFUNCF) {
2911 | NYI 2919 | NYI
@@ -2914,8 +2922,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
2914 } 2922 }
2915 | 2923 |
2916 |3: // Clear missing parameters. 2924 |3: // Clear missing parameters.
2917 | mvn CARG1, #~LJ_TNIL 2925 | strd CARG34, [BASE, NARGS8:RC]
2918 | str CARG1, [BASE, NARGS8:RC]
2919 | add NARGS8:RC, NARGS8:RC, #8 2926 | add NARGS8:RC, NARGS8:RC, #8
2920 | b <2 2927 | b <2
2921 break; 2928 break;
diff --git a/src/lib_math.c b/src/lib_math.c
index 5843e2f5..fb038b1d 100644
--- a/src/lib_math.c
+++ b/src/lib_math.c
@@ -59,10 +59,20 @@ LJLIB_ASM(math_atan2) LJLIB_REC(math_binary IR_ATAN2)
59 lj_lib_checknum(L, 2); 59 lj_lib_checknum(L, 2);
60 return FFH_RETRY; 60 return FFH_RETRY;
61} 61}
62LJLIB_ASM_(math_ldexp) LJLIB_REC(math_binary IR_LDEXP)
63LJLIB_ASM_(math_pow) LJLIB_REC(.) 62LJLIB_ASM_(math_pow) LJLIB_REC(.)
64LJLIB_ASM_(math_fmod) 63LJLIB_ASM_(math_fmod)
65 64
65LJLIB_ASM(math_ldexp) LJLIB_REC(math_binary IR_LDEXP)
66{
67 lj_lib_checknum(L, 1);
68#if LJ_DUALNUM && !LJ_TARGET_X86ORX64
69 lj_lib_checkint(L, 2);
70#else
71 lj_lib_checknum(L, 2);
72#endif
73 return FFH_RETRY;
74}
75
66LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN) 76LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN)
67{ 77{
68 int i = 0; 78 int i = 0;