Skip to content

Commit 4e080df

Browse files
committed
---
yaml --- r: 1607 b: refs/heads/master c: fc7cbe3 h: refs/heads/master i: 1605: 7b03814 1603: ff67d0e 1599: 5ce6008 v: v3
1 parent 3fe9cdf commit 4e080df

File tree

5 files changed

+78
-103
lines changed

5 files changed

+78
-103
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2ef57287229218466f87ea99c20f9a16f889e1c7
2+
refs/heads/master: fc7cbe31f9639a1d37baf4a35df9719ad155aa2c

trunk/src/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ TEST_XFAILS_RUSTC := $(addprefix test/run-pass/, \
475475
pred.rs \
476476
preempt.rs \
477477
rt-circular-buffer.rs \
478-
size-and-align.rs \
479478
spawn-fn.rs \
480479
spawn-module-qualified.rs \
481480
spawn.rs \

trunk/src/boot/be/abi.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ let general_code_alignment = 16;;
8080
let tydesc_field_first_param = 0;;
8181
let tydesc_field_size = 1;;
8282
let tydesc_field_align = 2;;
83-
let tydesc_field_copy_glue = 3;;
83+
let tydesc_field_take_glue = 3;;
8484
let tydesc_field_drop_glue = 4;;
8585
let tydesc_field_free_glue = 5;;
8686
let tydesc_field_sever_glue = 6;;

trunk/src/boot/me/semant.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type glue =
2020
| GLUE_yield
2121
| GLUE_exit_main_task
2222
| GLUE_exit_task
23-
| GLUE_copy of Ast.ty (* One-level copy. *)
23+
| GLUE_take of Ast.ty (* One-level refcounts++. *)
2424
| GLUE_drop of Ast.ty (* De-initialize local memory. *)
2525
| GLUE_free of Ast.ty (* Drop body + free() box ptr. *)
2626
| GLUE_sever of Ast.ty (* Null all box state slots. *)
@@ -2776,7 +2776,7 @@ let glue_str (cx:ctxt) (g:glue) : string =
27762776
| GLUE_yield -> "glue$yield"
27772777
| GLUE_exit_main_task -> "glue$exit_main_task"
27782778
| GLUE_exit_task -> "glue$exit_task"
2779-
| GLUE_copy ty -> "glue$copy$" ^ (ty_str cx ty)
2779+
| GLUE_take ty -> "glue$take$" ^ (ty_str cx ty)
27802780
| GLUE_drop ty -> "glue$drop$" ^ (ty_str cx ty)
27812781
| GLUE_free ty -> "glue$free$" ^ (ty_str cx ty)
27822782
| GLUE_sever ty -> "glue$sever$" ^ (ty_str cx ty)

trunk/src/boot/me/trans.ml

Lines changed: 74 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ let trans_visitor
13551355
Asm.WORD (word_ty_mach, Asm.IMM 0L);
13561356
Asm.WORD (word_ty_mach, Asm.IMM sz);
13571357
Asm.WORD (word_ty_mach, Asm.IMM align);
1358-
fix (get_copy_glue t);
1358+
fix (get_take_glue t);
13591359
fix (get_drop_glue t);
13601360
begin
13611361
match ty_mem_ctrl cx t with
@@ -2022,34 +2022,18 @@ let trans_visitor
20222022
get_typed_mem_glue g fty inner
20232023

20242024

2025-
and get_copy_glue
2025+
and get_take_glue
20262026
(ty:Ast.ty)
20272027
: fixup =
20282028
let ty = get_genericized_ty ty in
20292029
let arg_ty_params_alias = 0 in
20302030
let arg_src_alias = 1 in
2031-
let arg_initflag = 2 in
20322031

2033-
let g = GLUE_copy ty in
2034-
let inner (out_ptr:Il.cell) (args:Il.cell) =
2035-
let dst = deref out_ptr in
2032+
let g = GLUE_take ty in
2033+
let inner (_:Il.cell) (args:Il.cell) =
20362034
let ty_params = deref (get_element_ptr args arg_ty_params_alias) in
20372035
let src = deref (get_element_ptr args arg_src_alias) in
2038-
2039-
(* Translate copy code for the dst-initializing and
2040-
* dst-non-initializing cases and branch accordingly. *)
2041-
let initflag = get_element_ptr args arg_initflag in
2042-
let jmps = trans_compare_simple Il.JNE (Il.Cell initflag) one in
2043-
2044-
trans_copy_ty_full true ty_params true dst ty src ty;
2045-
2046-
let skip_noninit_jmp = mark() in
2047-
emit (Il.jmp Il.JMP Il.CodeNone);
2048-
List.iter patch jmps;
2049-
2050-
trans_copy_ty_full true ty_params false dst ty src ty;
2051-
2052-
patch skip_noninit_jmp;
2036+
trans_take_ty true ty_params src ty;
20532037
in
20542038
let ty_params_ptr = ty_params_covering ty in
20552039
let fty =
@@ -2186,17 +2170,23 @@ let trans_visitor
21862170
get_tydesc_params ty_params_cell elt_td_ptr_cell
21872171
in
21882172

2189-
let initflag = Il.Reg (force_to_reg one) in
2190-
2173+
(* Take all *)
21912174
copy_loop dst_buf src_buf (Il.Cell fill) (Il.Cell elt_sz)
21922175
begin
2193-
fun dptr sptr ->
2176+
fun _ sptr ->
21942177
trans_call_dynamic_glue
21952178
elt_td_ptr_cell
2196-
Abi.tydesc_field_copy_glue
2197-
(Some (deref dptr))
2198-
[| ty_params_ptr; sptr; initflag |]
2179+
Abi.tydesc_field_take_glue
21992180
None
2181+
[| ty_params_ptr; sptr |]
2182+
None;
2183+
end;
2184+
2185+
(* Memcpy all *)
2186+
copy_loop dst_buf src_buf (Il.Cell fill) one
2187+
begin
2188+
fun dptr sptr ->
2189+
mov (deref dptr) (Il.Cell (deref sptr))
22002190
end;
22012191

22022192
(* Set the new vec's fill to the original vec's fill *)
@@ -3734,17 +3724,58 @@ let trans_visitor
37343724
end
37353725
tys
37363726

3737-
and trans_copy_ty
3727+
and trans_take_ty
3728+
(force_inline:bool)
37383729
(ty_params:Il.cell)
3739-
(initializing:bool)
3740-
(dst:Il.cell) (dst_ty:Ast.ty)
3741-
(src:Il.cell) (src_ty:Ast.ty)
3730+
(v:Il.cell)
3731+
(ty:Ast.ty)
37423732
: unit =
3743-
trans_copy_ty_full
3744-
false ty_params initializing dst dst_ty src src_ty
3733+
let ty = strip_mutable_or_constrained_ty ty in
3734+
match ty_mem_ctrl cx ty with
3735+
MEM_rc_opaque | MEM_gc | MEM_rc_struct -> incr_refcount v
3736+
| _ ->
3737+
begin
3738+
match ty with
3739+
Ast.TY_fn _
3740+
| Ast.TY_obj _ ->
3741+
let binding =
3742+
get_element_ptr v Abi.binding_field_bound_data
3743+
in
3744+
let null_jmp = null_check binding in
3745+
incr_refcount binding;
3746+
patch null_jmp
37453747

3746-
and trans_copy_ty_full
3747-
(force_inline:bool)
3748+
| Ast.TY_param (i, _) ->
3749+
aliasing false v
3750+
begin
3751+
fun v ->
3752+
let td = get_ty_param ty_params i in
3753+
let ty_params_ptr = get_tydesc_params ty_params td in
3754+
trans_call_dynamic_glue
3755+
td Abi.tydesc_field_take_glue
3756+
None
3757+
[| ty_params_ptr; v; |]
3758+
None
3759+
end
3760+
3761+
| Ast.TY_rec _
3762+
| Ast.TY_tag _
3763+
| Ast.TY_tup _ ->
3764+
if force_inline
3765+
then
3766+
iter_ty_parts ty_params v ty
3767+
(trans_take_ty force_inline ty_params)
3768+
else
3769+
trans_call_static_glue
3770+
(code_fixup_to_ptr_operand (get_take_glue ty))
3771+
None
3772+
[| alias ty_params; alias v; |]
3773+
None
3774+
3775+
| _ -> ()
3776+
end
3777+
3778+
and trans_copy_ty
37483779
(ty_params:Il.cell)
37493780
(initializing:bool)
37503781
(dst:Il.cell) (dst_ty:Ast.ty)
@@ -3789,7 +3820,7 @@ let trans_visitor
37893820
| _ ->
37903821
(* Heavyweight copy: duplicate 1 level of the referent. *)
37913822
anno "heavy";
3792-
trans_copy_ty_heavy force_inline ty_params initializing
3823+
trans_copy_ty_heavy ty_params initializing
37933824
dst dst_ty src src_ty
37943825
end
37953826

@@ -3821,7 +3852,6 @@ let trans_visitor
38213852
*)
38223853

