aboutsummaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorMike Pall <mike>2023-09-15 05:23:29 +0200
committerMike Pall <mike>2023-09-15 05:23:29 +0200
commitb36f9fad63de19074d97df787146056c028e8fba (patch)
treed8a0063e82bb132cd203869e61c920f4b8ada68e /src/host
parent8af63f992058ebbac2d72ef92811cf22a90fa347 (diff)
downloadluajit-b36f9fad63de19074d97df787146056c028e8fba.tar.gz
luajit-b36f9fad63de19074d97df787146056c028e8fba.tar.bz2
luajit-b36f9fad63de19074d97df787146056c028e8fba.zip
Windows/ARM64: Fix exception unwinding (again).
Thanks to Peter Cawley. #593
Diffstat (limited to 'src/host')
-rw-r--r--src/host/buildvm_peobj.c12
1 files changed, 5 insertions, 7 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);