diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 4e71b62f10cd7..e3336e24a6e1a 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -12,26 +12,17 @@ use sys; use unstable; - -pub mod rusti { - #[abi = "rust-intrinsic"] - #[link_name = "rusti"] - pub extern "rust-intrinsic" { - fn forget(x: T); - - fn transmute(e: T) -> U; - } -} +use unstable::intrinsics; /// Casts the value at `src` to U. The two types must have the same length. pub unsafe fn transmute_copy(src: &T) -> U { - let mut dest: U = unstable::intrinsics::init(); + let mut dest: U = intrinsics::init(); { - let dest_ptr: *mut u8 = rusti::transmute(&mut dest); - let src_ptr: *u8 = rusti::transmute(src); - unstable::intrinsics::memmove64(dest_ptr, - src_ptr, - sys::size_of::() as u64); + let dest_ptr: *mut u8 = transmute(&mut dest); + let src_ptr: *u8 = transmute(src); + intrinsics::memmove64(dest_ptr, + src_ptr, + sys::size_of::() as u64); } dest } @@ -45,7 +36,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { * reinterpret_cast on pointer types. */ #[inline(always)] -pub unsafe fn forget(thing: T) { rusti::forget(thing); } +pub unsafe fn forget(thing: T) { intrinsics::forget(thing); } /** * Force-increment the reference count on a shared box. If used @@ -65,7 +56,7 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } */ #[inline(always)] pub unsafe fn transmute(thing: L) -> G { - rusti::transmute(thing) + intrinsics::transmute(thing) } /// Coerce an immutable reference to be mutable. diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index fbb6753723293..784656718d0d2 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -11,6 +11,7 @@ #[doc(hidden)]; // FIXME #3538 use cast::transmute; +use unstable::intrinsics; pub type Word = uint; @@ -75,13 +76,6 @@ fn test_simple_deep() { fn frame_address(f: &fn(x: *u8)) { unsafe { - rusti::frame_address(f) - } -} - -pub mod rusti { - #[abi = "rust-intrinsic"] - pub extern "rust-intrinsic" { - pub fn frame_address(f: &once fn(x: *u8)); + intrinsics::frame_address(f) } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index fc57cf40d1e01..962295e0b8a4b 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -19,6 +19,7 @@ use libc; use libc::{c_void, c_char, size_t}; use repr; use str; +use unstable::intrinsics; pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void); @@ -38,16 +39,6 @@ pub struct Closure { env: *(), } -pub mod rusti { - #[abi = "rust-intrinsic"] - pub extern "rust-intrinsic" { - fn get_tydesc() -> *(); - fn size_of() -> uint; - fn pref_align_of() -> uint; - fn min_align_of() -> uint; - } -} - pub mod rustrt { use libc::{c_char, size_t}; @@ -81,7 +72,7 @@ pub fn shape_le(x1: &T, x2: &T) -> bool { */ #[inline(always)] pub fn get_type_desc() -> *TypeDesc { - unsafe { rusti::get_tydesc::() as *TypeDesc } + unsafe { intrinsics::get_tydesc::() as *TypeDesc } } /// Returns a pointer to a type descriptor. @@ -93,7 +84,7 @@ pub fn get_type_desc_val(_val: &T) -> *TypeDesc { /// Returns the size of a type #[inline(always)] pub fn size_of() -> uint { - unsafe { rusti::size_of::() } + unsafe { intrinsics::size_of::() } } /// Returns the size of the type that `_val` points to @@ -128,7 +119,7 @@ pub fn nonzero_size_of_val(_val: &T) -> uint { */ #[inline(always)] pub fn min_align_of() -> uint { - unsafe { rusti::min_align_of::() } + unsafe { intrinsics::min_align_of::() } } /// Returns the ABI-required minimum alignment of the type of the value that @@ -141,7 +132,7 @@ pub fn min_align_of_val(_val: &T) -> uint { /// Returns the preferred alignment of a type #[inline(always)] pub fn pref_align_of() -> uint { - unsafe { rusti::pref_align_of::() } + unsafe { intrinsics::pref_align_of::() } } /// Returns the preferred alignment of the type of the value that diff --git a/src/libcore/unstable/intrinsics.rs b/src/libcore/unstable/intrinsics.rs index f332ecc63fc7e..d476822819eb9 100644 --- a/src/libcore/unstable/intrinsics.rs +++ b/src/libcore/unstable/intrinsics.rs @@ -114,6 +114,7 @@ pub extern "rust-intrinsic" { /// `forget` is unsafe because the caller is responsible for /// ensuring the argument is deallocated already. pub unsafe fn forget(_: T) -> (); + pub fn transmute(e: T) -> U; /// Returns `true` if a type requires drop glue. pub fn needs_drop() -> bool; @@ -121,8 +122,8 @@ pub extern "rust-intrinsic" { // XXX: intrinsic uses legacy modes and has reference to TyDesc // and TyVisitor which are in librustc //fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> (); - // XXX: intrinsic uses legacy modes - //fn frame_address(f: &once fn(*u8)); + + pub fn frame_address(f: &once fn(*u8)); /// Get the address of the `__morestack` stack growth function. pub fn morestack_addr() -> *(); diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index fd9fba8c1d753..a087a16caa245 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -43,14 +43,7 @@ use core::sys::TypeDesc; use core::sys; use core::uint; use core::vec; - -pub mod rusti { - #[abi = "rust-intrinsic"] - pub extern "rust-intrinsic" { - fn move_val_init(dst: &mut T, src: T); - fn needs_drop() -> bool; - } -} +use core::unstable::intrinsics; pub mod rustrt { use core::libc::size_t; @@ -208,7 +201,7 @@ pub impl Arena { let tydesc = sys::get_type_desc::(); let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); let ptr: *mut T = transmute(ptr); - rusti::move_val_init(&mut (*ptr), op()); + intrinsics::move_val_init(&mut (*ptr), op()); return transmute(ptr); } } @@ -261,7 +254,7 @@ pub impl Arena { // has *not* been initialized yet. *ty_ptr = transmute(tydesc); // Actually initialize it - rusti::move_val_init(&mut(*ptr), op()); + intrinsics::move_val_init(&mut(*ptr), op()); // Now that we are done, update the tydesc to indicate that // the object is there. *ty_ptr = bitpack_tydesc_ptr(tydesc, true); @@ -276,7 +269,7 @@ pub impl Arena { unsafe { // XXX: Borrow check let this = transmute_mut_region(self); - if !rusti::needs_drop::() { + if !intrinsics::needs_drop::() { return this.alloc_pod(op); } // XXX: Borrow check diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 2f5d12d08073b..f1e0027146c9e 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -11,8 +11,9 @@ //! A priority queue implemented with a binary heap use core::old_iter::BaseIter; +use core::unstable::intrinsics::{move_val_init, init}; +use core::unstable::intrinsics::uninit; use core::util::{replace, swap}; -use core::unstable::intrinsics::{init, move_val_init}; pub struct PriorityQueue { priv data: ~[T],