@@ -799,19 +799,6 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: ast::def_id,
799
799
ret rslt( rs. bcx , val) ;
800
800
}
801
801
802
- // trans_raw_malloc: expects a type indicating which pointer type we want and
803
- // a size indicating how much space we want malloc'd.
804
- fn trans_raw_malloc ( cx : @block_ctxt , llptr_ty : TypeRef , llsize : ValueRef ) ->
805
- result {
806
- // FIXME: need a table to collect tydesc globals.
807
-
808
- let tydesc = C_null ( T_ptr ( bcx_ccx ( cx) . tydesc_type ) ) ;
809
- let rval =
810
- Call ( cx, bcx_ccx ( cx) . upcalls . malloc ,
811
- [ cx. fcx . lltaskptr , llsize, tydesc] ) ;
812
- ret rslt( cx, PointerCast ( cx, rval, llptr_ty) ) ;
813
- }
814
-
815
802
// trans_shared_malloc: expects a type indicating which pointer type we want
816
803
// and a size indicating how much space we want malloc'd.
817
804
fn trans_shared_malloc ( cx : @block_ctxt , llptr_ty : TypeRef , llsize : ValueRef )
@@ -829,6 +816,8 @@ fn trans_shared_malloc(cx: @block_ctxt, llptr_ty: TypeRef, llsize: ValueRef)
829
816
// enough space for something of that type, along with space for a reference
830
817
// count; in other words, it allocates a box for something of that type.
831
818
fn trans_malloc_boxed_raw ( cx : @block_ctxt , t : ty:: t ) -> result {
819
+ let bcx = cx;
820
+
832
821
// Synthesize a fake box type structurally so we have something
833
822
// to measure the size of.
834
823
@@ -839,9 +828,10 @@ fn trans_malloc_boxed_raw(cx: @block_ctxt, t: ty::t) -> result {
839
828
840
829
// The mk_int here is the space being
841
830
// reserved for the refcount.
842
- let boxed_body = ty:: mk_tup ( bcx_tcx ( cx) , [ ty:: mk_int ( bcx_tcx ( cx) ) , t] ) ;
843
- let box_ptr = ty:: mk_imm_box ( bcx_tcx ( cx) , t) ;
844
- let sz = size_of ( cx, boxed_body) ;
831
+ let boxed_body = ty:: mk_tup ( bcx_tcx ( bcx) , [ ty:: mk_int ( bcx_tcx ( cx) ) , t] ) ;
832
+ let box_ptr = ty:: mk_imm_box ( bcx_tcx ( bcx) , t) ;
833
+ let r = size_of ( cx, boxed_body) ;
834
+ let llsz = r. val ; bcx = r. bcx ;
845
835
846
836
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
847
837
// wants.
@@ -851,7 +841,10 @@ fn trans_malloc_boxed_raw(cx: @block_ctxt, t: ty::t) -> result {
851
841
let sp = cx. sp ;
852
842
check ( type_has_static_size ( ccx, box_ptr) ) ;
853
843
let llty = type_of ( ccx, sp, box_ptr) ;
854
- ret trans_raw_malloc ( sz. bcx , llty, sz. val ) ;
844
+
845
+ let tydesc = C_null ( T_ptr ( ccx. tydesc_type ) ) ;
846
+ let rval = Call ( cx, ccx. upcalls . malloc , [ cx. fcx . lltaskptr , llsz, tydesc] ) ;
847
+ ret rslt( cx, PointerCast ( cx, rval, llty) ) ;
855
848
}
856
849
857
850
// trans_malloc_boxed: usefully wraps trans_malloc_box_raw; allocates a box,
0 commit comments