aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vm_arm.dasc22
-rw-r--r--src/vm_mips.dasc22
-rw-r--r--src/vm_ppc.dasc20
-rw-r--r--src/vm_x86.dasc25
4 files changed, 79 insertions, 10 deletions
diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc
index 559d20bd..8a48016e 100644
--- a/src/vm_arm.dasc
+++ b/src/vm_arm.dasc
@@ -2109,6 +2109,8 @@ static void build_subroutines(BuildCtx *ctx)
2109 | bhi >9 // More results wanted? 2109 | bhi >9 // More results wanted?
2110 | 2110 |
2111 | ldr TRACE:RA, [CARG1, CARG3, lsl #2] 2111 | ldr TRACE:RA, [CARG1, CARG3, lsl #2]
2112 | cmp TRACE:RA, #0
2113 | beq ->cont_nop
2112 | ldrh RC, TRACE:RA->link 2114 | ldrh RC, TRACE:RA->link
2113 | cmp RC, CARG3 2115 | cmp RC, CARG3
2114 | beq ->cont_nop // Blacklisted. 2116 | beq ->cont_nop // Blacklisted.
@@ -2193,7 +2195,7 @@ static void build_subroutines(BuildCtx *ctx)
2193 | ldr L, SAVE_L 2195 | ldr L, SAVE_L
2194 |1: 2196 |1:
2195 | cmp CARG1, #0 2197 | cmp CARG1, #0
2196 | blt >3 // Check for error from exit. 2198 | blt >9 // Check for error from exit.
2197 | lsl RC, CARG1, #3 2199 | lsl RC, CARG1, #3
2198 | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] 2200 | ldr LFUNC:CARG2, [BASE, FRAME_FUNC]
2199 | str RC, SAVE_MULTRES 2201 | str RC, SAVE_MULTRES
@@ -2209,6 +2211,9 @@ static void build_subroutines(BuildCtx *ctx)
2209 | ldr INS, [PC], #4 2211 | ldr INS, [PC], #4
2210 | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. 2212 | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8.
2211 | st_vmstate CARG4 2213 | st_vmstate CARG4
2214 | cmp OP, #BC_FUNCC+2 // Fast function?
2215 | bhs >4
2216 |2:
2212 | cmp OP, #BC_FUNCF // Function header? 2217 | cmp OP, #BC_FUNCF // Function header?
2213 | ldr OP, [DISPATCH, OP, lsl #2] 2218 | ldr OP, [DISPATCH, OP, lsl #2]
2214 | decode_RA8 RA, INS 2219 | decode_RA8 RA, INS
@@ -2218,7 +2223,20 @@ static void build_subroutines(BuildCtx *ctx)
2218 | ldrhs CARG3, [BASE, FRAME_FUNC] 2223 | ldrhs CARG3, [BASE, FRAME_FUNC]
2219 | bx OP 2224 | bx OP
2220 | 2225 |
2221 |3: // Rethrow error from the right C frame. 2226 |4: // Check frame below fast function.
2227 | ldr CARG1, [BASE, FRAME_PC]
2228 | ands CARG2, CARG1, #FRAME_TYPE
2229 | bne <2 // Trace stitching continuation?
2230 | // Otherwise set KBASE for Lua function below fast function.
2231 | ldr CARG3, [CARG1, #-4]
2232 | decode_RA8 CARG1, CARG3
2233 | sub CARG2, BASE, CARG1
2234 | ldr LFUNC:CARG3, [CARG2, #-16]
2235 | ldr CARG3, LFUNC:CARG3->field_pc
2236 | ldr KBASE, [CARG3, #PC2PROTO(k)]
2237 | b <2
2238 |
2239 |9: // Rethrow error from the right C frame.
2222 | rsb CARG2, CARG1, #0 2240 | rsb CARG2, CARG1, #0
2223 | mov CARG1, L 2241 | mov CARG1, L
2224 | bl extern lj_err_throw // (lua_State *L, int errcode) 2242 | bl extern lj_err_throw // (lua_State *L, int errcode)
diff --git a/src/vm_mips.dasc b/src/vm_mips.dasc
index 094ffe38..4aaff4b0 100644
--- a/src/vm_mips.dasc
+++ b/src/vm_mips.dasc
@@ -2043,6 +2043,8 @@ static void build_subroutines(BuildCtx *ctx)
2043 | 2043 |
2044 | addu TMP2, TMP1, TMP2 2044 | addu TMP2, TMP1, TMP2
2045 | lw TRACE:TMP2, 0(TMP2) 2045 | lw TRACE:TMP2, 0(TMP2)
2046 | beqz TRACE:TMP2, ->cont_nop
2047 |. nop
2046 | lhu RD, TRACE:TMP2->link 2048 | lhu RD, TRACE:TMP2->link
2047 | beq RD, TMP3, ->cont_nop // Blacklisted. 2049 | beq RD, TMP3, ->cont_nop // Blacklisted.
2048 |. load_got lj_dispatch_stitch 2050 |. load_got lj_dispatch_stitch
@@ -2144,7 +2146,7 @@ static void build_subroutines(BuildCtx *ctx)
2144 | addiu DISPATCH, JGL, -GG_DISP2G-32768 2146 | addiu DISPATCH, JGL, -GG_DISP2G-32768
2145 | sw BASE, L->base 2147 | sw BASE, L->base
2146 |1: 2148 |1:
2147 | bltz CRET1, >3 // Check for error from exit. 2149 | bltz CRET1, >9 // Check for error from exit.
2148 |. lw LFUNC:RB, FRAME_FUNC(BASE) 2150 |. lw LFUNC:RB, FRAME_FUNC(BASE)
2149 | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). 2151 | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float).
2150 | sll MULTRES, CRET1, 3 2152 | sll MULTRES, CRET1, 3
@@ -2172,11 +2174,27 @@ static void build_subroutines(BuildCtx *ctx)
2172 | jr AT 2174 | jr AT
2173 |. decode_RD8b RD 2175 |. decode_RD8b RD
2174 |2: 2176 |2:
2177 | sltiu TMP2, TMP1, (BC_FUNCC+2)*4 // Fast function?
2178 | bnez TMP2, >3
2179 |. lw TMP1, FRAME_PC(BASE)
2180 | // Check frame below fast function.
2181 | andi TMP0, TMP1, FRAME_TYPE
2182 | bnez TMP0, >3 // Trace stitching continuation?
2183 |. nop
2184 | // Otherwise set KBASE for Lua function below fast function.
2185 | lw TMP2, -4(TMP1)
2186 | decode_RA8a TMP0, TMP2
2187 | decode_RA8b TMP0
2188 | subu TMP1, BASE, TMP0
2189 | lw LFUNC:TMP2, -8+FRAME_FUNC(TMP1)
2190 | lw TMP1, LFUNC:TMP2->pc
2191 | lw KBASE, PC2PROTO(k)(TMP1)
2192 |3:
2175 | addiu RC, MULTRES, -8 2193 | addiu RC, MULTRES, -8
2176 | jr AT 2194 | jr AT
2177 |. addu RA, RA, BASE 2195 |. addu RA, RA, BASE
2178 | 2196 |
2179 |3: // Rethrow error from the right C frame. 2197 |9: // Rethrow error from the right C frame.
2180 | load_got lj_err_throw 2198 | load_got lj_err_throw
2181 | negu CARG2, CRET1 2199 | negu CARG2, CRET1
2182 | call_intern lj_err_throw // (lua_State *L, int errcode) 2200 | call_intern lj_err_throw // (lua_State *L, int errcode)
diff --git a/src/vm_ppc.dasc b/src/vm_ppc.dasc
index c21f5c43..1d5446c2 100644
--- a/src/vm_ppc.dasc
+++ b/src/vm_ppc.dasc
@@ -2531,6 +2531,8 @@ static void build_subroutines(BuildCtx *ctx)
2531 | 2531 |
2532 | slwi TMP2, TMP3, 2 2532 | slwi TMP2, TMP3, 2
2533 | lwzx TRACE:TMP2, TMP1, TMP2 2533 | lwzx TRACE:TMP2, TMP1, TMP2
2534 | cmpwi TRACE:TMP2, 0
2535 | beq ->cont_nop
2534 | lhz RD, TRACE:TMP2->link 2536 | lhz RD, TRACE:TMP2->link
2535 | cmpw RD, TMP3 2537 | cmpw RD, TMP3
2536 | cmpwi cr1, RD, 0 2538 | cmpwi cr1, RD, 0
@@ -2637,7 +2639,7 @@ static void build_subroutines(BuildCtx *ctx)
2637 | stp BASE, L->base 2639 | stp BASE, L->base
2638 |1: 2640 |1:
2639 | cmpwi CARG1, 0 2641 | cmpwi CARG1, 0
2640 | blt >3 // Check for error from exit. 2642 | blt >9 // Check for error from exit.
2641 | lwz LFUNC:RB, FRAME_FUNC(BASE) 2643 | lwz LFUNC:RB, FRAME_FUNC(BASE)
2642 | slwi MULTRES, CARG1, 3 2644 | slwi MULTRES, CARG1, 3
2643 | li TMP2, 0 2645 | li TMP2, 0
@@ -2673,11 +2675,25 @@ static void build_subroutines(BuildCtx *ctx)
2673 | decode_RC8 RC, INS 2675 | decode_RC8 RC, INS
2674 | bctr 2676 | bctr
2675 |2: 2677 |2:
2678 | cmplwi TMP1, (BC_FUNCC+2)*4 // Fast function?
2679 | blt >3
2680 | // Check frame below fast function.
2681 | lwz TMP1, FRAME_PC(BASE)
2682 | andix. TMP0, TMP1, FRAME_TYPE
2683 | bney >3 // Trace stitching continuation?
2684 | // Otherwise set KBASE for Lua function below fast function.
2685 | lwz TMP2, -4(TMP1)
2686 | decode_RA8 TMP0, TMP2
2687 | sub TMP1, BASE, TMP0
2688 | lwz LFUNC:TMP2, -12(TMP1)
2689 | lwz TMP1, LFUNC:TMP2->pc
2690 | lwz KBASE, PC2PROTO(k)(TMP1)
2691 |3:
2676 | subi RC, MULTRES, 8 2692 | subi RC, MULTRES, 8
2677 | add RA, RA, BASE 2693 | add RA, RA, BASE
2678 | bctr 2694 | bctr
2679 | 2695 |
2680 |3: // Rethrow error from the right C frame. 2696 |9: // Rethrow error from the right C frame.
2681 | neg CARG2, CARG1 2697 | neg CARG2, CARG1
2682 | mr CARG1, L 2698 | mr CARG1, L
2683 | bl extern lj_err_throw // (lua_State *L, int errcode) 2699 | bl extern lj_err_throw // (lua_State *L, int errcode)
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index c2f03d80..451c246b 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -2697,6 +2697,8 @@ static void build_subroutines(BuildCtx *ctx)
2697 | mov RB, TMP1 // Get previous trace number. 2697 | mov RB, TMP1 // Get previous trace number.
2698 | mov RA, [DISPATCH+DISPATCH_J(trace)] 2698 | mov RA, [DISPATCH+DISPATCH_J(trace)]
2699 | mov TRACE:RD, [RA+RB*4] 2699 | mov TRACE:RD, [RA+RB*4]
2700 | test TRACE:RD, TRACE:RD
2701 | jz ->cont_nop
2700 | movzx RD, word TRACE:RD->link 2702 | movzx RD, word TRACE:RD->link
2701 | cmp RD, RB 2703 | cmp RD, RB
2702 | je ->cont_nop // Blacklisted. 2704 | je ->cont_nop // Blacklisted.
@@ -2844,7 +2846,7 @@ static void build_subroutines(BuildCtx *ctx)
2844 | mov r13, TMPa 2846 | mov r13, TMPa
2845 | mov r12, TMPQ 2847 | mov r12, TMPQ
2846 |.endif 2848 |.endif
2847 | test RD, RD; js >3 // Check for error from exit. 2849 | test RD, RD; js >9 // Check for error from exit.
2848 | mov L:RB, SAVE_L 2850 | mov L:RB, SAVE_L
2849 | mov MULTRES, RD 2851 | mov MULTRES, RD
2850 | mov LFUNC:KBASE, [BASE-8] 2852 | mov LFUNC:KBASE, [BASE-8]
@@ -2860,16 +2862,31 @@ static void build_subroutines(BuildCtx *ctx)
2860 | add PC, 4 2862 | add PC, 4
2861 | shr RC, 16 2863 | shr RC, 16
2862 | cmp OP, BC_FUNCF // Function header? 2864 | cmp OP, BC_FUNCF // Function header?
2863 | jb >2 2865 | jb >3
2864 | mov RC, MULTRES // RC/RD holds nres+1. 2866 | cmp OP, BC_FUNCC+2 // Fast function?
2867 | jae >4
2865 |2: 2868 |2:
2869 | mov RC, MULTRES // RC/RD holds nres+1.
2870 |3:
2866 |.if X64 2871 |.if X64
2867 | jmp aword [DISPATCH+OP*8] 2872 | jmp aword [DISPATCH+OP*8]
2868 |.else 2873 |.else
2869 | jmp aword [DISPATCH+OP*4] 2874 | jmp aword [DISPATCH+OP*4]
2870 |.endif 2875 |.endif
2871 | 2876 |
2872 |3: // Rethrow error from the right C frame. 2877 |4: // Check frame below fast function.
2878 | mov RC, [BASE-4]
2879 | test RC, FRAME_TYPE
2880 | jnz <2 // Trace stitching continuation?
2881 | // Otherwise set KBASE for Lua function below fast function.
2882 | movzx RC, byte [RC-3]
2883 | not RCa
2884 | mov LFUNC:KBASE, [BASE+RC*8-8]
2885 | mov KBASE, LFUNC:KBASE->pc
2886 | mov KBASE, [KBASE+PC2PROTO(k)]
2887 | jmp <2
2888 |
2889 |9: // Rethrow error from the right C frame.
2873 | neg RD 2890 | neg RD
2874 | mov FCARG1, L:RB 2891 | mov FCARG1, L:RB
2875 | mov FCARG2, RD 2892 | mov FCARG2, RD