Skip to content

Commit bb97207

Browse files
committed
Rename Lambda.apply_position
1 parent a7cb650 commit bb97207

36 files changed

+170
-169
lines changed

asmcomp/cmm.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ type memory_chunk =
148148
| Double
149149

150150
and operation =
151-
Capply of machtype * Lambda.apply_position
151+
Capply of machtype * Lambda.region_close
152152
| Cextcall of string * machtype * exttype list * bool
153153
| Cload of memory_chunk * Asttypes.mutable_flag
154154
| Calloc of Lambda.alloc_mode

asmcomp/cmm.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ type memory_chunk =
139139
see PR#10433 *)
140140

141141
and operation =
142-
Capply of machtype * Lambda.apply_position
142+
Capply of machtype * Lambda.region_close
143143
| Cextcall of string * machtype * exttype list * bool
144144
(** The [machtype] is the machine type of the result.
145145
The [exttype list] describes the unboxing types of the arguments.

asmcomp/cmm_helpers.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,14 +1846,14 @@ let has_local_allocs e =
18461846
let remove_region_tail e =
18471847
let rec has_tail = function
18481848
| Ctail _
1849-
| Cop(Capply(_, Apply_tail), _, _) -> raise Exit
1849+
| Cop(Capply(_, Rc_close_at_apply), _, _) -> raise Exit
18501850
| Cregion _ -> ()
18511851
| e -> ignore (iter_shallow_tail has_tail e)
18521852
in
18531853
let rec remove_tail = function
18541854
| Ctail e -> e
1855-
| Cop(Capply(mach, Apply_tail), args, dbg) ->
1856-
Cop(Capply(mach, Apply_nontail), args, dbg)
1855+
| Cop(Capply(mach, Rc_close_at_apply), args, dbg) ->
1856+
Cop(Capply(mach, Rc_normal), args, dbg)
18571857
| Cregion _ as e -> e
18581858
| e ->
18591859
map_shallow_tail remove_tail e
@@ -1891,15 +1891,15 @@ let apply_function_body (arity, (mode : Lambda.alloc_mode)) =
18911891
let clos = V.create_local "clos" in
18921892
let rec app_fun clos n =
18931893
if n = arity-1 then
1894-
Cop(Capply(typ_val, Apply_nontail),
1894+
Cop(Capply(typ_val, Rc_normal),
18951895
[get_field_gen Asttypes.Mutable (Cvar clos) 0 (dbg ());
18961896
Cvar arg.(n);
18971897
Cvar clos],
18981898
dbg ())
18991899
else begin
19001900
let newclos = V.create_local "clos" in
19011901
Clet(VP.create newclos,
1902-
Cop(Capply(typ_val, Apply_nontail),
1902+
Cop(Capply(typ_val, Rc_normal),
19031903
[get_field_gen Asttypes.Mutable (Cvar clos) 0 (dbg ());
19041904
Cvar arg.(n); Cvar clos], dbg ()),
19051905
app_fun newclos (n+1))
@@ -1914,7 +1914,7 @@ let apply_function_body (arity, (mode : Lambda.alloc_mode)) =
19141914
Cconst_int(pos_arity_in_closinfo, dbg())], dbg());
19151915
Cconst_int(arity, dbg())], dbg()),
19161916
dbg (),
1917-
Cop(Capply(typ_val, Apply_nontail),
1917+
Cop(Capply(typ_val, Rc_normal),
19181918
get_field_gen Asttypes.Mutable (Cvar clos) 2 (dbg ())
19191919
:: List.map (fun s -> Cvar s) all_args,
19201920
dbg ()),
@@ -2007,7 +2007,7 @@ let tuplify_function arity =
20072007
{fun_name;
20082008
fun_args = [VP.create arg, typ_val; VP.create clos, typ_val];
20092009
fun_body =
2010-
Cop(Capply(typ_val, Apply_nontail),
2010+
Cop(Capply(typ_val, Rc_normal),
20112011
get_field_gen Asttypes.Mutable (Cvar clos) 2 (dbg ())
20122012
:: access_components 0 @ [Cvar clos],
20132013
(dbg ()));
@@ -2050,7 +2050,7 @@ let final_curry_function ~nlocal ~arity =
20502050
let last_clos = V.create_local "clos" in
20512051
let rec curry_fun args clos n =
20522052
if n = 0 then
2053-
Cop(Capply(typ_val, Apply_nontail),
2053+
Cop(Capply(typ_val, Rc_normal),
20542054
get_field_gen Asttypes.Mutable (Cvar clos) 2 (dbg ()) ::
20552055
args @ [Cvar last_arg; Cvar clos],
20562056
dbg ())
@@ -2134,7 +2134,7 @@ let rec intermediate_curry_functions ~nlocal ~arity num =
21342134
let direct_args = iter (num+2) in
21352135
let rec iter i args clos =
21362136
if i = 0 then
2137-
Cop(Capply(typ_val, Apply_nontail),
2137+
Cop(Capply(typ_val, Rc_normal),
21382138
(get_field_gen Asttypes.Mutable (Cvar clos) 2 (dbg ()))
21392139
:: args @ [Cvar clos],
21402140
dbg ())
@@ -2693,7 +2693,7 @@ let entry_point namelist =
26932693
List.fold_right
26942694
(fun name next ->
26952695
let entry_sym = Compilenv.make_symbol ~unitname:name (Some "entry") in
2696-
Csequence(Cop(Capply(typ_void, Apply_nontail),
2696+
Csequence(Cop(Capply(typ_void, Rc_normal),
26972697
[cconst_symbol entry_sym], dbg ()),
26982698
Csequence(incr_global_inited (), next)))
26992699
namelist (cconst_int 1) in

asmcomp/selectgen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ method emit_tail (env:environment) exp =
10951095
| Cphantom_let (_var, _defining_expr, body) ->
10961096
self#emit_tail env body
10971097
| Cop((Capply(ty, pos)) as op, args, dbg) ->
1098-
let tail = (pos = Lambda.Apply_tail) in
1098+
let tail = (pos = Lambda.Rc_close_at_apply) in
10991099
let endregion = env.region_tail in
11001100
begin match self#emit_parts_list env' args with
11011101
None -> ()

bytecomp/bytegen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ let rec comp_expr env exp sz cont =
685685
ap_loc=loc;
686686
ap_func=func;
687687
ap_args=[arg];
688-
ap_position=pos;
688+
ap_region_close=pos;
689689
ap_mode=Alloc_heap;
690690
ap_tailcall=Default_tailcall;
691691
ap_inlined=Default_inlined;

lambda/lambda.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ type alloc_mode =
5050
| Alloc_heap
5151
| Alloc_local
5252

53-
type apply_position =
54-
| Apply_tail
55-
| Apply_nontail
53+
type region_close =
54+
| Rc_normal
55+
| Rc_close_at_apply
5656

5757
type primitive =
5858
| Pidentity
5959
| Pbytes_to_string
6060
| Pbytes_of_string
6161
| Pignore
62-
| Prevapply of apply_position
63-
| Pdirapply of apply_position
62+
| Prevapply of region_close
63+
| Pdirapply of region_close
6464
(* Globals *)
6565
| Pgetglobal of Ident.t
6666
| Psetglobal of Ident.t
@@ -356,7 +356,7 @@ type lambda =
356356
| Lassign of Ident.t * lambda
357357
| Lsend of
358358
meth_kind * lambda * lambda * lambda list
359-
* apply_position * alloc_mode * scoped_location
359+
* region_close * alloc_mode * scoped_location
360360
| Levent of lambda * lambda_event
361361
| Lifused of Ident.t * lambda
362362
| Lregion of lambda
@@ -374,7 +374,7 @@ and lfunction =
374374
and lambda_apply =
375375
{ ap_func : lambda;
376376
ap_args : lambda list;
377-
ap_position : apply_position;
377+
ap_region_close : region_close;
378378
ap_mode : alloc_mode;
379379
ap_loc : scoped_location;
380380
ap_tailcall : tailcall_attribute;
@@ -912,12 +912,12 @@ let duplicate lam =
912912
let shallow_map ~tail ~non_tail:f = function
913913
| Lvar _
914914
| Lconst _ as lam -> lam
915-
| Lapply { ap_func; ap_args; ap_position; ap_mode; ap_loc; ap_tailcall;
915+
| Lapply { ap_func; ap_args; ap_region_close; ap_mode; ap_loc; ap_tailcall;
916916
ap_inlined; ap_specialised; ap_probe } ->
917917
Lapply {
918918
ap_func = f ap_func;
919919
ap_args = List.map f ap_args;
920-
ap_position;
920+
ap_region_close;
921921
ap_mode;
922922
ap_loc;
923923
ap_tailcall;

lambda/lambda.mli

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@ type alloc_mode =
5757
| Alloc_heap
5858
| Alloc_local
5959

60-
type apply_position =
61-
| Apply_tail
62-
| Apply_nontail
60+
(* Tail calls can close their enclosing region early *)
61+
type region_close =
62+
| Rc_normal
63+
| Rc_close_at_apply
6364

6465
type primitive =
6566
| Pidentity
6667
| Pbytes_to_string
6768
| Pbytes_of_string
6869
| Pignore
69-
| Prevapply of apply_position
70-
| Pdirapply of apply_position
70+
| Prevapply of region_close
71+
| Pdirapply of region_close
7172
(* Globals *)
7273
| Pgetglobal of Ident.t
7374
| Psetglobal of Ident.t
@@ -326,7 +327,7 @@ type lambda =
326327
| Lfor of Ident.t * lambda * lambda * direction_flag * lambda
327328
| Lassign of Ident.t * lambda
328329
| Lsend of meth_kind * lambda * lambda * lambda list
329-
* apply_position * alloc_mode * scoped_location
330+
* region_close * alloc_mode * scoped_location
330331
| Levent of lambda * lambda_event
331332
| Lifused of Ident.t * lambda
332333
| Lregion of lambda
@@ -346,7 +347,7 @@ and lfunction =
346347
and lambda_apply =
347348
{ ap_func : lambda;
348349
ap_args : lambda list;
349-
ap_position : apply_position;
350+
ap_region_close : region_close;
350351
ap_mode : alloc_mode;
351352
ap_loc : scoped_location;
352353
ap_tailcall : tailcall_attribute;

lambda/matching.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ let inline_lazy_force_cond arg pos loc =
18461846
ap_loc = loc;
18471847
ap_func = force_fun;
18481848
ap_args = [ varg ];
1849-
ap_position = pos;
1849+
ap_region_close = pos;
18501850
ap_mode = Alloc_heap;
18511851
ap_inlined = Default_inlined;
18521852
ap_specialised = Default_specialise;
@@ -1882,7 +1882,7 @@ let inline_lazy_force_switch arg pos loc =
18821882
ap_loc = loc;
18831883
ap_func = force_fun;
18841884
ap_args = [ varg ];
1885-
ap_position = pos;
1885+
ap_region_close = pos;
18861886
ap_mode = Alloc_heap;
18871887
ap_inlined = Default_inlined;
18881888
ap_specialised = Default_specialise;
@@ -1904,7 +1904,7 @@ let inline_lazy_force arg pos loc =
19041904
ap_loc = loc;
19051905
ap_func = Lazy.force code_force_lazy;
19061906
ap_args = [ arg ];
1907-
ap_position = pos;
1907+
ap_region_close = pos;
19081908
ap_mode = Alloc_heap;
19091909
ap_inlined = Default_inlined;
19101910
ap_specialised = Default_specialise;
@@ -1922,7 +1922,7 @@ let inline_lazy_force arg pos loc =
19221922

19231923
let get_expr_args_lazy ~scopes head (arg, _mut) rem =
19241924
let loc = head_loc ~scopes head in
1925-
(inline_lazy_force arg Apply_nontail loc, Strict) :: rem
1925+
(inline_lazy_force arg Rc_normal loc, Strict) :: rem
19261926

19271927
let divide_lazy ~scopes head ctx pm =
19281928
divide_line (Context.specialize head)

lambda/matching.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ val expand_stringswitch:
5151
scoped_location -> lambda -> (string * lambda) list ->
5252
lambda option -> lambda
5353

54-
val inline_lazy_force : lambda -> apply_position -> scoped_location -> lambda
54+
val inline_lazy_force : lambda -> region_close -> scoped_location -> lambda

lambda/printlambda.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ let apply_probe ppf = function
580580
let apply_kind name pos mode =
581581
let name =
582582
match pos with
583-
| Apply_nontail -> name
584-
| Apply_tail -> name ^ "tail"
583+
| Rc_normal -> name
584+
| Rc_close_at_apply -> name ^ "tail"
585585
in
586586
name ^ alloc_kind mode
587587

@@ -593,7 +593,7 @@ let rec lam ppf = function
593593
| Lapply ap ->
594594
let lams ppf largs =
595595
List.iter (fun l -> fprintf ppf "@ %a" lam l) largs in
596-
let form = apply_kind "apply" ap.ap_position ap.ap_mode in
596+
let form = apply_kind "apply" ap.ap_region_close ap.ap_mode in
597597
fprintf ppf "@[<2>(%s@ %a%a%a%a%a%a)@]" form
598598
lam ap.ap_func lams ap.ap_args
599599
apply_tailcall_attribute ap.ap_tailcall

0 commit comments

Comments
 (0)