aboutsummaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorMike Pall <mike>2023-09-11 13:33:27 +0200
committerMike Pall <mike>2023-09-11 13:33:27 +0200
commitf63bc569fab1450def4c817f100e580dddb425c5 (patch)
treee3cabaf5b138f9affe4e004f741b48467c2f27f4 /src/host
parent836ab4227a1b024321731fe5a5059368c9f0dff7 (diff)
downloadluajit-f63bc569fab1450def4c817f100e580dddb425c5.tar.gz
luajit-f63bc569fab1450def4c817f100e580dddb425c5.tar.bz2
luajit-f63bc569fab1450def4c817f100e580dddb425c5.zip
Windows/ARM64: Fix exception unwinding.
Thanks to Peter Cawley. #593
Diffstat (limited to 'src/host')
-rw-r--r--src/host/buildvm_peobj.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/host/buildvm_peobj.c b/src/host/buildvm_peobj.c
index fc3ef71a..cdbb79b6 100644
--- a/src/host/buildvm_peobj.c
+++ b/src/host/buildvm_peobj.c
@@ -354,7 +354,7 @@ void emit_peobj(BuildCtx *ctx)
354#define CBE16(x) (*p = ((x) >> 8) & 0xff, p[1] = (x) & 0xff, p += 2) 354#define CBE16(x) (*p = ((x) >> 8) & 0xff, p[1] = (x) & 0xff, p += 2)
355#define CALLOC_S(s) (*p++ = ((s) >> 4)) /* s < 512 */ 355#define CALLOC_S(s) (*p++ = ((s) >> 4)) /* s < 512 */
356#define CSAVE_FPLR(o) (*p++ = 0x40 | ((o) >> 3)) /* o <= 504 */ 356#define CSAVE_FPLR(o) (*p++ = 0x40 | ((o) >> 3)) /* o <= 504 */
357#define CSAVE_REGP(r,o) CBE16(0xc800 | (((r)-19)<< 6) | ((o) >> 3)) 357#define CSAVE_REGP(r,o) CBE16(0xc800 | (((r) - 19) << 6) | ((o) >> 3))
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)
@@ -362,6 +362,7 @@ void emit_peobj(BuildCtx *ctx)
362#define CSAVE_FREGS(r1,r2,o1) do { \ 362#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); \ 363 int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_FREGP(r, o); \
364} while (0) 364} while (0)
365#define CSAVE_REG(r,o) CBE16(0xd000 | (((r) - 19) << 6) | (~(o) >> 3))
365#define CSAVE_REGX(r,o) CBE16(0xd400 | (((r) - 19) << 5) | (~(o) >> 3)) 366#define CSAVE_REGX(r,o) CBE16(0xd400 | (((r) - 19) << 5) | (~(o) >> 3))
366#define CADD_FP(s) CBE16(0xe200 | ((s) >> 3)) /* s < 8*256 */ 367#define CADD_FP(s) CBE16(0xe200 | ((s) >> 3)) /* s < 8*256 */
367#define CODE_NOP 0xe3 368#define CODE_NOP 0xe3
@@ -373,12 +374,11 @@ void emit_peobj(BuildCtx *ctx)
373 374
374 /* Unwind codes for .text section with handler. */ 375 /* Unwind codes for .text section with handler. */
375 p = uwc; 376 p = uwc;
376 CALLOC_S(208); /* +1 */
377 CSAVE_FPLR(192); /* +1 */
378 CADD_FP(192); /* +2 */
379 CSAVE_REGS(19, 28, 184); /* +5*2 */ 377 CSAVE_REGS(19, 28, 184); /* +5*2 */
380 CSAVE_FREGS(8, 15, 104); /* +4*2 */ 378 CSAVE_FREGS(8, 15, 104); /* +4*2 */
381 CEND_ALIGN; /* +1 +1 -> 24 */ 379 CSAVE_FPLR(192); /* +1 */
380 CALLOC_S(208); /* +1 */
381 CEND_ALIGN; /* +1 +3 -> 24 */
382 382
383 u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2); 383 u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2);
384 owrite(ctx, &u32, 4); 384 owrite(ctx, &u32, 4);
@@ -389,9 +389,9 @@ void emit_peobj(BuildCtx *ctx)
389 389
390 /* Unwind codes for vm_ffi_call without handler. */ 390 /* Unwind codes for vm_ffi_call without handler. */
391 p = uwc; 391 p = uwc;
392 CSAVE_FPLR(16); /* +1 */
393 CADD_FP(16); /* +2 */ 392 CADD_FP(16); /* +2 */
394 CSAVE_REGX(19, -24); /* +2 */ 393 CSAVE_FPLR(16); /* +1 */
394 CSAVE_REG(19, 8); /* +2 */
395 CSAVE_REGX(20, -32); /* +2 */ 395 CSAVE_REGX(20, -32); /* +2 */
396 CEND_ALIGN; /* +1 +0 -> 8 */ 396 CEND_ALIGN; /* +1 +0 -> 8 */
397 397