@@ -98133,13 +98133,12 @@ type value = {
98133
98133
type let_kind = Lam_compat.let_kind
98134
98134
98135
98135
type maybe_tail =
98136
- | Tail_in_try
98137
- | Tail_no_name_lambda
98138
- | Tail_with_name of return_label
98136
+ | Tail_in_try
98137
+ | Tail_with_name of return_label option
98139
98138
98140
98139
type tail_type =
98141
98140
| Not_tail
98142
- | Maybe_tail of maybe_tail
98141
+ | Maybe_tail_is_return of maybe_tail
98143
98142
(* anonoymous function does not have identifier *)
98144
98143
98145
98144
(* delegate to the callee to generate expression
@@ -98162,6 +98161,8 @@ type jmp_table
98162
98161
val continuation_is_return:
98163
98162
continuation ->
98164
98163
bool
98164
+
98165
+
98165
98166
type t = {
98166
98167
continuation : continuation ;
98167
98168
jmp_table : jmp_table;
@@ -98239,15 +98240,14 @@ type return_label = {
98239
98240
98240
98241
type maybe_tail =
98241
98242
| Tail_in_try
98242
- | Tail_no_name_lambda
98243
- | Tail_with_name of return_label
98243
+ | Tail_with_name of return_label option
98244
98244
98245
98245
type tail_type =
98246
98246
| Not_tail
98247
- | Maybe_tail of maybe_tail
98247
+ | Maybe_tail_is_return of maybe_tail
98248
98248
(* Note [return] does indicate it is a tail position in most cases
98249
98249
however, in an exception handler, return may not be in tail position
98250
- to fix #1701 we play a trick that (Maybe_tail None)
98250
+ to fix #1701 we play a trick that (Maybe_tail_is_return None)
98251
98251
would never trigger tailcall, however, it preserves [return]
98252
98252
semantics
98253
98253
*)
@@ -98266,7 +98266,7 @@ type jmp_table = value HandlerMap.t
98266
98266
98267
98267
let continuation_is_return ( x : continuation) =
98268
98268
match x with
98269
- | EffectCall (Maybe_tail _) | NeedValue (Maybe_tail _)
98269
+ | EffectCall (Maybe_tail_is_return _) | NeedValue (Maybe_tail_is_return _)
98270
98270
-> true
98271
98271
| EffectCall Not_tail | NeedValue Not_tail
98272
98272
| Declare _ | Assign _
@@ -98488,7 +98488,7 @@ let output_of_expression
98488
98488
make [ S.define_variable ~kind n exp]
98489
98489
| Assign n ->
98490
98490
make [S.assign n exp ]
98491
- | EffectCall (Maybe_tail _) ->
98491
+ | EffectCall (Maybe_tail_is_return _) ->
98492
98492
make [S.return_stmt exp] ~output_finished:True
98493
98493
| NeedValue _ ->
98494
98494
{block = []; value = Some exp; output_finished = False }
@@ -98499,7 +98499,7 @@ let output_of_block_and_expression
98499
98499
(block : J.block) exp : t =
98500
98500
match continuation with
98501
98501
| EffectCall Not_tail -> make block ~value:exp
98502
- | EffectCall (Maybe_tail _) ->
98502
+ | EffectCall (Maybe_tail_is_return _) ->
98503
98503
make (Ext_list.append_one block (S.return_stmt exp)) ~output_finished:True
98504
98504
| Declare (kind,n) ->
98505
98505
make (Ext_list.append_one block (S.define_variable ~kind n exp))
@@ -107203,7 +107203,7 @@ module E = Js_exp_make
107203
107203
*)
107204
107204
let ensure_value_unit (st : Lam_compile_context.continuation) e : E.t =
107205
107205
match st with
107206
- | EffectCall (Maybe_tail _ ) | NeedValue (Maybe_tail _)
107206
+ | EffectCall (Maybe_tail_is_return _ ) | NeedValue (Maybe_tail_is_return _)
107207
107207
| Assign _ | Declare _ | NeedValue _ -> E.seq e E.unit
107208
107208
| EffectCall Not_tail -> e
107209
107209
(* NeedValue should return a meaningful expression*)
@@ -110733,9 +110733,9 @@ let change_tail_type_in_try
110733
110733
(x : Lam_compile_context.tail_type)
110734
110734
: Lam_compile_context.tail_type =
110735
110735
match x with
110736
- | Maybe_tail (Tail_with_name _ | Tail_no_name_lambda ) ->
110737
- Maybe_tail Tail_in_try
110738
- | Not_tail | Maybe_tail Tail_in_try
110736
+ | Maybe_tail_is_return (Tail_with_name _ ) ->
110737
+ Maybe_tail_is_return Tail_in_try
110738
+ | Not_tail | Maybe_tail_is_return Tail_in_try
110739
110739
-> x
110740
110740
110741
110741
(* assume outer is [Lstaticcatch] *)
@@ -110963,7 +110963,7 @@ and compile_recursive_let ~all_bindings
110963
110963
let output =
110964
110964
compile_lambda
110965
110965
{ cxt with
110966
- continuation = EffectCall (Maybe_tail (Tail_with_name ret ));
110966
+ continuation = EffectCall (Maybe_tail_is_return (Tail_with_name (Some ret ) ));
110967
110967
jmp_table = Lam_compile_context.empty_handler_map} body in
110968
110968
let result =
110969
110969
if ret.triggered then
@@ -111900,7 +111900,7 @@ and compile_ifthenelse
111900
111900
(Js_output.output_as_block (
111901
111901
compile_lambda lambda_cxt t_branch))
111902
111902
?else_))
111903
- | Maybe_tail _, {block = []; value = Some out1},
111903
+ | Maybe_tail_is_return _, {block = []; value = Some out1},
111904
111904
{block = []; value = Some out2} ->
111905
111905
Js_output.make
111906
111906
(Ext_list.append_one b (S.return_stmt (E.econd e out1 out2)))
@@ -111953,7 +111953,7 @@ and compile_apply
111953
111953
) in
111954
111954
match fn, lambda_cxt.continuation with
111955
111955
| (Lvar fn_id,
111956
- (EffectCall (Maybe_tail (Tail_with_name ret)) | NeedValue (Maybe_tail (Tail_with_name ret))))
111956
+ (EffectCall (Maybe_tail_is_return (Tail_with_name (Some ret))) | NeedValue (Maybe_tail_is_return (Tail_with_name (Some ret) ))))
111957
111957
when Ident.same ret.id fn_id ->
111958
111958
ret.triggered <- true;
111959
111959
(* Here we mark [finished] true, since the continuation
@@ -112136,7 +112136,7 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
112136
112136
*)
112137
112137
(Js_output.output_as_block
112138
112138
( compile_lambda
112139
- { lambda_cxt with continuation = EffectCall ( Maybe_tail Tail_no_name_lambda );
112139
+ { lambda_cxt with continuation = EffectCall ( Maybe_tail_is_return (Tail_with_name None) );
112140
112140
jmp_table = Lam_compile_context.empty_handler_map}
112141
112141
body)))
112142
112142
| _ -> assert false)
@@ -112189,7 +112189,7 @@ and compile_lambda
112189
112189
(Js_output.output_as_block
112190
112190
( compile_lambda
112191
112191
{ lambda_cxt with
112192
- continuation = EffectCall (Maybe_tail Tail_no_name_lambda );
112192
+ continuation = EffectCall (Maybe_tail_is_return (Tail_with_name None) );
112193
112193
jmp_table = Lam_compile_context.empty_handler_map}
112194
112194
body)))
112195
112195
| Lapply appinfo ->
0 commit comments