From 8bf00333455a572bc4c48f947777ed2e7b57af09 Mon Sep 17 00:00:00 2001 From: Philipp Brüschweiler Date: Thu, 20 Jun 2013 14:45:10 +0200 Subject: Remove unused shape fields from typedescs --- src/rt/rust_builtin.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index e476fa0ad5e..1a84325c7a9 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -732,10 +732,9 @@ rust_task_deref(rust_task *task) { // Must call on rust stack. extern "C" CDECL void rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) { - void (*glue_fn)(void *, void *, void *) = - (void (*)(void *, void *, void *))tydesc[glue_index]; - if (glue_fn) - glue_fn(0, 0, root); + glue_fn *fn = (glue_fn*) tydesc[glue_index]; + if (fn) + fn(0, 0, root); } // Don't run on the Rust stack! -- cgit 1.4.1-3-g733a5 From 976c0b3dfb6a0da8a70958f157507b5dcf7c5ceb Mon Sep 17 00:00:00 2001 From: Philipp Brüschweiler Date: Fri, 21 Jun 2013 10:00:49 +0200 Subject: Remove rust_call_tydesc_glue Towards #4812. Also includes some minor cleanups. --- src/libextra/arena.rs | 32 ++++++++------------------------ src/libstd/cleanup.rs | 18 +++--------------- src/libstd/gc.rs | 15 +++++---------- src/libstd/sys.rs | 23 ----------------------- src/rt/rust_builtin.cpp | 8 -------- src/rt/rustrt.def.in | 3 +-- 6 files changed, 17 insertions(+), 82 deletions(-) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/libextra/arena.rs b/src/libextra/arena.rs index a7d5660cd2e..3766af04656 100644 --- a/src/libextra/arena.rs +++ b/src/libextra/arena.rs @@ -41,36 +41,20 @@ use list::{MutList, MutCons, MutNil}; 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() -> *TyDesc { + intrinsics::get_tydesc::() 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 diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index 28aab9adad2..557a2fbc4ae 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -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); } } diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index 611b95a7745..2a211484e73 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -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 { 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); } } } diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index 7f80375c2f6..a1d6342323c 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -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() -> *TypeDesc { - unsafe { intrinsics::get_tydesc::() as *TypeDesc } -} - /// Returns the size of a type #[inline] pub fn size_of() -> uint { diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 1a84325c7a9..8d771da32fc 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -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) { diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index ba7ada04a27..7fd948d2cd9 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -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 -- cgit 1.4.1-3-g733a5