Skip to content

Commit

Permalink
Cherry-pick from upstream: 6964d3a: Reload exception pointer register…
Browse files Browse the repository at this point in the history
… in caml_c_call* - unclear which PR this is from

(cherry picked from commit ebfbd52)
  • Loading branch information
mshinwell committed Aug 19, 2024
1 parent 370b25c commit f78e46a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ocaml/runtime/arm64.S
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,9 @@ FUNCTION(caml_c_call)
str TRAP_PTR, Caml_state(exn_handler)
/* Call the function */
blr ADDITIONAL_ARG
/* Reload alloc ptr */
/* Reload new allocation pointer & exn handler */
ldr ALLOC_PTR, Caml_state(young_ptr)
ldr TRAP_PTR, Caml_state(exn_handler)
/* Load ocaml stack */
SWITCH_C_TO_OCAML
#if defined(WITH_THREAD_SANITIZER)
Expand Down Expand Up @@ -657,8 +658,9 @@ FUNCTION(caml_c_call_stack_args)
blr ADDITIONAL_ARG
/* Restore stack */
mov sp, x19
/* Reload alloc ptr */
/* Reload new allocation pointer & exn handler */
ldr ALLOC_PTR, Caml_state(young_ptr)
ldr TRAP_PTR, Caml_state(exn_handler)
/* Switch from C to OCaml */
SWITCH_C_TO_OCAML
/* Return */
Expand Down
5 changes: 5 additions & 0 deletions ocaml/testsuite/tests/callback/test1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ external mycallback3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd
external mycallback4 :
('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e = "mycallback4"

let rec growstack n =
if n <= 0 then 0 else 1 + growstack (n - 1)

let rec tak (x, y, z as _tuple) =
if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y))
else z
Expand Down Expand Up @@ -63,3 +66,5 @@ let _ =
print_int(trapexit ()); print_newline();
print_string(tripwire mypushroot); print_newline();
print_string(tripwire mycamlparam); print_newline();
begin try ignore (mycallback1 growstack 1_000); raise Exit
with Exit -> () end

0 comments on commit f78e46a

Please sign in to comment.