@@ -19,37 +19,46 @@ type t =
19
19
exn_continuation : Continuation .t ;
20
20
params : Bound_parameters .t ;
21
21
my_closure : Variable .t ;
22
+ my_region : Variable .t ;
22
23
my_depth : Variable .t
23
24
}
24
25
25
26
let [@ ocamlformat " disable" ] print ppf
26
- { return_continuation; exn_continuation; params; my_closure; my_depth } =
27
+ { return_continuation; exn_continuation; params; my_closure; my_region; my_depth } =
27
28
Format. fprintf ppf " @[<hov 1>(\
28
29
@[<hov 1>(return_continuation@ %a)@]@ \
29
30
@[<hov 1>(exn_continuation@ %a)@]@ \
30
31
@[<hov 1>(params@ %a)@]@ \
31
32
@[<hov 1>(my_closure@ %a)@]@ \
33
+ @[<hov 1>(my_region@ %a)@]@ \
32
34
@[<hov 1>(my_depth@ %a)@])@]"
33
35
Continuation. print return_continuation
34
36
Continuation. print exn_continuation
35
37
Bound_parameters. print params
36
38
Variable. print my_closure
39
+ Variable. print my_region
37
40
Variable. print my_depth
38
41
39
- let create ~return_continuation ~exn_continuation ~params ~my_closure ~my_depth
40
- =
42
+ let create ~return_continuation ~exn_continuation ~params ~my_closure ~my_region
43
+ ~ my_depth =
41
44
Bound_parameters. check_no_duplicates params;
42
45
(if Flambda_features. check_invariants ()
43
46
then
44
47
let params_set = Bound_parameters. var_set params in
45
- if Variable. equal my_closure my_depth
46
- || Variable.Set. mem my_closure params_set
47
- || Variable.Set. mem my_depth params_set
48
+ let my_set = Variable.Set. of_list [ my_closure; my_region; my_depth] in
49
+ if Variable.Set. cardinal my_set <> 3
50
+ || not ( Variable.Set. is_empty ( Variable.Set. inter my_set params_set))
48
51
then
49
52
Misc. fatal_errorf
50
- " [my_closure] and [my_depth] must be disjoint from themselves and the \
51
- other parameters" );
52
- { return_continuation; exn_continuation; params; my_closure; my_depth }
53
+ " [my_closure], [my_region] and [my_depth] must be disjoint from \
54
+ themselves and the other parameters" );
55
+ { return_continuation;
56
+ exn_continuation;
57
+ params;
58
+ my_closure;
59
+ my_region;
60
+ my_depth
61
+ }
53
62
54
63
let return_continuation t = t.return_continuation
55
64
@@ -59,10 +68,18 @@ let params t = t.params
59
68
60
69
let my_closure t = t.my_closure
61
70
71
+ let my_region t = t.my_region
72
+
62
73
let my_depth t = t.my_depth
63
74
64
75
let free_names
65
- { return_continuation; exn_continuation; params; my_closure; my_depth } =
76
+ { return_continuation;
77
+ exn_continuation;
78
+ params;
79
+ my_closure;
80
+ my_region;
81
+ my_depth
82
+ } =
66
83
(* See [bound_continuations.ml] for why [add_traps] is [true]. *)
67
84
let free_names =
68
85
Name_occurrences. add_continuation Name_occurrences. empty return_continuation
@@ -78,11 +95,19 @@ let free_names
78
95
let free_names =
79
96
Name_occurrences. add_variable free_names my_closure Name_mode. normal
80
97
in
98
+ let free_names =
99
+ Name_occurrences. add_variable free_names my_region Name_mode. normal
100
+ in
81
101
Name_occurrences. add_variable free_names my_depth Name_mode. normal
82
102
83
103
let apply_renaming
84
- { return_continuation; exn_continuation; params; my_closure; my_depth }
85
- renaming =
104
+ { return_continuation;
105
+ exn_continuation;
106
+ params;
107
+ my_closure;
108
+ my_region;
109
+ my_depth
110
+ } renaming =
86
111
let return_continuation =
87
112
Renaming. apply_continuation renaming return_continuation
88
113
in
@@ -91,25 +116,47 @@ let apply_renaming
91
116
in
92
117
let params = Bound_parameters. apply_renaming params renaming in
93
118
let my_closure = Renaming. apply_variable renaming my_closure in
119
+ let my_region = Renaming. apply_variable renaming my_region in
94
120
let my_depth = Renaming. apply_variable renaming my_depth in
95
- { return_continuation; exn_continuation; params; my_closure; my_depth }
121
+ (* CR mshinwell: this should have a phys-equal check *)
122
+ { return_continuation;
123
+ exn_continuation;
124
+ params;
125
+ my_closure;
126
+ my_region;
127
+ my_depth
128
+ }
96
129
97
130
let ids_for_export
98
- { return_continuation; exn_continuation; params; my_closure; my_depth } =
131
+ { return_continuation;
132
+ exn_continuation;
133
+ params;
134
+ my_closure;
135
+ my_region;
136
+ my_depth
137
+ } =
99
138
let ids =
100
139
Ids_for_export. add_continuation Ids_for_export. empty return_continuation
101
140
in
102
141
let ids = Ids_for_export. add_continuation ids exn_continuation in
103
142
let ids = Ids_for_export. union ids (Bound_parameters. ids_for_export params) in
104
143
let ids = Ids_for_export. add_variable ids my_closure in
144
+ let ids = Ids_for_export. add_variable ids my_region in
105
145
Ids_for_export. add_variable ids my_depth
106
146
107
147
let rename
108
- { return_continuation; exn_continuation; params; my_closure; my_depth } =
148
+ { return_continuation;
149
+ exn_continuation;
150
+ params;
151
+ my_closure;
152
+ my_region;
153
+ my_depth
154
+ } =
109
155
{ return_continuation = Continuation. rename return_continuation;
110
156
exn_continuation = Continuation. rename exn_continuation;
111
157
params = Bound_parameters. rename params;
112
158
my_closure = Variable. rename my_closure;
159
+ my_region = Variable. rename my_region;
113
160
my_depth = Variable. rename my_depth
114
161
}
115
162
@@ -118,13 +165,15 @@ let renaming
118
165
exn_continuation = exn_continuation1 ;
119
166
params = params1 ;
120
167
my_closure = my_closure1 ;
168
+ my_region = my_region1 ;
121
169
my_depth = my_depth1
122
170
}
123
171
~guaranteed_fresh :
124
172
{ return_continuation = return_continuation2 ;
125
173
exn_continuation = exn_continuation2 ;
126
174
params = params2 ;
127
175
my_closure = my_closure2 ;
176
+ my_region = my_region2 ;
128
177
my_depth = my_depth2
129
178
} =
130
179
let renaming =
@@ -144,4 +193,7 @@ let renaming
144
193
Renaming. add_fresh_variable renaming my_closure1
145
194
~guaranteed_fresh: my_closure2
146
195
in
196
+ let renaming =
197
+ Renaming. add_fresh_variable renaming my_region1 ~guaranteed_fresh: my_region2
198
+ in
147
199
Renaming. add_fresh_variable renaming my_depth1 ~guaranteed_fresh: my_depth2
0 commit comments