Skip to content

Commit cb1eb40

Browse files
committed
take into account inline attribute when deciding whether inline or no
1 parent a9253d8 commit cb1eb40

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

jscomp/core/lam_analysis.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,18 @@ let destruct_pattern (body : Lam.t) params args =
334334

335335
(** Hints to inlining *)
336336
let ok_to_inline_fun_when_app
337-
~(body : Lam.t)
338-
(params : Ident.t list)
337+
(m : Lam.lfunction)
339338
(args : Lam.t list) =
340-
let s = size body in
341-
s < small_inline_size ||
342-
(destruct_pattern body params args) ||
343-
(args_all_const args &&
344-
(s < 10 && no_side_effects body ))
339+
match m.attr with
340+
| Always_inline -> true
341+
| Never_inline -> false
342+
| Default_inline ->
343+
let Lam.{body; params} = m in
344+
let s = size body in
345+
s < small_inline_size ||
346+
(destruct_pattern body params args) ||
347+
(args_all_const args &&
348+
(s < 10 && no_side_effects body ))
345349

346350

347351

jscomp/core/lam_analysis.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ val no_side_effects : Lam.t -> bool
3434

3535
val size : Lam.t -> int
3636

37-
val ok_to_inline_fun_when_app : body:Lam.t -> Lam.ident list -> Lam.t list -> bool
37+
val ok_to_inline_fun_when_app :
38+
Lam.lfunction ->
39+
Lam.t list ->
40+
bool
3841

3942

4043

jscomp/core/lam_pass_remove_alias.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ let simplify_alias
155155
let normal () = Lam.apply ( simpl fn) (Ext_list.map args simpl) loc status in
156156
begin
157157
match Hash_ident.find_opt meta.ident_tbl v with
158-
| Some (FunctionId {lambda = Some(Lfunction {params; body} as _m,
158+
| Some (FunctionId {lambda = Some(Lfunction ({params; body} as m),
159159
rec_flag)
160160
})
161161
->
@@ -177,7 +177,7 @@ let simplify_alias
177177
end
178178
else
179179
if (* Lam_analysis.size body < Lam_analysis.small_inline_size *)
180-
Lam_analysis.ok_to_inline_fun_when_app ~body params args
180+
Lam_analysis.ok_to_inline_fun_when_app m args
181181
then
182182

183183
(* let param_map = *)

0 commit comments

Comments
 (0)