@@ -383,14 +383,10 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
383383 Result :: new ( r. bcx , PointerCast ( r. bcx , r. val , llty_ptr) )
384384}
385385
386- pub fn malloc_raw_dyn_proc < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
387- t : ty:: t , alloc_fn : LangItem )
388- -> Result < ' blk , ' tcx > {
386+ pub fn malloc_raw_dyn_proc < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , t : ty:: t ) -> Result < ' blk , ' tcx > {
389387 let _icx = push_ctxt ( "malloc_raw_dyn_proc" ) ;
390388 let ccx = bcx. ccx ( ) ;
391389
392- let langcall = require_alloc_fn ( bcx, t, alloc_fn) ;
393-
394390 // Grab the TypeRef type of ptr_ty.
395391 let ptr_ty = ty:: mk_uniq ( bcx. tcx ( ) , t) ;
396392 let ptr_llty = type_of ( ccx, ptr_ty) ;
@@ -399,18 +395,15 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
399395 let size = llsize_of ( bcx. ccx ( ) , llty) ;
400396 let llalign = C_uint ( ccx, llalign_of_min ( bcx. ccx ( ) , llty) as uint ) ;
401397
402- // Allocate space:
403- let drop_glue = glue:: get_drop_glue ( ccx, ty:: mk_uniq ( bcx. tcx ( ) , t) ) ;
404- let r = callee:: trans_lang_call (
405- bcx,
406- langcall,
407- [
408- PointerCast ( bcx, drop_glue, Type :: glue_fn ( ccx, Type :: i8p ( ccx) ) . ptr_to ( ) ) ,
409- size,
410- llalign
411- ] ,
412- None ) ;
413- Result :: new ( r. bcx , PointerCast ( r. bcx , r. val , ptr_llty) )
398+ // Allocate space and store the destructor pointer:
399+ let Result { bcx : bcx, val : llbox} = malloc_raw_dyn ( bcx, ptr_llty, t, size, llalign) ;
400+ let dtor_ptr = GEPi ( bcx, llbox, [ 0 u, abi:: box_field_drop_glue] ) ;
401+ let drop_glue_field_ty = type_of ( ccx, ty:: mk_nil_ptr ( bcx. tcx ( ) ) ) ;
402+ let drop_glue = PointerCast ( bcx, glue:: get_drop_glue ( ccx, ty:: mk_uniq ( bcx. tcx ( ) , t) ) ,
403+ drop_glue_field_ty) ;
404+ Store ( bcx, drop_glue, dtor_ptr) ;
405+
406+ Result :: new ( bcx, llbox)
414407}
415408
416409
0 commit comments