rustc: Call the box annihilator in main
This commit is contained in:
parent
24c89693f0
commit
1c5db46f8e
@ -71,13 +71,13 @@ struct Task {
|
||||
#[lang="annihilate"]
|
||||
pub unsafe fn annihilate() {
|
||||
use rt::rt_free;
|
||||
use io::WriterUtil;
|
||||
|
||||
let task: *Task = transmute(rustrt::rust_get_task());
|
||||
|
||||
// Pass 1: Make all boxes immortal.
|
||||
let box = (*task).boxed_region.live_allocs;
|
||||
let mut box: *mut BoxRepr = transmute(copy box);
|
||||
assert (*box).prev == null();
|
||||
while box != mut_null() {
|
||||
debug!("making box immortal: %x", box as uint);
|
||||
(*box).ref_count = 0x77777777;
|
||||
@ -87,7 +87,6 @@ pub unsafe fn annihilate() {
|
||||
// Pass 2: Drop all boxes.
|
||||
let box = (*task).boxed_region.live_allocs;
|
||||
let mut box: *mut BoxRepr = transmute(copy box);
|
||||
assert (*box).prev == null();
|
||||
while box != mut_null() {
|
||||
debug!("calling drop glue for box: %x", box as uint);
|
||||
let tydesc: *TypeDesc = transmute(copy (*box).type_desc);
|
||||
|
@ -1984,6 +1984,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
||||
let bcx = top_scope_block(fcx, None);
|
||||
let lltop = bcx.llbb;
|
||||
|
||||
// Call main.
|
||||
let lloutputarg = llvm::LLVMGetParam(llfdecl, 0 as c_uint);
|
||||
let llenvarg = llvm::LLVMGetParam(llfdecl, 1 as c_uint);
|
||||
let mut args = ~[lloutputarg, llenvarg];
|
||||
@ -1991,10 +1992,14 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
||||
vec::push(args, llvm::LLVMGetParam(llfdecl, 2 as c_uint));
|
||||
}
|
||||
Call(bcx, main_llfn, args);
|
||||
|
||||
// Call the box annihilator.
|
||||
let did = bcx.tcx().lang_items.annihilate_fn.get();
|
||||
let bcx = callee::trans_rtcall_or_lang_call(bcx, did, ~[],
|
||||
expr::Ignore);
|
||||
|
||||
build_return(bcx);
|
||||
|
||||
finish_fn(fcx, lltop);
|
||||
|
||||
return llfdecl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user