Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/core/js_pass_tailcall_inline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ let subst (export_set : Set_ident.t) stats =
Call
( {
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
},
args,
_info );
Expand Down
8 changes: 6 additions & 2 deletions jscomp/core/lam_pass_remove_alias.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
ap_info;
} -> (
match Lam_compile_env.query_external_id_info ident fld_name with
| { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
| {
persistent_closed_lambda =
Some (Lfunction ({ params; body } as lfunction));
}
(* be more cautious when do cross module inlining *)
when Ext_list.same_length params args
&& Ext_list.for_all args (fun arg ->
Expand All @@ -180,7 +183,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
match Hash_ident.find_opt meta.ident_tbl p with
| Some v -> v <> Parameter
| None -> true)
| _ -> true) ->
| _ -> true)
&& Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
(* Function inlining interact with other optimizations...
Expand Down
16 changes: 8 additions & 8 deletions jscomp/test/async_inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ async function willBeInlined(param) {

var inlined = willBeInlined(undefined);

function wrapSomethingAsync(param) {
((async function (param) {
var test = await Promise.resolve("Test");
console.log(test);
})(777));
}

async function doSomethingAsync(someAsyncFunction) {
return await Curry._1(someAsyncFunction, undefined);
}
Expand Down Expand Up @@ -53,11 +46,17 @@ var tui = 3;

var tuia = uncurriedIdAsync(3);

function wrapSomethingAsync(param) {
((async function (param) {
var test = await Promise.resolve("Test");
console.log(test);
})(undefined));
}

var tci = 3;

exports.willBeInlined = willBeInlined;
exports.inlined = inlined;
exports.wrapSomethingAsync = wrapSomethingAsync;
exports.M = M;
exports.broken = broken$2;
exports.curriedId = curriedId;
Expand All @@ -68,4 +67,5 @@ exports.tci = tci;
exports.tcia = tcia;
exports.tui = tui;
exports.tuia = tuia;
exports.wrapSomethingAsync = wrapSomethingAsync;
/* inlined Not a pure module */
12 changes: 11 additions & 1 deletion jscomp/test/async_inline.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ let uncurriedIdAsync = async (.x ) => x
let tci = curriedId(3)
let tcia = curriedIdAsync(3)
let tui = uncurriedId(. 3)
let tuia = uncurriedIdAsync(. 3)
let tuia = uncurriedIdAsync(. 3)

external ignorePromise: promise<'a> => unit = "%identity"

let wrapSomethingAsync = () =>
(
async () => {
let test = await Js.Promise.resolve("Test")
Js.log(test)
}
)()->ignorePromise
10 changes: 7 additions & 3 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92837,7 +92837,7 @@ let subst (export_set : Set_ident.t) stats =
Call
( {
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
},
args,
_info );
Expand Down Expand Up @@ -139496,7 +139496,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
ap_info;
} -> (
match Lam_compile_env.query_external_id_info ident fld_name with
| { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
| {
persistent_closed_lambda =
Some (Lfunction ({ params; body } as lfunction));
}
(* be more cautious when do cross module inlining *)
when Ext_list.same_length params args
&& Ext_list.for_all args (fun arg ->
Expand All @@ -139505,7 +139508,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
match Hash_ident.find_opt meta.ident_tbl p with
| Some v -> v <> Parameter
| None -> true)
| _ -> true) ->
| _ -> true)
&& Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
(* Function inlining interact with other optimizations...
Expand Down
10 changes: 7 additions & 3 deletions lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92837,7 +92837,7 @@ let subst (export_set : Set_ident.t) stats =
Call
( {
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
},
args,
_info );
Expand Down Expand Up @@ -139496,7 +139496,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
ap_info;
} -> (
match Lam_compile_env.query_external_id_info ident fld_name with
| { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
| {
persistent_closed_lambda =
Some (Lfunction ({ params; body } as lfunction));
}
(* be more cautious when do cross module inlining *)
when Ext_list.same_length params args
&& Ext_list.for_all args (fun arg ->
Expand All @@ -139505,7 +139508,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
match Hash_ident.find_opt meta.ident_tbl p with
| Some v -> v <> Parameter
| None -> true)
| _ -> true) ->
| _ -> true)
&& Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
(* Function inlining interact with other optimizations...
Expand Down
10 changes: 7 additions & 3 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141231,7 +141231,7 @@ let subst (export_set : Set_ident.t) stats =
Call
( {
expression_desc =
Fun {is_method=false; params; body; env};
Fun {is_method=false; params; body; env; async=false};
},
args,
_info );
Expand Down Expand Up @@ -154666,7 +154666,10 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
ap_info;
} -> (
match Lam_compile_env.query_external_id_info ident fld_name with
| { persistent_closed_lambda = Some (Lfunction { params; body; _ }) }
| {
persistent_closed_lambda =
Some (Lfunction ({ params; body } as lfunction));
}
(* be more cautious when do cross module inlining *)
when Ext_list.same_length params args
&& Ext_list.for_all args (fun arg ->
Expand All @@ -154675,7 +154678,8 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
match Hash_ident.find_opt meta.ident_tbl p with
| Some v -> v <> Parameter
| None -> true)
| _ -> true) ->
| _ -> true)
&& Lam_analysis.lfunction_can_be_beta_reduced lfunction ->
simpl (Lam_beta_reduce.propagate_beta_reduce meta params body args)
| _ -> Lam.apply (simpl l1) (Ext_list.map args simpl) ap_info)
(* Function inlining interact with other optimizations...
Expand Down