1
Fork 0

Remove debug_mem since @graydon said it conflicted with GC changes

This commit is contained in:
Niko Matsakis 2013-05-06 20:14:54 -04:00
parent 8b32bde408
commit ce45f390dd
2 changed files with 2 additions and 30 deletions

View file

@ -167,8 +167,7 @@ fn debug_mem() -> bool {
#[cfg(notest)]
#[lang="annihilate"]
pub unsafe fn annihilate() {
use unstable::lang::{local_free};
use unstable::lang;
use unstable::lang::local_free;
use io::WriterUtil;
use io;
use libc;
@ -192,10 +191,8 @@ pub unsafe fn annihilate() {
for each_live_alloc(true) |box, uniq| {
stats.n_total_boxes += 1;
if uniq {
lang::debug_mem("Managed-uniq: ", &*box);
stats.n_unique_boxes += 1;
} else {
lang::debug_mem("Immortalizing: ", &*box);
(*box).header.ref_count = managed::raw::RC_IMMORTAL;
}
}
@ -207,13 +204,9 @@ pub unsafe fn annihilate() {
// callback, as the original value may have been freed.
for each_live_alloc(false) |box, uniq| {
if !uniq {
lang::debug_mem("Invoking tydesc/glue on: ", &*box);
let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
lang::debug_mem("Box data: ", &(*box).data);
lang::debug_mem("Type descriptor: ", tydesc);
drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
lang::debug_mem("Dropped ", &*box);
}
}
@ -225,7 +218,6 @@ pub unsafe fn annihilate() {
// not be valid after.
for each_live_alloc(true) |box, uniq| {
if !uniq {
lang::debug_mem("About to free: ", &*box);
stats.n_bytes_freed +=
(*((*box).header.type_desc)).size
+ sys::size_of::<BoxRepr>();

View file

@ -153,32 +153,13 @@ unsafe fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
#[lang="exchange_malloc"]
#[inline(always)]
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
let result = transmute(exchange_alloc::malloc(transmute(td), transmute(size)));
debug_mem("exchange_malloc: ", result);
return result;
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
}
/// Because this code is so perf. sensitive, use a static constant so that
/// debug printouts are compiled out most of the time.
static ENABLE_DEBUG: bool = false;
#[inline]
pub fn debug_mem<T>(tag: &'static str, p: *const T) {
//! A useful debugging function that prints a pointer + tag + newline
//! without allocating memory.
if ENABLE_DEBUG && ::rt::env::get().debug_mem {
debug_mem_slow(tag, p);
}
fn debug_mem_slow<T>(tag: &'static str, p: *const T) {
let dbg = STDERR_FILENO as io::fd_t;
dbg.write_str(tag);
dbg.write_hex(p as uint);
dbg.write_str("\n");
}
}
#[inline]
unsafe fn debug_borrow<T>(tag: &'static str,
p: *const T,
@ -252,7 +233,6 @@ impl DebugPrints for io::fd_t {
#[lang="exchange_free"]
#[inline(always)]
pub unsafe fn exchange_free(ptr: *c_char) {
debug_mem("exchange_free: ", ptr);
exchange_alloc::free(transmute(ptr))
}