Skip to content

Commit b24a074

Browse files
committed
Fixed async exceptions on arm64
The following tests - tests/lib-systhreads/eintr.ml and tests/async-exns/async_exns_1 were failing. This patch loads the trap ptr into Caml_state->async_exception_pointer in arm64.S which fixes the test cases.
1 parent 9f135a4 commit b24a074

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ocaml/runtime/arm64.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,19 @@ L(jump_to_caml):
338338
ldr x8, Caml_state(bottom_of_stack)
339339
ldr x9, Caml_state(last_return_address)
340340
ldr x10, Caml_state(gc_regs)
341+
ldr x11, Caml_state(async_exception_pointer)
341342
stp x8, x9, [sp, -32]! /* 16-byte alignment */
342343
CFI_ADJUST(32)
343344
str x10, [sp, 16]
345+
str x11, [sp, 24]
344346
/* Setup a trap frame to catch exceptions escaping the OCaml code */
345347
ldr x8, Caml_state(exception_pointer)
346348
adr x9, L(trap_handler)
347349
stp x8, x9, [sp, -16]!
348350
CFI_ADJUST(16)
349351
add TRAP_PTR, sp, #0
352+
/* Store the async exception pointer */
353+
str TRAP_PTR, Caml_state(async_exception_pointer)
350354
/* Reload allocation pointer */
351355
ldr ALLOC_PTR, Caml_state(young_ptr)
352356
/* Call the OCaml code */
@@ -358,12 +362,14 @@ L(caml_retaddr):
358362
str x8, Caml_state(exception_pointer)
359363
/* Pop the callback link, restoring the global variables */
360364
L(return_result):
365+
ldr x11, [sp, 24]
361366
ldr x10, [sp, 16]
362367
ldp x8, x9, [sp], 32
363368
CFI_ADJUST(-32)
364369
str x8, Caml_state(bottom_of_stack)
365370
str x9, Caml_state(last_return_address)
366371
str x10, Caml_state(gc_regs)
372+
str x11, Caml_state(async_exception_pointer)
367373
/* Update allocation pointer */
368374
str ALLOC_PTR, Caml_state(young_ptr)
369375
/* Reload callee-save registers and return address */

0 commit comments

Comments
 (0)