@@ -1954,13 +1954,13 @@ let trans_visitor
1954
1954
let initflag = get_element_ptr args arg_initflag in
1955
1955
let jmps = trans_compare_simple Il. JNE (Il. Cell initflag) one in
1956
1956
1957
- trans_copy_ty ty_params true dst ty src ty;
1957
+ trans_copy_ty_full true ty_params true dst ty src ty;
1958
1958
1959
1959
let skip_noninit_jmp = mark() in
1960
1960
emit (Il. jmp Il. JMP Il. CodeNone );
1961
1961
List. iter patch jmps;
1962
1962
1963
- trans_copy_ty ty_params false dst ty src ty;
1963
+ trans_copy_ty_full true ty_params false dst ty src ty;
1964
1964
1965
1965
patch skip_noninit_jmp;
1966
1966
in
@@ -3661,6 +3661,16 @@ let trans_visitor
3661
3661
(dst :Il.cell ) (dst_ty :Ast.ty )
3662
3662
(src :Il.cell ) (src_ty :Ast.ty )
3663
3663
: 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 =
3664
3674
let anno (weight :string ) : unit =
3665
3675
iflog
3666
3676
begin
@@ -3700,7 +3710,7 @@ let trans_visitor
3700
3710
| _ ->
3701
3711
(* Heavyweight copy: duplicate 1 level of the referent. *)
3702
3712
anno " heavy" ;
3703
- trans_copy_ty_heavy ty_params initializing
3713
+ trans_copy_ty_heavy force_inline ty_params initializing
3704
3714
dst dst_ty src src_ty
3705
3715
end
3706
3716
@@ -3732,6 +3742,7 @@ let trans_visitor
3732
3742
*)
3733
3743
3734
3744
and trans_copy_ty_heavy
3745
+ (force_inline :bool )
3735
3746
(ty_params :Il.cell )
3736
3747
(initializing :bool )
3737
3748
(dst :Il.cell ) (dst_ty :Ast.ty )
@@ -3777,8 +3788,7 @@ let trans_visitor
3777
3788
iflog
3778
3789
(fun _ -> annotate
3779
3790
(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
3782
3792
aliasing false src
3783
3793
begin
3784
3794
fun src ->
@@ -3814,17 +3824,28 @@ let trans_visitor
3814
3824
* through to the binding's self-copy fptr. For now
3815
3825
* this only works by accident.
3816
3826
*)
3817
- trans_copy_ty ty_params initializing
3827
+ trans_copy_ty ty_params true
3818
3828
dst_binding (Ast. TY_box Ast. TY_int )
3819
3829
src_binding (Ast. TY_box Ast. TY_int );
3820
3830
patch null_jmp
3821
3831
end
3822
3832
3823
3833
| _ ->
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
3828
3849
3829
3850
3830
3851
and trans_copy
0 commit comments