diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-02-12 16:40:17 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-02-13 12:54:17 -0800 |
| commit | 1c5295c0bf6e69a772120ec6a56e0fdb3021ded4 (patch) | |
| tree | b4c3ab032249a36a7885046556949d086f390366 /src/libstd | |
| parent | 44e6883d1462ed4072b1d6a3ce6702bc14065045 (diff) | |
| download | rust-1c5295c0bf6e69a772120ec6a56e0fdb3021ded4.tar.gz rust-1c5295c0bf6e69a772120ec6a56e0fdb3021ded4.zip | |
Register new snapshots
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cleanup.rs | 47 | ||||
| -rw-r--r-- | src/libstd/reflect.rs | 7 | ||||
| -rw-r--r-- | src/libstd/repr.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/global_heap.rs | 30 | ||||
| -rw-r--r-- | src/libstd/rt/local_heap.rs | 74 | ||||
| -rw-r--r-- | src/libstd/unstable/intrinsics.rs | 4 | ||||
| -rw-r--r-- | src/libstd/unstable/lang.rs | 8 | ||||
| -rw-r--r-- | src/libstd/unstable/raw.rs | 13 |
8 files changed, 1 insertions, 186 deletions
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index a43dca94970..dd43d8e2971 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -57,53 +57,6 @@ fn debug_mem() -> bool { } /// Destroys all managed memory (i.e. @ boxes) held by the current task. -#[cfg(stage0)] -pub unsafe fn annihilate() { - use rt::local_heap::local_free; - - let mut n_total_boxes = 0u; - - // Pass 1: Make all boxes immortal. - // - // In this pass, nothing gets freed, so it does not matter whether - // we read the next field before or after the callback. - each_live_alloc(true, |alloc| { - n_total_boxes += 1; - (*alloc).ref_count = RC_IMMORTAL; - true - }); - - // Pass 2: Drop all boxes. - // - // In this pass, unique-managed boxes may get freed, but not - // managed boxes, so we must read the `next` field *after* the - // callback, as the original value may have been freed. - each_live_alloc(false, |alloc| { - let tydesc = (*alloc).type_desc; - let data = &(*alloc).data as *(); - ((*tydesc).drop_glue)(data as *i8); - true - }); - - // Pass 3: Free all boxes. - // - // In this pass, managed boxes may get freed (but not - // unique-managed boxes, though I think that none of those are - // left), so we must read the `next` field before, since it will - // not be valid after. - each_live_alloc(true, |alloc| { - local_free(alloc as *u8); - true - }); - - if debug_mem() { - // We do logging here w/o allocation. - debug!("total boxes annihilated: {}", n_total_boxes); - } -} - -/// Destroys all managed memory (i.e. @ boxes) held by the current task. -#[cfg(not(stage0))] pub unsafe fn annihilate() { use rt::local_heap::local_free; diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 1c22408592a..f88da60ae9b 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -441,11 +441,4 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { self.align_to::<&'static u8>(); true } - - // NOTE Remove after next snapshot. - #[cfg(stage0)] - fn visit_type(&mut self) -> bool { - if ! self.inner.visit_type() { return false; } - true - } } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 4ced74a92b7..dc745ff548f 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -601,10 +601,6 @@ impl<'a> TyVisitor for ReprVisitor<'a> { fn visit_param(&mut self, _i: uint) -> bool { true } fn visit_self(&mut self) -> bool { true } - - // NOTE Remove after next snapshot. - #[cfg(stage0)] - fn visit_type(&mut self) -> bool { true } } pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 2f553585f38..4bce16706ee 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -10,8 +10,6 @@ use libc::{c_void, size_t, free, malloc, realloc}; use ptr::{RawPtr, mut_null}; -#[cfg(stage0)] -use unstable::intrinsics::TyDesc; use unstable::intrinsics::abort; use unstable::raw; use mem::size_of; @@ -75,15 +73,7 @@ pub unsafe fn exchange_malloc(size: uint) -> *u8 { } // FIXME: #7496 -#[cfg(not(test), stage0)] -#[lang="closure_exchange_malloc"] -#[inline] -pub unsafe fn closure_exchange_malloc_(td: *u8, size: uint) -> *u8 { - closure_exchange_malloc(td, size) -} - -// FIXME: #7496 -#[cfg(not(test), not(stage0))] +#[cfg(not(test))] #[lang="closure_exchange_malloc"] #[inline] pub unsafe fn closure_exchange_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { @@ -91,24 +81,6 @@ pub unsafe fn closure_exchange_malloc_(drop_glue: fn(*mut u8), size: uint, align } #[inline] -#[cfg(stage0)] -pub unsafe fn closure_exchange_malloc(td: *u8, size: uint) -> *u8 { - let td = td as *TyDesc; - let size = size; - - assert!(td.is_not_null()); - - let total_size = get_box_size(size, (*td).align); - let p = malloc_raw(total_size); - - let alloc = p as *mut raw::Box<()>; - (*alloc).type_desc = td; - - alloc as *u8 -} - -#[inline] -#[cfg(not(stage0))] pub unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { let total_size = get_box_size(size, align); let p = malloc_raw(total_size); diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 3bee9e48b60..023f712d3a0 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -21,8 +21,6 @@ use rt::env; use rt::global_heap; use rt::local::Local; use rt::task::Task; -#[cfg(stage0)] -use unstable::intrinsics::TyDesc; use unstable::raw; use vec::ImmutableVector; @@ -61,29 +59,6 @@ impl LocalHeap { } #[inline] - #[cfg(stage0)] - pub fn alloc(&mut self, td: *TyDesc, size: uint) -> *mut Box { - let total_size = global_heap::get_box_size(size, unsafe { (*td).align }); - let alloc = self.memory_region.malloc(total_size); - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { cast::transmute(alloc) }; - // Clear out this box, and move it to the front of the live - // allocations list - mybox.type_desc = td; - mybox.ref_count = 1; - mybox.prev = ptr::mut_null(); - mybox.next = self.live_allocs; - if !self.live_allocs.is_null() { - unsafe { (*self.live_allocs).prev = alloc; } - } - self.live_allocs = alloc; - } - return alloc; - } - - #[inline] - #[cfg(not(stage0))] pub fn alloc(&mut self, drop_glue: fn(*mut u8), size: uint, align: uint) -> *mut Box { let total_size = global_heap::get_box_size(size, align); let alloc = self.memory_region.malloc(total_size); @@ -126,41 +101,6 @@ impl LocalHeap { } #[inline] - #[cfg(stage0)] - pub fn free(&mut self, alloc: *mut Box) { - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { cast::transmute(alloc) }; - assert!(!mybox.type_desc.is_null()); - - // Unlink it from the linked list - if !mybox.prev.is_null() { - unsafe { (*mybox.prev).next = mybox.next; } - } - if !mybox.next.is_null() { - unsafe { (*mybox.next).prev = mybox.prev; } - } - if self.live_allocs == alloc { - self.live_allocs = mybox.next; - } - - // Destroy the box memory-wise - if self.poison_on_free { - unsafe { - let ptr: *mut u8 = cast::transmute(&mybox.data); - ptr::set_memory(ptr, 0xab, (*mybox.type_desc).size); - } - } - mybox.prev = ptr::mut_null(); - mybox.next = ptr::mut_null(); - mybox.type_desc = ptr::null(); - } - - self.memory_region.free(alloc); - } - - #[inline] - #[cfg(not(stage0))] pub fn free(&mut self, alloc: *mut Box) { { // Make sure that we can't use `mybox` outside of this scope @@ -339,20 +279,6 @@ impl Drop for MemoryRegion { } #[inline] -#[cfg(stage0)] -pub unsafe fn local_malloc(td: *u8, size: uint) -> *u8 { - // FIXME: Unsafe borrow for speed. Lame. - let task: Option<*mut Task> = Local::try_unsafe_borrow(); - match task { - Some(task) => { - (*task).heap.alloc(td as *TyDesc, size) as *u8 - } - None => rtabort!("local malloc outside of task") - } -} - -#[inline] -#[cfg(not(stage0))] pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { // FIXME: Unsafe borrow for speed. Lame. let task: Option<*mut Task> = Local::try_unsafe_borrow(); diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index b9e9c9d5a43..c983d82563c 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -160,10 +160,6 @@ pub trait TyVisitor { fn visit_trait(&mut self, name: &str) -> bool; fn visit_param(&mut self, i: uint) -> bool; fn visit_self(&mut self) -> bool; - - // NOTE Remove after next snapshot. - #[cfg(stage0)] - fn visit_type(&mut self) -> bool; } extern "rust-intrinsic" { diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs index a85f26720bf..4648f149a9f 100644 --- a/src/libstd/unstable/lang.rs +++ b/src/libstd/unstable/lang.rs @@ -27,14 +27,6 @@ pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! { } #[lang="malloc"] -#[cfg(stage0)] -#[inline] -pub unsafe fn local_malloc(td: *u8, size: uint) -> *u8 { - ::rt::local_heap::local_malloc(td, size) -} - -#[lang="malloc"] -#[cfg(not(stage0))] #[inline] pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { ::rt::local_heap::local_malloc(drop_glue, size, align) diff --git a/src/libstd/unstable/raw.rs b/src/libstd/unstable/raw.rs index 98dde95d3b7..87547997798 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/unstable/raw.rs @@ -9,21 +9,8 @@ // except according to those terms. use cast; -#[cfg(stage0)] -use unstable::intrinsics::TyDesc; /// The representation of a Rust managed box -#[cfg(stage0)] -pub struct Box<T> { - ref_count: uint, - type_desc: *TyDesc, - prev: *mut Box<T>, - next: *mut Box<T>, - data: T -} - -/// The representation of a Rust managed box -#[cfg(not(stage0))] pub struct Box<T> { ref_count: uint, drop_glue: fn(ptr: *mut u8), |
