提交 976c0b3d 编写于 作者: P Philipp Brüschweiler

Remove rust_call_tydesc_glue

Towards #4812. Also includes some minor cleanups.
上级 273f9056
......@@ -41,36 +41,20 @@
use core::at_vec;
use core::cast::{transmute, transmute_mut_region};
use core::cast;
use core::libc::size_t;
use core::ptr;
use core::sys;
use core::uint;
use core::vec;
use core::unstable::intrinsics;
use core::unstable::intrinsics::{TyDesc};
#[cfg(stage0)]
use intrinsic::{get_tydesc, TyDesc};
#[cfg(not(stage0))]
use core::unstable::intrinsics::{get_tydesc, TyDesc};
pub mod rustrt {
use core::libc::size_t;
#[cfg(stage0)]
use intrinsic::{TyDesc};
#[cfg(not(stage0))]
use core::unstable::intrinsics::{TyDesc};
pub extern {
#[rust_stack]
unsafe fn rust_call_tydesc_glue(root: *u8,
tydesc: *TyDesc,
field: size_t);
}
}
use core::unstable::intrinsics::{get_tydesc};
// This probably belongs somewhere else. Needs to be kept in sync with
// changes to glue...
static tydesc_drop_glue_index: size_t = 3 as size_t;
#[cfg(stage0)]
unsafe fn get_tydesc<T>() -> *TyDesc {
intrinsics::get_tydesc::<T>() as *TyDesc
}
// The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array
......@@ -150,8 +134,8 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
// start, size, align, is_done);
if is_done {
rustrt::rust_call_tydesc_glue(
ptr::offset(buf, start), tydesc, tydesc_drop_glue_index);
((*tydesc).drop_glue)(&tydesc as **TyDesc,
ptr::offset(buf, start) as *i8);
}
// Find where the next tydesc lives
......
......@@ -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);
}
}
......
......@@ -40,12 +40,13 @@
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);
}
}
}
......
......@@ -22,17 +22,6 @@
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 @@ unsafe fn rust_upcall_fail(expr: *c_char,
}
}
/**
* 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 {
......
......@@ -729,14 +729,6 @@ rust_task_deref(rust_task *task) {
task->deref();
}
// Must call on rust stack.
extern "C" CDECL void
rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) {
glue_fn *fn = (glue_fn*) tydesc[glue_index];
if (fn)
fn(0, 0, root);
}
// Don't run on the Rust stack!
extern "C" void
rust_log_str(uint32_t level, const char *str, size_t size) {
......
......@@ -174,7 +174,6 @@ rust_set_task_local_data
rust_task_local_data_atexit
rust_task_ref
rust_task_deref
rust_call_tydesc_glue
tdefl_compress_mem_to_heap
tinfl_decompress_mem_to_heap
rust_gc_metadata
......@@ -239,4 +238,4 @@ rust_valgrind_stack_deregister
rust_take_env_lock
rust_drop_env_lock
rust_update_log_settings
rust_running_on_valgrind
\ No newline at end of file
rust_running_on_valgrind
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册