Skip to content

Commit

Permalink
Disable inlining for effect functions that manipulate stacks (#3231)
Browse files Browse the repository at this point in the history
* noinline effects

* also need try/match
  • Loading branch information
TheNumbat authored Nov 5, 2024
1 parent c8caf1e commit 50b8f0a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions stdlib/effect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ module Deep = struct
external cont_set_last_fiber :
('a, 'b) continuation -> last_fiber -> unit = "%setfield1"

let continue k v =
let[@inline never] continue k v =
resume (take_cont_noexc k) (fun x -> x) v (cont_last_fiber k)

let discontinue k e =
let[@inline never] discontinue k e =
resume (take_cont_noexc k) (fun e -> raise e) e (cont_last_fiber k)

let discontinue_with_backtrace k e bt =
let[@inline never] discontinue_with_backtrace k e bt =
resume (take_cont_noexc k) (fun e -> Printexc.raise_with_backtrace e bt)
e (cont_last_fiber k)

Expand All @@ -76,7 +76,7 @@ module Deep = struct
external reperform :
'a t -> ('a, 'b) continuation -> last_fiber -> 'b = "%reperform"

let match_with comp arg handler =
let[@inline never] match_with comp arg handler =
let effc eff k last_fiber =
match handler.effc eff with
| Some f ->
Expand All @@ -90,7 +90,7 @@ module Deep = struct
type 'a effect_handler =
{ effc: 'b. 'b t -> (('b,'a) continuation -> 'a) option }

let try_with comp arg handler =
let[@inline never] try_with comp arg handler =
let effc' eff k last_fiber =
match handler.effc eff with
| Some f ->
Expand Down Expand Up @@ -120,7 +120,7 @@ module Shallow = struct
external cont_set_last_fiber :
('a, 'b) continuation -> last_fiber -> unit = "%setfield1"

let fiber : type a b. (a -> b) -> (a, b) continuation = fun f ->
let[@inline never] fiber : type a b. (a -> b) -> (a, b) continuation = fun f ->
let module M = struct type _ t += Initial_setup__ : a t end in
let exception E of (a,b) continuation in
let f' () = f (perform M.Initial_setup__) in
Expand Down Expand Up @@ -152,7 +152,7 @@ module Shallow = struct
external reperform :
'a t -> ('a, 'b) continuation -> last_fiber -> 'c = "%reperform"

let continue_gen k resume_fun v handler =
let[@inline never] continue_gen k resume_fun v handler =
let effc eff k last_fiber =
match handler.effc eff with
| Some f ->
Expand Down

0 comments on commit 50b8f0a

Please sign in to comment.