diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/host/buildvm_peobj.c | 12 | ||||
| -rw-r--r-- | src/vm_arm64.dasc | 42 |
2 files changed, 38 insertions, 16 deletions
diff --git a/src/host/buildvm_peobj.c b/src/host/buildvm_peobj.c index 667cc3fc..7ce3b05a 100644 --- a/src/host/buildvm_peobj.c +++ b/src/host/buildvm_peobj.c | |||
| @@ -358,12 +358,11 @@ void emit_peobj(BuildCtx *ctx) | |||
| 358 | #define CSAVE_REGS(r1,r2,o1) do { \ | 358 | #define CSAVE_REGS(r1,r2,o1) do { \ |
| 359 | int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_REGP(r, o); \ | 359 | int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_REGP(r, o); \ |
| 360 | } while (0) | 360 | } while (0) |
| 361 | #define CSAVE_REGPX(r,o) CBE16(0xcc00 | (((r) - 19) << 6) | (~(o) >> 3)) | ||
| 361 | #define CSAVE_FREGP(r,o) CBE16(0xd800 | (((r) - 8) << 6) | ((o) >> 3)) | 362 | #define CSAVE_FREGP(r,o) CBE16(0xd800 | (((r) - 8) << 6) | ((o) >> 3)) |
| 362 | #define CSAVE_FREGS(r1,r2,o1) do { \ | 363 | #define CSAVE_FREGS(r1,r2,o1) do { \ |
| 363 | int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_FREGP(r, o); \ | 364 | int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_FREGP(r, o); \ |
| 364 | } while (0) | 365 | } while (0) |
| 365 | #define CSAVE_REG(r,o) CBE16(0xd000 | (((r) - 19) << 6) | ((o) >> 3)) | ||
| 366 | #define CSAVE_REGX(r,o) CBE16(0xd400 | (((r) - 19) << 5) | (~(o) >> 3)) | ||
| 367 | #define CADD_FP(s) CBE16(0xe200 | ((s) >> 3)) /* s < 8*256 */ | 366 | #define CADD_FP(s) CBE16(0xe200 | ((s) >> 3)) /* s < 8*256 */ |
| 368 | #define CODE_NOP 0xe3 | 367 | #define CODE_NOP 0xe3 |
| 369 | #define CODE_END 0xe4 | 368 | #define CODE_END 0xe4 |
| @@ -374,8 +373,8 @@ void emit_peobj(BuildCtx *ctx) | |||
| 374 | 373 | ||
| 375 | /* Unwind codes for .text section with handler. */ | 374 | /* Unwind codes for .text section with handler. */ |
| 376 | p = uwc; | 375 | p = uwc; |
| 377 | CSAVE_REGS(19, 28, 184); /* +5*2 */ | 376 | CSAVE_REGS(19, 28, 176); /* +5*2 */ |
| 378 | CSAVE_FREGS(8, 15, 104); /* +4*2 */ | 377 | CSAVE_FREGS(8, 15, 96); /* +4*2 */ |
| 379 | CSAVE_FPLR(192); /* +1 */ | 378 | CSAVE_FPLR(192); /* +1 */ |
| 380 | CALLOC_S(208); /* +1 */ | 379 | CALLOC_S(208); /* +1 */ |
| 381 | CEND_ALIGN; /* +1 +3 -> 24 */ | 380 | CEND_ALIGN; /* +1 +3 -> 24 */ |
| @@ -391,9 +390,8 @@ void emit_peobj(BuildCtx *ctx) | |||
| 391 | p = uwc; | 390 | p = uwc; |
| 392 | CADD_FP(16); /* +2 */ | 391 | CADD_FP(16); /* +2 */ |
| 393 | CSAVE_FPLR(16); /* +1 */ | 392 | CSAVE_FPLR(16); /* +1 */ |
| 394 | CSAVE_REG(19, 8); /* +2 */ | 393 | CSAVE_REGPX(19, -32); /* +2 */ |
| 395 | CSAVE_REGX(20, -32); /* +2 */ | 394 | CEND_ALIGN; /* +1 +2 -> 8 */ |
| 396 | CEND_ALIGN; /* +1 +0 -> 8 */ | ||
| 397 | 395 | ||
| 398 | u32 = ((8u >> 2) << 27) | (((uint32_t)ctx->codesz - fcofs) >> 2); | 396 | u32 = ((8u >> 2) << 27) | (((uint32_t)ctx->codesz - fcofs) >> 2); |
| 399 | owrite(ctx, &u32, 4); | 397 | owrite(ctx, &u32, 4); |
diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc index b94a9c0e..d622d2a0 100644 --- a/src/vm_arm64.dasc +++ b/src/vm_arm64.dasc | |||
| @@ -113,13 +113,37 @@ | |||
| 113 | | | 113 | | |
| 114 | |.define TMPDofs, #24 | 114 | |.define TMPDofs, #24 |
| 115 | | | 115 | | |
| 116 | |.if WIN | ||
| 117 | |// Windows unwind data is suited to r1 stored first. | ||
| 118 | |.macro stp_unwind, r1, r2, where | ||
| 119 | | stp r1, r2, where | ||
| 120 | |.endmacro | ||
| 121 | |.macro ldp_unwind, r1, r2, where | ||
| 122 | | ldp r1, r2, where | ||
| 123 | |.endmacro | ||
| 124 | |.macro ldp_unwind, r1, r2, where, post_index | ||
| 125 | | ldp r1, r2, where, post_index | ||
| 126 | |.endmacro | ||
| 127 | |.else | ||
| 128 | |// Otherwise store r2 first for compact unwind info (OSX). | ||
| 129 | |.macro stp_unwind, r1, r2, where | ||
| 130 | | stp r2, r1, where | ||
| 131 | |.endmacro | ||
| 132 | |.macro ldp_unwind, r1, r2, where | ||
| 133 | | ldp r2, r1, where | ||
| 134 | |.endmacro | ||
| 135 | |.macro ldp_unwind, r1, r2, where, post_index | ||
| 136 | | ldp r2, r1, where, post_index | ||
| 137 | |.endmacro | ||
| 138 | |.endif | ||
| 139 | | | ||
| 116 | |.macro save_, gpr1, gpr2, fpr1, fpr2 | 140 | |.macro save_, gpr1, gpr2, fpr1, fpr2 |
| 117 | | stp d..fpr2, d..fpr1, [sp, # SAVE_FPR_+(14-fpr1)*8] | 141 | | stp_unwind d..fpr1, d..fpr2, [sp, # SAVE_FPR_+(14-fpr1)*8] |
| 118 | | stp x..gpr2, x..gpr1, [sp, # SAVE_GPR_+(27-gpr1)*8] | 142 | | stp_unwind x..gpr1, x..gpr2, [sp, # SAVE_GPR_+(27-gpr1)*8] |
| 119 | |.endmacro | 143 | |.endmacro |
| 120 | |.macro rest_, gpr1, gpr2, fpr1, fpr2 | 144 | |.macro rest_, gpr1, gpr2, fpr1, fpr2 |
| 121 | | ldp d..fpr2, d..fpr1, [sp, # SAVE_FPR_+(14-fpr1)*8] | 145 | | ldp_unwind d..fpr1, d..fpr2, [sp, # SAVE_FPR_+(14-fpr1)*8] |
| 122 | | ldp x..gpr2, x..gpr1, [sp, # SAVE_GPR_+(27-gpr1)*8] | 146 | | ldp_unwind x..gpr1, x..gpr2, [sp, # SAVE_GPR_+(27-gpr1)*8] |
| 123 | |.endmacro | 147 | |.endmacro |
| 124 | | | 148 | | |
| 125 | |.macro saveregs | 149 | |.macro saveregs |
| @@ -127,14 +151,14 @@ | |||
| 127 | | sub sp, sp, # CFRAME_SPACE | 151 | | sub sp, sp, # CFRAME_SPACE |
| 128 | | stp fp, lr, [sp, # SAVE_FP_LR_] | 152 | | stp fp, lr, [sp, # SAVE_FP_LR_] |
| 129 | | add fp, sp, # SAVE_FP_LR_ | 153 | | add fp, sp, # SAVE_FP_LR_ |
| 130 | | stp x20, x19, [sp, # SAVE_GPR_+(27-19)*8] | 154 | | stp_unwind x19, x20, [sp, # SAVE_GPR_+(27-19)*8] |
| 131 | | save_ 21, 22, 8, 9 | 155 | | save_ 21, 22, 8, 9 |
| 132 | | save_ 23, 24, 10, 11 | 156 | | save_ 23, 24, 10, 11 |
| 133 | | save_ 25, 26, 12, 13 | 157 | | save_ 25, 26, 12, 13 |
| 134 | | save_ 27, 28, 14, 15 | 158 | | save_ 27, 28, 14, 15 |
| 135 | |.endmacro | 159 | |.endmacro |
| 136 | |.macro restoreregs | 160 | |.macro restoreregs |
| 137 | | ldp x20, x19, [sp, # SAVE_GPR_+(27-19)*8] | 161 | | ldp_unwind x19, x20, [sp, # SAVE_GPR_+(27-19)*8] |
| 138 | | rest_ 21, 22, 8, 9 | 162 | | rest_ 21, 22, 8, 9 |
| 139 | | rest_ 23, 24, 10, 11 | 163 | | rest_ 23, 24, 10, 11 |
| 140 | | rest_ 25, 26, 12, 13 | 164 | | rest_ 25, 26, 12, 13 |
| @@ -2162,7 +2186,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 2162 | |//----------------------------------------------------------------------- | 2186 | |//----------------------------------------------------------------------- |
| 2163 | | | 2187 | | |
| 2164 | |// Handler for callback functions. | 2188 | |// Handler for callback functions. |
| 2165 | |// Saveregs already performed. Callback slot number in [sp], g in r12. | 2189 | |// Saveregs already performed. Callback slot number in w9, g in x10. |
| 2166 | |->vm_ffi_callback: | 2190 | |->vm_ffi_callback: |
| 2167 | |.if FFI | 2191 | |.if FFI |
| 2168 | |.type CTSTATE, CTState, PC | 2192 | |.type CTSTATE, CTState, PC |
| @@ -2215,7 +2239,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 2215 | |.if FFI | 2239 | |.if FFI |
| 2216 | | .type CCSTATE, CCallState, x19 | 2240 | | .type CCSTATE, CCallState, x19 |
| 2217 | | sp_auth | 2241 | | sp_auth |
| 2218 | | stp x20, CCSTATE, [sp, #-32]! | 2242 | | stp_unwind CCSTATE, x20, [sp, #-32]! |
| 2219 | | stp fp, lr, [sp, #16] | 2243 | | stp fp, lr, [sp, #16] |
| 2220 | | add fp, sp, #16 | 2244 | | add fp, sp, #16 |
| 2221 | | mov CCSTATE, x0 | 2245 | | mov CCSTATE, x0 |
| @@ -2247,7 +2271,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 2247 | | stp d0, d1, CCSTATE->fpr[0] | 2271 | | stp d0, d1, CCSTATE->fpr[0] |
| 2248 | | stp d2, d3, CCSTATE->fpr[2] | 2272 | | stp d2, d3, CCSTATE->fpr[2] |
| 2249 | | ldp fp, lr, [sp, #16] | 2273 | | ldp fp, lr, [sp, #16] |
| 2250 | | ldp x20, CCSTATE, [sp], #32 | 2274 | | ldp_unwind CCSTATE, x20, [sp], #32 |
| 2251 | | ret_auth | 2275 | | ret_auth |
| 2252 | |.endif | 2276 | |.endif |
| 2253 | |// Note: vm_ffi_call must be the last function in this object file! | 2277 | |// Note: vm_ffi_call must be the last function in this object file! |
