@@ -86,6 +86,26 @@ type region_close =
86
86
| Rc_nontail (* do not close region, must not TCO *)
87
87
| Rc_close_at_apply (* close region and tail call *)
88
88
89
+ (* * Notes about applytail (as emitted by Printlambda) a.k.a. Rc_close_at_apply:
90
+
91
+ applytail / Rc_close_at_apply means that a call occurs in tail position of
92
+ the nearest enclosing region, and should be compiled by closing that region
93
+ (and only that region) just before control is transferred to the call.
94
+
95
+ In the raw lambda generated by Translcore, this can occur only in tail
96
+ position of a function, so these do happen to be tail calls. But after
97
+ inlining (by Simplif or otherwise), this may no longer be the case.
98
+
99
+ In particular, this code pattern:
100
+
101
+ (function (region (.... (region ... (applytail f)))))
102
+
103
+ means that the applytail is in tail position of the inner region and closes
104
+ that one. It just so happens to be at the end of the outer function as well,
105
+ but it does not mean that it's a tail call of that function. (It's not a
106
+ tail call because the outer region needs to end there.)
107
+ *)
108
+
89
109
(* CR layouts v5: When we add more blocks of non-scannable values, consider
90
110
whether some of the primitives specific to ufloat records
91
111
([Pmakeufloatblock], [Pufloatfield], and [Psetufloatfield]) can/should be
0 commit comments