38233854
and trans_copy_ty_heavy
3824-
(force_inline:bool)
38253855
(ty_params:Il.cell)
38263856
(initializing:bool)
38273857
(dst:Il.cell) (dst_ty:Ast.ty)
@@ -3863,68 +3893,14 @@ let trans_visitor
38633893
(ty_sz cx ty)));
38643894
mov dst (Il.Cell src)
38653895

3866-
| Ast.TY_param (i, _) ->
3867-
iflog
3868-
(fun _ -> annotate
3869-
(Printf.sprintf "copy_ty: parametric copy %#d" i));
3870-
let initflag = Il.Reg (force_to_reg one) in
3871-
aliasing false src
3872-
begin
3873-
fun src ->
3874-
let td = get_ty_param ty_params i in
3875-
let ty_params_ptr = get_tydesc_params ty_params td in
3876-
trans_call_dynamic_glue
3877-
td Abi.tydesc_field_copy_glue
3878-
(Some dst)
3879-
[| ty_params_ptr; src; initflag |]
3880-
None
3881-
end
3882-
3883-
| Ast.TY_fn _
3884-
| Ast.TY_obj _ ->
3885-
begin
3886-
let src_item =
3887-
get_element_ptr src Abi.binding_field_dispatch
3888-
in
3889-
let dst_item =
3890-
get_element_ptr dst Abi.binding_field_dispatch
3891-
in
3892-
let src_binding =
3893-
get_element_ptr src Abi.binding_field_bound_data
3894-
in
3895-
let dst_binding =
3896-
get_element_ptr dst Abi.binding_field_bound_data
3897-
in
3898-
mov dst_item (Il.Cell src_item);
3899-
mov dst_binding zero;
3900-
let null_jmp = null_check src_binding in
3901-
(* Copy if we have a src binding. *)
3902-
(* FIXME (issue #58): this is completely wrong, call
3903-
* through to the binding's self-copy fptr. For now
3904-
* this only works by accident.
3905-
*)
3906-
trans_copy_ty ty_params true
3907-
dst_binding (Ast.TY_box Ast.TY_int)
3908-
src_binding (Ast.TY_box Ast.TY_int);
3909-
patch null_jmp
3910-
end
3911-
39123896
| _ ->
3913-
if force_inline || should_inline_structure_helpers ty
3914-
then
3915-
iter_ty_parts_full ty_params dst src ty
3916-
(fun dst src ty ->
3917-
trans_copy_ty ty_params initializing
3918-
dst ty src ty)
3919-
else
3920-
let initflag = Il.Reg (force_to_reg one) in
3921-
trans_call_static_glue
3922-
(code_fixup_to_ptr_operand (get_copy_glue ty))
3923-
(Some dst)
3924-
[| alias ty_params;
3925-
alias src;
3926-
initflag |]
3927-
None
3897+
trans_take_ty false ty_params src ty;
3898+
if not initializing
3899+
then drop_ty ty_params dst ty;
3900+
let sz = ty_sz_with_ty_params ty_params ty in
3901+
copy_loop dst src sz (imm 1L)
3902+
(fun dptr sptr ->
3903+
mov (deref dptr) (Il.Cell (deref sptr)))
39283904

39293905

39303906
and trans_copy

0 commit comments

Comments
 (0)