Skip to content

Commit 9fc9638

Browse files
committed
Subject copying code to inline heuristic, cut 30kb from rustc.
1 parent a441865 commit 9fc9638

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

src/boot/me/trans.ml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,13 +1954,13 @@ let trans_visitor
19541954
let initflag = get_element_ptr args arg_initflag in
19551955
let jmps = trans_compare_simple Il.JNE (Il.Cell initflag) one in
19561956

1957-
trans_copy_ty ty_params true dst ty src ty;
1957+
trans_copy_ty_full true ty_params true dst ty src ty;
19581958

19591959
let skip_noninit_jmp = mark() in
19601960
emit (Il.jmp Il.JMP Il.CodeNone);
19611961
List.iter patch jmps;
19621962

1963-
trans_copy_ty ty_params false dst ty src ty;
1963+
trans_copy_ty_full true ty_params false dst ty src ty;
19641964

19651965
patch skip_noninit_jmp;
19661966
in
@@ -3661,6 +3661,16 @@ let trans_visitor
36613661
(dst:Il.cell) (dst_ty:Ast.ty)
36623662
(src:Il.cell) (src_ty:Ast.ty)
36633663
: unit =
3664+
trans_copy_ty_full
3665+
false ty_params initializing dst dst_ty src src_ty
3666+
3667+
and trans_copy_ty_full
3668+
(force_inline:bool)
3669+
(ty_params:Il.cell)
3670+
(initializing:bool)
3671+
(dst:Il.cell) (dst_ty:Ast.ty)
3672+
(src:Il.cell) (src_ty:Ast.ty)
3673+
: unit =
36643674
let anno (weight:string) : unit =
36653675
iflog
36663676
begin
@@ -3700,7 +3710,7 @@ let trans_visitor
37003710
| _ ->
37013711
(* Heavyweight copy: duplicate 1 level of the referent. *)
37023712
anno "heavy";
3703-
trans_copy_ty_heavy ty_params initializing
3713+
trans_copy_ty_heavy force_inline ty_params initializing
37043714
dst dst_ty src src_ty
37053715
end
37063716

@@ -3732,6 +3742,7 @@ let trans_visitor
37323742
*)
37333743

37343744
and trans_copy_ty_heavy
3745+
(force_inline:bool)
37353746
(ty_params:Il.cell)
37363747
(initializing:bool)
37373748
(dst:Il.cell) (dst_ty:Ast.ty)
@@ -3777,8 +3788,7 @@ let trans_visitor
37773788
iflog
37783789
(fun _ -> annotate
37793790
(Printf.sprintf "copy_ty: parametric copy %#d" i));
3780-
let initflag = if initializing then one else zero in
3781-
let initflag = Il.Reg (force_to_reg initflag) in
3791+
let initflag = Il.Reg (force_to_reg one) in
37823792
aliasing false src
37833793
begin
37843794
fun src ->
@@ -3814,17 +3824,28 @@ let trans_visitor
38143824
* through to the binding's self-copy fptr. For now
38153825
* this only works by accident.
38163826
*)
3817-
trans_copy_ty ty_params initializing
3827+
trans_copy_ty ty_params true
38183828
dst_binding (Ast.TY_box Ast.TY_int)
38193829
src_binding (Ast.TY_box Ast.TY_int);
38203830
patch null_jmp
38213831
end
38223832

38233833
| _ ->
3824-
iter_ty_parts_full ty_params dst src ty
3825-
(fun dst src ty ->
3826-
trans_copy_ty ty_params true
3827-
dst ty src ty)
3834+
if force_inline || should_inline_structure_helpers ty
3835+
then
3836+
iter_ty_parts_full ty_params dst src ty
3837+
(fun dst src ty ->
3838+
trans_copy_ty ty_params true
3839+
dst ty src ty)
3840+
else
3841+
let initflag = Il.Reg (force_to_reg one) in
3842+
trans_call_static_glue
3843+
(code_fixup_to_ptr_operand (get_copy_glue ty))
3844+
(Some dst)
3845+
[| alias ty_params;
3846+
alias src;
3847+
initflag |]
3848+
None
38283849

38293850

38303851
and trans_copy

0 commit comments

Comments
 (0)