Remove rust_call_tydesc_glue

Towards #4812. Also includes some minor cleanups.
This commit is contained in:
Philipp Brüschweiler 2013-06-21 10:00:49 +02:00
parent 273f90566c
commit 976c0b3dfb
6 changed files with 17 additions and 82 deletions

View file

@ -158,20 +158,6 @@ fn debug_mem() -> bool {
false
}
#[cfg(stage0)]
unsafe fn call_drop_glue(tydesc: *::std::unstable::intrinsics::TyDesc, data: *i8) {
use sys::TypeDesc;
let tydesc: *TypeDesc = transmute(tydesc);
let drop_glue: extern "Rust" fn(**TypeDesc, *i8) = transmute((*tydesc).drop_glue);
drop_glue(to_unsafe_ptr(&tydesc), data);
}
#[cfg(not(stage0))]
unsafe fn call_drop_glue(tydesc: *::std::unstable::intrinsics::TyDesc, data: *i8) {
((*tydesc).drop_glue)(to_unsafe_ptr(&tydesc), data);
}
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
#[cfg(not(test))]
#[lang="annihilate"]
@ -213,7 +199,9 @@ pub unsafe fn annihilate() {
// callback, as the original value may have been freed.
for each_live_alloc(false) |box, uniq| {
if !uniq {
call_drop_glue((*box).header.type_desc, transmute(&(*box).data));
let tydesc = (*box).header.type_desc;
let data = transmute(&(*box).data);
((*tydesc).drop_glue)(to_unsafe_ptr(&tydesc), data);
}
}

View file

@ -40,12 +40,13 @@ with destructors.
use cast;
use container::{Map, Set};
use io;
use libc::{size_t, uintptr_t};
use libc::{uintptr_t};
use option::{None, Option, Some};
use ptr;
use hashmap::HashSet;
use stackwalk::walk_stack;
use sys;
use unstable::intrinsics::{TyDesc};
pub use stackwalk::Word;
@ -58,17 +59,11 @@ pub struct StackSegment {
}
pub mod rustrt {
use libc::size_t;
use stackwalk::Word;
use super::StackSegment;
#[link_name = "rustrt"]
pub extern {
#[rust_stack]
pub unsafe fn rust_call_tydesc_glue(root: *Word,
tydesc: *Word,
field: size_t);
#[rust_stack]
pub unsafe fn rust_gc_metadata() -> *Word;
@ -125,7 +120,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
return None;
}
type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
type Visitor<'self> = &'self fn(root: **Word, tydesc: *TyDesc) -> bool;
// Walks the list of roots for the given safe point, and calls visitor
// on each root.
@ -139,7 +134,7 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
let stack_roots: *u32 = bump(sp_meta, 2);
let reg_roots: *u8 = bump(stack_roots, num_stack_roots);
let addrspaces: *Word = align_to_pointer(bump(reg_roots, num_reg_roots));
let tydescs: ***Word = bump(addrspaces, num_stack_roots);
let tydescs: ***TyDesc = bump(addrspaces, num_stack_roots);
// Stack roots
let mut sri = 0;
@ -364,7 +359,7 @@ pub fn cleanup_stack_for_failure() {
// FIXME #4420: Destroy this box
// FIXME #4330: Destroy this box
} else {
rustrt::rust_call_tydesc_glue(*root, tydesc, 3 as size_t);
((*tydesc).drop_glue)(&tydesc as **TyDesc, *root as *i8);
}
}
}

View file

@ -22,17 +22,6 @@ use repr;
use str;
use unstable::intrinsics;
// Corresponds to runtime type_desc type
#[cfg(stage0)]
pub struct TypeDesc {
size: uint,
align: uint,
take_glue: uint,
drop_glue: uint,
free_glue: uint
// Remaining fields not listed
}
/// The representation of a Rust closure
pub struct Closure {
code: *(),
@ -50,18 +39,6 @@ pub mod rustrt {
}
}
/**
* Returns a pointer to a type descriptor.
*
* Useful for calling certain function in the Rust runtime or otherwise
* performing dark magick.
*/
#[inline]
#[cfg(stage0)]
pub fn get_type_desc<T>() -> *TypeDesc {
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
}
/// Returns the size of a type
#[inline]
pub fn size_of<T>() -> uint {