about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPhilipp Brüschweiler <blei42@gmail.com>2013-06-21 10:00:49 +0200
committerPhilipp Brüschweiler <blei42@gmail.com>2013-06-23 12:49:16 +0200
commit976c0b3dfb6a0da8a70958f157507b5dcf7c5ceb (patch)
treebb7afcd189fcab9ab60366b7cb885573dad7be17 /src/libstd
parent273f90566c26309c13ebe10278f8745e978250b2 (diff)
downloadrust-976c0b3dfb6a0da8a70958f157507b5dcf7c5ceb.tar.gz
rust-976c0b3dfb6a0da8a70958f157507b5dcf7c5ceb.zip
Remove rust_call_tydesc_glue
Towards #4812. Also includes some minor cleanups.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cleanup.rs18
-rw-r--r--src/libstd/gc.rs15
-rw-r--r--src/libstd/sys.rs23
3 files changed, 8 insertions, 48 deletions
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,18 +59,12 @@ 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;
 
         pub unsafe fn rust_get_stack_segment() -> *StackSegment;
@@ -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);
             }
         }
     }
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<T>() -> *TypeDesc {
-    unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
-}
-
 /// Returns the size of a type
 #[inline]
 pub fn size_of<T>() -> uint {