From c6a23cddfb66c97c5c5a5836a08c602ba2bb4f02 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 14 May 2012 16:31:35 -0700 Subject: [PATCH] rustc: Make unique closures use the new unique allocator --- src/rustc/middle/trans/closure.rs | 10 +++------- src/rustc/middle/trans/uniq.rs | 11 +---------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 0de416e89f7..f1d0e4e8746 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -179,10 +179,7 @@ fn allocate_cbox(bcx: block, (bcx, box) } ty::ck_uniq { - let uniq_cbox_ty = mk_tuplified_uniq_cbox_ty(tcx, cdata_ty); - let box = uniq::alloc_uniq(bcx, uniq_cbox_ty); - nuke_ref_count(bcx, box); - let bcx = store_tydesc(bcx, cdata_ty, box, ti); + let box = malloc_unique_raw(bcx, cdata_ty); (bcx, box) } ty::ck_block { @@ -606,7 +603,7 @@ fn make_opaque_cbox_free_glue( ty::ck_box | ty::ck_uniq { /* hard cases: */ } } - let ccx = bcx.ccx(), tcx = ccx.tcx; + let ccx = bcx.ccx(); with_cond(bcx, IsNotNull(bcx, cbox)) {|bcx| // Load the type descr found in the cbox let lltydescty = T_ptr(ccx.tydesc_type); @@ -628,8 +625,7 @@ fn make_opaque_cbox_free_glue( trans_free(bcx, cbox) } ty::ck_uniq { - let bcx = free_ty(bcx, tydesc, ty::mk_type(tcx)); - trans_shared_free(bcx, cbox) + trans_unique_free(bcx, cbox) } } } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index cde7cbf4b70..a3325fc4904 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -5,7 +5,7 @@ import build::*; import base::*; import shape::llsize_of; -export trans_uniq, make_free_glue, autoderef, duplicate, alloc_uniq; +export trans_uniq, make_free_glue, autoderef, duplicate; fn trans_uniq(bcx: block, contents: @ast::expr, node_id: ast::node_id, dest: dest) -> block { @@ -19,15 +19,6 @@ fn trans_uniq(bcx: block, contents: @ast::expr, ret store_in_dest(bcx, box, dest); } -fn alloc_uniq(bcx: block, uniq_ty: ty::t) -> ValueRef { - let _icx = bcx.insn_ctxt("uniq::alloc_uniq"); - let contents_ty = content_ty(uniq_ty); - let llty = type_of::type_of(bcx.ccx(), contents_ty); - let llsz = llsize_of(bcx.ccx(), llty); - let llptrty = T_ptr(llty); - shared_malloc(bcx, llptrty, llsz) -} - fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) -> block { let _icx = bcx.insn_ctxt("uniq::make_free_glue");