@@ -66,7 +66,7 @@ let list_group f g l =
6666type application_description =
6767 { arity : int
6868 ; exact : bool
69- ; cps : bool
69+ ; trampolined : bool
7070 }
7171
7272module Share = struct
@@ -144,7 +144,7 @@ module Share = struct
144144 | _ -> t)
145145
146146 let get
147- ~cps_calls
147+ ~trampolined_calls
148148 ?alias_strings
149149 ?(alias_prims = false )
150150 ?(alias_apply = true )
@@ -161,9 +161,9 @@ module Share = struct
161161 match i with
162162 | Let (_ , Constant c ) -> get_constant c share
163163 | Let (x , Apply { args; exact; _ } ) ->
164- let cps = Var.Set. mem x cps_calls in
165- if (not exact) || cps
166- then add_apply { arity = List. length args; exact; cps } share
164+ let trampolined = Var.Set. mem x trampolined_calls in
165+ if (not exact) || trampolined
166+ then add_apply { arity = List. length args; exact; trampolined } share
167167 else share
168168 | Let (_ , Special (Alias_prim name )) ->
169169 let name = Primitive. resolve name in
@@ -255,11 +255,11 @@ module Share = struct
255255 try J. EVar (AppMap. find desc t.vars.applies)
256256 with Not_found ->
257257 let x =
258- let { arity; exact; cps } = desc in
258+ let { arity; exact; trampolined } = desc in
259259 Var. fresh_n
260260 (Printf. sprintf
261261 " caml_%scall%d"
262- (match exact, cps with
262+ (match exact, trampolined with
263263 | true , false -> assert false
264264 | true , true -> " cps_exact_"
265265 | false , false -> " "
@@ -280,7 +280,7 @@ module Ctx = struct
280280 ; exported_runtime : (Code.Var .t * bool ref ) option
281281 ; should_export : bool
282282 ; effect_warning : bool ref
283- ; cps_calls : Effects .cps_calls
283+ ; trampolined_calls : Effects .trampolined_calls
284284 }
285285
286286 let initial
@@ -289,7 +289,7 @@ module Ctx = struct
289289 ~should_export
290290 blocks
291291 live
292- cps_calls
292+ trampolined_calls
293293 share
294294 debug =
295295 { blocks
@@ -299,7 +299,7 @@ module Ctx = struct
299299 ; exported_runtime
300300 ; should_export
301301 ; effect_warning = ref (not warn_on_unhandled_effect)
302- ; cps_calls
302+ ; trampolined_calls
303303 }
304304end
305305
@@ -950,7 +950,7 @@ let parallel_renaming params args continuation queue =
950950
951951(* ***)
952952
953- let apply_fun_raw ctx f params exact cps =
953+ let apply_fun_raw ctx f params exact trampolined =
954954 let n = List. length params in
955955 let apply_directly =
956956 (* Make sure we are performing a regular call, not a (slower)
@@ -979,7 +979,7 @@ let apply_fun_raw ctx f params exact cps =
979979 , apply_directly
980980 , J. call (runtime_fun ctx " caml_call_gen" ) [ f; J. array params ] J. N )
981981 in
982- if cps
982+ if trampolined
983983 then (
984984 assert (Config.Flag. effects () );
985985 (* When supporting effect, we systematically perform tailcall
@@ -992,7 +992,7 @@ let apply_fun_raw ctx f params exact cps =
992992 , J. call (runtime_fun ctx " caml_trampoline_return" ) [ f; J. array params ] J. N ))
993993 else apply
994994
995- let generate_apply_fun ctx { arity; exact; cps } =
995+ let generate_apply_fun ctx { arity; exact; trampolined } =
996996 let f' = Var. fresh_n " f" in
997997 let f = J. V f' in
998998 let params =
@@ -1007,23 +1007,24 @@ let generate_apply_fun ctx { arity; exact; cps } =
10071007 ( None
10081008 , J. fun_
10091009 (f :: params)
1010- [ J. Return_statement (Some (apply_fun_raw ctx f' params' exact cps)), J. N ]
1010+ [ J. Return_statement (Some (apply_fun_raw ctx f' params' exact trampolined)), J. N
1011+ ]
10111012 J. N )
10121013
1013- let apply_fun ctx f params exact cps loc =
1014+ let apply_fun ctx f params exact trampolined loc =
10141015 (* We always go through an intermediate function when doing CPS
10151016 calls. This function first checks the stack depth to prevent
10161017 a stack overflow. This makes the code smaller than inlining
10171018 the test, and we expect the performance impact to be low
10181019 since the function should get inlined by the JavaScript
10191020 engines. *)
1020- if Config.Flag. inline_callgen () || (exact && not cps )
1021- then apply_fun_raw ctx f params exact cps
1021+ if Config.Flag. inline_callgen () || (exact && not trampolined )
1022+ then apply_fun_raw ctx f params exact trampolined
10221023 else
10231024 let y =
10241025 Share. get_apply
10251026 (generate_apply_fun ctx)
1026- { arity = List. length params; exact; cps }
1027+ { arity = List. length params; exact; trampolined }
10271028 ctx.Ctx. share
10281029 in
10291030 J. call y (f :: params) loc
@@ -1209,7 +1210,7 @@ let throw_statement ctx cx k loc =
12091210let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
12101211 match e with
12111212 | Apply { f; args; exact } ->
1212- let cps = Var.Set. mem x ctx.Ctx. cps_calls in
1213+ let trampolined = Var.Set. mem x ctx.Ctx. trampolined_calls in
12131214 let args, prop, queue =
12141215 List. fold_right
12151216 ~f: (fun x (args , prop , queue ) ->
@@ -1220,7 +1221,7 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
12201221 in
12211222 let (prop', f), queue = access_queue queue f in
12221223 let prop = or_p prop prop' in
1223- let e = apply_fun ctx f args exact cps loc in
1224+ let e = apply_fun ctx f args exact trampolined loc in
12241225 (e, prop, queue), []
12251226 | Block (tag , a , array_or_not , _mut ) ->
12261227 let contents, prop, queue =
@@ -2121,12 +2122,12 @@ let f
21212122 (p : Code.program )
21222123 ~exported_runtime
21232124 ~live_vars
2124- ~cps_calls
2125+ ~trampolined_calls
21252126 ~should_export
21262127 ~warn_on_unhandled_effect
21272128 debug =
21282129 let t' = Timer. make () in
2129- let share = Share. get ~cps_calls ~alias_prims: exported_runtime p in
2130+ let share = Share. get ~trampolined_calls ~alias_prims: exported_runtime p in
21302131 let exported_runtime =
21312132 if exported_runtime then Some (Code.Var. fresh_n " runtime" , ref false ) else None
21322133 in
@@ -2137,7 +2138,7 @@ let f
21372138 ~should_export
21382139 p.blocks
21392140 live_vars
2140- cps_calls
2141+ trampolined_calls
21412142 share
21422143 debug
21432144 in
0 commit comments