Skip to content

Commit 7814745

Browse files
committed
rustc: Remove trans_raw_malloc, as it's only called from one place
1 parent d882f8e commit 7814745

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/comp/middle/trans.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -799,19 +799,6 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: ast::def_id,
799799
ret rslt(rs.bcx, val);
800800
}
801801

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-
815802
// trans_shared_malloc: expects a type indicating which pointer type we want
816803
// and a size indicating how much space we want malloc'd.
817804
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)
829816
// enough space for something of that type, along with space for a reference
830817
// count; in other words, it allocates a box for something of that type.
831818
fn trans_malloc_boxed_raw(cx: @block_ctxt, t: ty::t) -> result {
819+
let bcx = cx;
820+
832821
// Synthesize a fake box type structurally so we have something
833822
// to measure the size of.
834823

@@ -839,9 +828,10 @@ fn trans_malloc_boxed_raw(cx: @block_ctxt, t: ty::t) -> result {
839828

840829
// The mk_int here is the space being
841830
// 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;
845835

846836
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
847837
// wants.
@@ -851,7 +841,10 @@ fn trans_malloc_boxed_raw(cx: @block_ctxt, t: ty::t) -> result {
851841
let sp = cx.sp;
852842
check (type_has_static_size(ccx, box_ptr));
853843
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));
855848
}
856849

857850
// trans_malloc_boxed: usefully wraps trans_malloc_box_raw; allocates a box,

0 commit comments

Comments
 (0)