diff options
Diffstat (limited to 'src/buildvm_arm.dasc')
-rw-r--r-- | src/buildvm_arm.dasc | 119 |
1 files changed, 106 insertions, 13 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index f2b08ed9..495181a1 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
@@ -336,7 +336,8 @@ static void build_subroutines(BuildCtx *ctx) | |||
336 | | | 336 | | |
337 | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | 337 | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. |
338 | | // (void *cframe) | 338 | | // (void *cframe) |
339 | | bic sp, CARG1, #~CFRAME_RAWMASK | 339 | | bic CARG1, CARG1, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. |
340 | | mov sp, CARG1 | ||
340 | |->vm_unwind_ff_eh: // Landing pad for external unwinder. | 341 | |->vm_unwind_ff_eh: // Landing pad for external unwinder. |
341 | | ldr L, SAVE_L | 342 | | ldr L, SAVE_L |
342 | | mov MASKR8, #255 | 343 | | mov MASKR8, #255 |
@@ -1921,6 +1922,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
1921 | | sub NARGS8:RC, CARG4, BASE | 1922 | | sub NARGS8:RC, CARG4, BASE |
1922 | | str CARG2, SAVE_PC // Invalidate for subsequent line hook. | 1923 | | str CARG2, SAVE_PC // Invalidate for subsequent line hook. |
1923 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | 1924 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] |
1925 | | ldr INS, [PC, #-4] | ||
1924 | | bx CRET1 | 1926 | | bx CRET1 |
1925 | | | 1927 | | |
1926 | |//----------------------------------------------------------------------- | 1928 | |//----------------------------------------------------------------------- |
@@ -1929,11 +1931,74 @@ static void build_subroutines(BuildCtx *ctx) | |||
1929 | | | 1931 | | |
1930 | |->vm_exit_handler: | 1932 | |->vm_exit_handler: |
1931 | #if LJ_HASJIT | 1933 | #if LJ_HASJIT |
1932 | | NYI | 1934 | | sub sp, sp, #12 |
1935 | | push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} | ||
1936 | | ldr CARG1, [sp, #64] // Load original value of lr. | ||
1937 | | ldr DISPATCH, [lr] // Load DISPATCH. | ||
1938 | | add CARG3, sp, #64 // Recompute original value of sp. | ||
1939 | | mv_vmstate CARG4, EXIT | ||
1940 | | str CARG3, [sp, #52] // Store sp in RID_SP | ||
1941 | | st_vmstate CARG4 | ||
1942 | | ldr CARG2, [CARG1, #-4]! // Get exit instruction. | ||
1943 | | str CARG1, [sp, #56] // Store exit pc in RID_LR and RID_PC. | ||
1944 | | str CARG1, [sp, #60] | ||
1945 | | lsl CARG2, CARG2, #8 | ||
1946 | | add CARG1, CARG1, CARG2, asr #6 | ||
1947 | | ldr CARG2, [lr, #4] // Load exit stub group offset. | ||
1948 | | sub CARG1, CARG1, lr | ||
1949 | | ldr L, [DISPATCH, #DISPATCH_GL(jit_L)] | ||
1950 | | add CARG1, CARG2, CARG1, lsr #2 // Compute exit number. | ||
1951 | | ldr BASE, [DISPATCH, #DISPATCH_GL(jit_base)] | ||
1952 | | str CARG1, [DISPATCH, #DISPATCH_J(exitno)] | ||
1953 | | mov CARG4, #0 | ||
1954 | | str L, [DISPATCH, #DISPATCH_J(L)] | ||
1955 | | str BASE, L->base | ||
1956 | | str CARG4, [DISPATCH, #DISPATCH_GL(jit_L)] | ||
1957 | | sub CARG1, DISPATCH, #-GG_DISP2J | ||
1958 | | mov CARG2, sp | ||
1959 | | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) | ||
1960 | | // Returns MULTRES (unscaled) or negated error code. | ||
1961 | | ldr CARG2, L->cframe | ||
1962 | | ldr BASE, L->base | ||
1963 | | bic CARG2, CARG2, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. | ||
1964 | | mov sp, CARG2 | ||
1965 | | ldr PC, SAVE_PC // Get SAVE_PC. | ||
1966 | | str L, SAVE_L // Set SAVE_L (on-trace resume/yield). | ||
1967 | | b >1 | ||
1933 | #endif | 1968 | #endif |
1934 | |->vm_exit_interp: | 1969 | |->vm_exit_interp: |
1970 | | // CARG1 = MULTRES or negated error code, BASE, PC and DISPATCH set. | ||
1935 | #if LJ_HASJIT | 1971 | #if LJ_HASJIT |
1936 | | NYI | 1972 | | ldr L, SAVE_L |
1973 | |1: | ||
1974 | | cmp CARG1, #0 | ||
1975 | | blt >3 // Check for error from exit. | ||
1976 | | lsl RC, CARG1, #3 | ||
1977 | | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | ||
1978 | | str RC, SAVE_MULTRES | ||
1979 | | mov CARG3, #0 | ||
1980 | | ldr CARG2, LFUNC:CARG2->field_pc | ||
1981 | | str CARG3, [DISPATCH, #DISPATCH_GL(jit_L)] | ||
1982 | | mv_vmstate CARG4, INTERP | ||
1983 | | ldr KBASE, [CARG2, #PC2PROTO(k)] | ||
1984 | | // Modified copy of ins_next which handles function header dispatch, too. | ||
1985 | | ldrb OP, [PC] | ||
1986 | | mov MASKR8, #255 | ||
1987 | | ldr INS, [PC], #4 | ||
1988 | | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | ||
1989 | | st_vmstate CARG4 | ||
1990 | | cmp OP, #BC_FUNCF // Function header? | ||
1991 | | ldr OP, [DISPATCH, OP, lsl #2] | ||
1992 | | decode_RA8 RA, INS | ||
1993 | | lsrlo RC, INS, #16 // No: Decode operands A*8 and D. | ||
1994 | | subhs RC, RC, #8 | ||
1995 | | addhs RA, RA, BASE // Yes: RA = BASE+framesize*8, RC = nargs*8 | ||
1996 | | bx OP | ||
1997 | | | ||
1998 | |3: // Rethrow error from the right C frame. | ||
1999 | | rsb CARG2, CARG1, #0 | ||
2000 | | mov CARG1, L | ||
2001 | | bl extern lj_err_throw // (lua_State *L, int errcode) | ||
1937 | #endif | 2002 | #endif |
1938 | | | 2003 | | |
1939 | |//----------------------------------------------------------------------- | 2004 | |//----------------------------------------------------------------------- |
@@ -1945,7 +2010,8 @@ static void build_subroutines(BuildCtx *ctx) | |||
1945 | |// double lj_vm_floor/ceil/trunc(double x); | 2010 | |// double lj_vm_floor/ceil/trunc(double x); |
1946 | |.macro vm_round, func | 2011 | |.macro vm_round, func |
1947 | |->vm_ .. func: | 2012 | |->vm_ .. func: |
1948 | | NYI | 2013 | | // NYI: Use internal implementation. |
2014 | | b extern func | ||
1949 | |.endmacro | 2015 | |.endmacro |
1950 | | | 2016 | | |
1951 | | vm_round floor | 2017 | | vm_round floor |
@@ -2022,7 +2088,30 @@ static void build_subroutines(BuildCtx *ctx) | |||
2022 | | eorlo CARG2, CARG2, #0x80000000 | 2088 | | eorlo CARG2, CARG2, #0x80000000 |
2023 | | biceq CARG2, CARG2, #0x80000000 | 2089 | | biceq CARG2, CARG2, #0x80000000 |
2024 | | bxls lr | 2090 | | bxls lr |
2091 | #if LJ_HASJIT | ||
2092 | | cmp OP, #9 | ||
2093 | | blo extern atan2 | ||
2094 | | beq >9 // No support needed for IR_LDEXP. | ||
2095 | | cmp OP, #11 | ||
2096 | | bhi >9 | ||
2097 | | push {r4, lr} | ||
2098 | | beq >1 | ||
2099 | | // IR_MIN | ||
2100 | | bl extern __aeabi_cdcmple | ||
2101 | | movhi CARG1, CARG3 | ||
2102 | | movhi CARG2, CARG4 | ||
2103 | | pop {r4, pc} | ||
2104 | |9: | ||
2105 | | NYI // Bad op. | ||
2106 | | | ||
2107 | |1: // IR_MAX | ||
2108 | | bl extern __aeabi_cdcmple | ||
2109 | | movlo CARG1, CARG3 | ||
2110 | | movlo CARG2, CARG4 | ||
2111 | | pop {r4, pc} | ||
2112 | #else | ||
2025 | | NYI // Other operations only needed by JIT compiler. | 2113 | | NYI // Other operations only needed by JIT compiler. |
2114 | #endif | ||
2026 | | | 2115 | | |
2027 | |//----------------------------------------------------------------------- | 2116 | |//----------------------------------------------------------------------- |
2028 | |//-- Miscellaneous functions -------------------------------------------- | 2117 | |//-- Miscellaneous functions -------------------------------------------- |
@@ -3568,13 +3657,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3568 | if (op == BC_FORI) { | 3657 | if (op == BC_FORI) { |
3569 | | subgt PC, RC, #0x20000 | 3658 | | subgt PC, RC, #0x20000 |
3570 | } else if (op == BC_JFORI) { | 3659 | } else if (op == BC_JFORI) { |
3571 | | subgt PC, RC, #0x20000 | 3660 | | sub PC, RC, #0x20000 |
3572 | | decode_RD RC, INS | 3661 | | ldrhle RC, [PC, #-2] |
3573 | | ble =>BC_JLOOP | ||
3574 | } else if (op == BC_IFORL) { | 3662 | } else if (op == BC_IFORL) { |
3575 | | suble PC, RC, #0x20000 | 3663 | | suble PC, RC, #0x20000 |
3576 | } else { | ||
3577 | | ble =>BC_JLOOP | ||
3578 | } | 3664 | } |
3579 | if (vk) { | 3665 | if (vk) { |
3580 | | strd CARG12, FOR_IDX | 3666 | | strd CARG12, FOR_IDX |
@@ -3583,6 +3669,9 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3583 | | ins_next1 | 3669 | | ins_next1 |
3584 | | ins_next2 | 3670 | | ins_next2 |
3585 | | strd CARG12, FOR_EXT | 3671 | | strd CARG12, FOR_EXT |
3672 | if (op == BC_JFORI || op == BC_JFORL) { | ||
3673 | | ble =>BC_JLOOP | ||
3674 | } | ||
3586 | |3: | 3675 | |3: |
3587 | | ins_next3 | 3676 | | ins_next3 |
3588 | | | 3677 | | |
@@ -3616,8 +3705,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3616 | if (op == BC_FORI) { | 3705 | if (op == BC_FORI) { |
3617 | | subhi PC, RC, #0x20000 | 3706 | | subhi PC, RC, #0x20000 |
3618 | } else if (op == BC_JFORI) { | 3707 | } else if (op == BC_JFORI) { |
3619 | | subhi PC, RC, #0x20000 | 3708 | | sub PC, RC, #0x20000 |
3620 | | decode_RD RC, INS | 3709 | | ldrhls RC, [PC, #-2] |
3621 | | bls =>BC_JLOOP | 3710 | | bls =>BC_JLOOP |
3622 | } else if (op == BC_IFORL) { | 3711 | } else if (op == BC_IFORL) { |
3623 | | subls PC, RC, #0x20000 | 3712 | | subls PC, RC, #0x20000 |
@@ -3687,7 +3776,9 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3687 | #if LJ_HASJIT | 3776 | #if LJ_HASJIT |
3688 | | // RA = base (ignored), RC = traceno | 3777 | | // RA = base (ignored), RC = traceno |
3689 | | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] | 3778 | | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] |
3779 | | mov CARG2, #0 // Traces on ARM don't store the trace number, so use 0. | ||
3690 | | ldr TRACE:RC, [CARG1, RC, lsl #2] | 3780 | | ldr TRACE:RC, [CARG1, RC, lsl #2] |
3781 | | st_vmstate CARG2 | ||
3691 | | ldr RA, TRACE:RC->mcode | 3782 | | ldr RA, TRACE:RC->mcode |
3692 | | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] | 3783 | | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] |
3693 | | str L, [DISPATCH, #DISPATCH_GL(jit_L)] | 3784 | | str L, [DISPATCH, #DISPATCH_GL(jit_L)] |
@@ -3723,8 +3814,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3723 | | ldr KBASE, [PC, #-4+PC2PROTO(k)] | 3814 | | ldr KBASE, [PC, #-4+PC2PROTO(k)] |
3724 | | cmp RA, CARG1 | 3815 | | cmp RA, CARG1 |
3725 | | bhi ->vm_growstack_l | 3816 | | bhi ->vm_growstack_l |
3726 | | ins_next1 | 3817 | if (op != BC_JFUNCF) { |
3727 | | ins_next2 | 3818 | | ins_next1 |
3819 | | ins_next2 | ||
3820 | } | ||
3728 | |2: | 3821 | |2: |
3729 | | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. | 3822 | | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. |
3730 | | mvn CARG4, #~LJ_TNIL | 3823 | | mvn CARG4, #~LJ_TNIL |