@@ -1893,34 +1893,38 @@ let trans_visitor
1893
1893
get_typed_mem_glue g fty inner
1894
1894
1895
1895
(*
1896
- * Vector-growth glue takes four arguments:
1896
+ * Vector-growth glue takes the following arguments:
1897
1897
*
1898
1898
* 0. (Implicit) task ptr
1899
1899
* 1. Pointer to the typarams of the caller's frame (possibly required to
1900
1900
* be passed to element's copy glue).
1901
- * 2. Pointer to tydesc of the vec's stored element type, so that elements
1901
+ * 2. Pointer to the tydesc of the vec, so that we can tell if it's gc
1902
+ * mem, and have a tydesc to pass to malloc if we're allocating anew.
1903
+ * 3. Pointer to tydesc of the vec's stored element type, so that elements
1902
1904
* can be copied to a newly alloc'ed vec if one must be created.
1903
- * 3 . Alias to vec that needs to grow (i.e. ptr to ptr to rust_vec).
1904
- * 4 . Number of bytes of growth requested
1905
+ * 4 . Alias to vec that needs to grow (i.e. ptr to ptr to rust_vec).
1906
+ * 5 . Number of bytes of growth requested
1905
1907
*)
1906
1908
and emit_vec_grow_glue
1907
1909
(fix :fixup )
1908
1910
(g :glue )
1909
1911
: unit =
1910
1912
let arg_typarams_ptr = 0 in
1911
- let arg_tydesc_ptr = 1 in
1912
- let arg_vec_alias = 2 in
1913
- let arg_nbytes = 3 in
1913
+ let arg_vec_tydesc_ptr = 1 in
1914
+ let arg_elt_tydesc_ptr = 2 in
1915
+ let arg_vec_alias = 3 in
1916
+ let arg_nbytes = 4 in
1914
1917
1915
1918
let name = glue_str cx g in
1916
1919
log cx " emitting glue: %s" name;
1917
1920
1918
1921
let fn_ty =
1919
1922
mk_simple_ty_fn
1920
1923
[| ty_params_covering Ast. TY_int ; (* an OK lie *)
1924
+ local_slot Ast. TY_type ;
1921
1925
local_slot Ast. TY_type ;
1922
1926
alias_slot (Ast. TY_vec Ast. TY_int ); (* an OK lie *)
1923
- local_slot Ast. TY_uint ; |]
1927
+ local_slot Ast. TY_uint |]
1924
1928
in
1925
1929
1926
1930
let args_rty = call_args_referent_type cx 0 fn_ty None in
@@ -1936,7 +1940,8 @@ let trans_visitor
1936
1940
let vec_alias_cell = get_element_ptr args_cell arg_vec_alias in
1937
1941
let vec_cell = deref vec_alias_cell in
1938
1942
let nbytes_cell = get_element_ptr args_cell arg_nbytes in
1939
- let td_ptr_cell = get_element_ptr args_cell arg_tydesc_ptr in
1943
+ let vec_td_ptr_cell = get_element_ptr args_cell arg_vec_tydesc_ptr in
1944
+ let elt_td_ptr_cell = get_element_ptr args_cell arg_elt_tydesc_ptr in
1940
1945
let ty_params_cell =
1941
1946
deref (get_element_ptr args_cell arg_typarams_ptr)
1942
1947
in
@@ -1951,7 +1956,8 @@ let trans_visitor
1951
1956
new_vec_cell
1952
1957
[| Il. Cell vec_cell;
1953
1958
Il. Cell nbytes_cell;
1954
- Il. Cell need_copy_alias_cell |]
1959
+ Il. Cell need_copy_alias_cell;
1960
+ Il. Cell vec_td_ptr_cell; |]
1955
1961
end;
1956
1962
1957
1963
let no_copy_jmps =
@@ -1965,7 +1971,7 @@ let trans_visitor
1965
1971
get_element_ptr_dyn ty_params_cell src_vec Abi. vec_elt_fill
1966
1972
in
1967
1973
let elt_sz =
1968
- get_element_ptr (deref td_ptr_cell ) Abi. tydesc_field_size
1974
+ get_element_ptr (deref elt_td_ptr_cell ) Abi. tydesc_field_size
1969
1975
in
1970
1976
1971
1977
let dst_buf =
@@ -1993,11 +1999,11 @@ let trans_visitor
1993
1999
1994
2000
(* Copy *)
1995
2001
let ty_params_ptr =
1996
- get_tydesc_params ty_params_cell td_ptr_cell
2002
+ get_tydesc_params ty_params_cell elt_td_ptr_cell
1997
2003
in
1998
2004
let initflag = Il. Reg (force_to_reg one) in
1999
2005
trans_call_dynamic_glue
2000
- td_ptr_cell
2006
+ elt_td_ptr_cell
2001
2007
Abi. tydesc_field_copy_glue
2002
2008
(Some (deref dptr))
2003
2009
[| ty_params_ptr; sptr; initflag |]
@@ -2971,8 +2977,8 @@ let trans_visitor
2971
2977
(ty :Ast.ty )
2972
2978
: unit =
2973
2979
2974
- let ty = strip_mutable_or_constrained_ty ty in
2975
2980
let mctrl = ty_mem_ctrl cx ty in
2981
+ let ty = strip_mutable_or_constrained_ty ty in
2976
2982
2977
2983
match ty with
2978
2984
@@ -3173,7 +3179,7 @@ let trans_visitor
3173
3179
check_box_rty cell;
3174
3180
note_drop_step ty " in free-ty" ;
3175
3181
begin
3176
- match simplified_ty ty with
3182
+ match strip_mutable_or_constrained_ty ty with
3177
3183
Ast. TY_port _ -> trans_del_port cell
3178
3184
| Ast. TY_chan _ -> trans_del_chan cell
3179
3185
| Ast. TY_task -> trans_kill_task cell
@@ -3183,14 +3189,13 @@ let trans_visitor
3183
3189
(fun _ src ty -> drop_ty ty_params src ty);
3184
3190
trans_free cell is_gc
3185
3191
3186
- | _ ->
3192
+ | Ast. TY_box body_ty ->
3187
3193
note_drop_step ty " in free-ty, dropping structured body" ;
3188
3194
let (body_mem, _) =
3189
3195
need_mem_cell
3190
3196
(get_element_ptr_dyn ty_params (deref cell)
3191
3197
Abi. box_rc_field_body)
3192
3198
in
3193
- let body_ty = simplified_ty ty in
3194
3199
let vr = next_vreg_cell Il. voidptr_t in
3195
3200
lea vr body_mem;
3196
3201
trace_word cx.ctxt_sess.Session. sess_trace_drop vr;
@@ -3201,6 +3206,8 @@ let trans_visitor
3201
3206
None ;
3202
3207
note_drop_step ty " in free-ty, calling free" ;
3203
3208
trans_free cell is_gc;
3209
+
3210
+ | t -> bug () " freeing unexpected type: %a" Ast. sprintf_ty t
3204
3211
end ;
3205
3212
note_drop_step ty " free-ty done" ;
3206
3213
@@ -3268,13 +3275,17 @@ let trans_visitor
3268
3275
(slot :Ast.slot )
3269
3276
: unit =
3270
3277
check_and_flush_chan cell slot;
3271
- drop_slot (get_ty_params_of_current_frame() ) cell slot
3278
+ drop_slot (get_ty_params_of_current_frame() ) cell
3279
+ { slot with
3280
+ Ast. slot_ty = Some (strip_mutable_or_constrained_ty
3281
+ (slot_ty slot)) }
3272
3282
3273
3283
and drop_ty_in_current_frame
3274
3284
(cell :Il.cell )
3275
3285
(ty :Ast.ty )
3276
3286
: unit =
3277
- drop_ty (get_ty_params_of_current_frame() ) cell ty
3287
+ drop_ty (get_ty_params_of_current_frame() ) cell
3288
+ (strip_mutable_or_constrained_ty ty)
3278
3289
3279
3290
(* Returns a mark for a jmp that must be patched to the continuation of
3280
3291
* the null case (i.e. fall-through means not null).
@@ -4755,7 +4766,8 @@ let trans_visitor
4755
4766
trans_call_simple_static_glue
4756
4767
(get_vec_grow_glue () )
4757
4768
(get_ty_params_of_current_frame () )
4758
- [| get_tydesc None elt_ty;
4769
+ [| get_tydesc None dst_ty;
4770
+ get_tydesc None elt_ty;
4759
4771
dst_vec_alias;
4760
4772
src_fill; |]
4761
4773
None
@@ -4827,7 +4839,8 @@ let trans_visitor
4827
4839
trans_call_simple_static_glue
4828
4840
(get_vec_grow_glue () )
4829
4841
(get_ty_params_of_current_frame () )
4830
- [| get_tydesc None elt_ty;
4842
+ [| get_tydesc None dst_ty;
4843
+ get_tydesc None elt_ty;
4831
4844
dst_vec_alias;
4832
4845
elt_sz_cell; |]
4833
4846
None
0 commit comments