File tree 7 files changed +46
-12
lines changed
7 files changed +46
-12
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ let subst (export_set : Set_ident.t) stats =
200
200
Call
201
201
( {
202
202
expression_desc =
203
- Fun {is_method= false ; params; body; env};
203
+ Fun {is_method= false ; params; body; env; async = false };
204
204
},
205
205
args,
206
206
_info );
Original file line number Diff line number Diff line change @@ -128,7 +128,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
128
128
ap_info;
129
129
} -> (
130
130
match Lam_compile_env. query_external_id_info ident fld_name with
131
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
131
+ | {
132
+ persistent_closed_lambda =
133
+ Some (Lfunction ({ params; body } as lfunction));
134
+ }
132
135
(* be more cautious when do cross module inlining *)
133
136
when Ext_list. same_length params args
134
137
&& Ext_list. for_all args (fun arg ->
@@ -137,7 +140,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
137
140
match Hash_ident. find_opt meta.ident_tbl p with
138
141
| Some v -> v <> Parameter
139
142
| None -> true )
140
- | _ -> true ) ->
143
+ | _ -> true )
144
+ && Lam_analysis. lfunction_can_be_beta_reduced lfunction ->
141
145
simpl (Lam_beta_reduce. propagate_beta_reduce meta params body args)
142
146
| _ -> Lam. apply (simpl l1) (Ext_list. map args simpl) ap_info)
143
147
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ function wrapSomethingAsync(param) {
15
15
} ) ( 777 ) ) ;
16
16
}
17
17
18
+ function wrapSomethingAsync2 ( param ) {
19
+ ( ( async function ( param ) {
20
+ var test = await Promise . resolve ( "Test" ) ;
21
+ console . log ( test ) ;
22
+ } ) ( undefined ) ) ;
23
+ }
24
+
18
25
async function doSomethingAsync ( someAsyncFunction ) {
19
26
return await Curry . _1 ( someAsyncFunction , undefined ) ;
20
27
}
@@ -34,6 +41,7 @@ var broken$2 = broken$1;
34
41
exports . willBeInlined = willBeInlined ;
35
42
exports . inlined = inlined ;
36
43
exports . wrapSomethingAsync = wrapSomethingAsync ;
44
+ exports . wrapSomethingAsync2 = wrapSomethingAsync2 ;
37
45
exports . M = M ;
38
46
exports . broken = broken$2 ;
39
47
/* inlined Not a pure module */
Original file line number Diff line number Diff line change @@ -11,6 +11,16 @@ let wrapSomethingAsync: unit => unit = () => {
11
11
)(777 )
12
12
}
13
13
14
+ external ignorePromise : promise <'a > => unit = "%identity"
15
+
16
+ let wrapSomethingAsync2 = () =>
17
+ (
18
+ async () => {
19
+ let test = await Js .Promise .resolve ("Test" )
20
+ Js .log (test )
21
+ }
22
+ )()-> ignorePromise
23
+
14
24
module M : {
15
25
let broken : (unit => promise <'a >) => promise <'a >
16
26
} = {
Original file line number Diff line number Diff line change @@ -92813,7 +92813,7 @@ let subst (export_set : Set_ident.t) stats =
92813
92813
Call
92814
92814
( {
92815
92815
expression_desc =
92816
- Fun {is_method=false; params; body; env};
92816
+ Fun {is_method=false; params; body; env; async=false };
92817
92817
},
92818
92818
args,
92819
92819
_info );
@@ -260296,7 +260296,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
260296
260296
ap_info;
260297
260297
} -> (
260298
260298
match Lam_compile_env.query_external_id_info ident fld_name with
260299
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
260299
+ | {
260300
+ persistent_closed_lambda =
260301
+ Some (Lfunction ({ params; body } as lfunction));
260302
+ }
260300
260303
(* be more cautious when do cross module inlining *)
260301
260304
when Ext_list.same_length params args
260302
260305
&& Ext_list.for_all args (fun arg ->
@@ -260305,7 +260308,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
260305
260308
match Hash_ident.find_opt meta.ident_tbl p with
260306
260309
| Some v -> v <> Parameter
260307
260310
| None -> true)
260308
- | _ -> true) ->
260311
+ | _ -> true)
260312
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
260309
260313
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
260310
260314
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
260311
260315
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -92813,7 +92813,7 @@ let subst (export_set : Set_ident.t) stats =
92813
92813
Call
92814
92814
( {
92815
92815
expression_desc =
92816
- Fun {is_method=false; params; body; env};
92816
+ Fun {is_method=false; params; body; env; async=false };
92817
92817
},
92818
92818
args,
92819
92819
_info );
@@ -260296,7 +260296,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
260296
260296
ap_info;
260297
260297
} -> (
260298
260298
match Lam_compile_env.query_external_id_info ident fld_name with
260299
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
260299
+ | {
260300
+ persistent_closed_lambda =
260301
+ Some (Lfunction ({ params; body } as lfunction));
260302
+ }
260300
260303
(* be more cautious when do cross module inlining *)
260301
260304
when Ext_list.same_length params args
260302
260305
&& Ext_list.for_all args (fun arg ->
@@ -260305,7 +260308,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
260305
260308
match Hash_ident.find_opt meta.ident_tbl p with
260306
260309
| Some v -> v <> Parameter
260307
260310
| None -> true)
260308
- | _ -> true) ->
260311
+ | _ -> true)
260312
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
260309
260313
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
260310
260314
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
260311
260315
(* Function inlining interact with other optimizations...
Original file line number Diff line number Diff line change @@ -262174,7 +262174,7 @@ let subst (export_set : Set_ident.t) stats =
262174
262174
Call
262175
262175
( {
262176
262176
expression_desc =
262177
- Fun {is_method=false; params; body; env};
262177
+ Fun {is_method=false; params; body; env; async=false };
262178
262178
},
262179
262179
args,
262180
262180
_info );
@@ -275566,7 +275566,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
275566
275566
ap_info;
275567
275567
} -> (
275568
275568
match Lam_compile_env.query_external_id_info ident fld_name with
275569
- | { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
275569
+ | {
275570
+ persistent_closed_lambda =
275571
+ Some (Lfunction ({ params; body } as lfunction));
275572
+ }
275570
275573
(* be more cautious when do cross module inlining *)
275571
275574
when Ext_list.same_length params args
275572
275575
&& Ext_list.for_all args (fun arg ->
@@ -275575,7 +275578,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
275575
275578
match Hash_ident.find_opt meta.ident_tbl p with
275576
275579
| Some v -> v <> Parameter
275577
275580
| None -> true)
275578
- | _ -> true) ->
275581
+ | _ -> true)
275582
+ && Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
275579
275583
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
275580
275584
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
275581
275585
(* Function inlining interact with other optimizations...
You can’t perform that action at this time.
0 commit comments