Skip to content

Replace all uses of rust-intrinsic ABI with calls to unstable::intrinsic... #6372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@

use sys;
use unstable;

pub mod rusti {
#[abi = "rust-intrinsic"]
#[link_name = "rusti"]
pub extern "rust-intrinsic" {
fn forget<T>(x: T);

fn transmute<T,U>(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<T, U>(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::<U>() 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::<U>() as u64);
}
dest
}
Expand All @@ -45,7 +36,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
* reinterpret_cast on pointer types.
*/
#[inline(always)]
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }

/**
* Force-increment the reference count on a shared box. If used
Expand All @@ -65,7 +56,7 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
*/
#[inline(always)]
pub unsafe fn transmute<L, G>(thing: L) -> G {
rusti::transmute(thing)
intrinsics::transmute(thing)
}

/// Coerce an immutable reference to be mutable.
Expand Down
10 changes: 2 additions & 8 deletions src/libcore/stackwalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#[doc(hidden)]; // FIXME #3538

use cast::transmute;
use unstable::intrinsics;

pub type Word = uint;

Expand Down Expand Up @@ -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)
}
}
19 changes: 5 additions & 14 deletions src/libcore/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -38,16 +39,6 @@ pub struct Closure {
env: *(),
}

pub mod rusti {
#[abi = "rust-intrinsic"]
pub extern "rust-intrinsic" {
fn get_tydesc<T>() -> *();
fn size_of<T>() -> uint;
fn pref_align_of<T>() -> uint;
fn min_align_of<T>() -> uint;
}
}

pub mod rustrt {
use libc::{c_char, size_t};

Expand Down Expand Up @@ -81,7 +72,7 @@ pub fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
*/
#[inline(always)]
pub fn get_type_desc<T>() -> *TypeDesc {
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
}

/// Returns a pointer to a type descriptor.
Expand All @@ -93,7 +84,7 @@ pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
/// Returns the size of a type
#[inline(always)]
pub fn size_of<T>() -> uint {
unsafe { rusti::size_of::<T>() }
unsafe { intrinsics::size_of::<T>() }
}

/// Returns the size of the type that `_val` points to
Expand Down Expand Up @@ -128,7 +119,7 @@ pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
*/
#[inline(always)]
pub fn min_align_of<T>() -> uint {
unsafe { rusti::min_align_of::<T>() }
unsafe { intrinsics::min_align_of::<T>() }
}

/// Returns the ABI-required minimum alignment of the type of the value that
Expand All @@ -141,7 +132,7 @@ pub fn min_align_of_val<T>(_val: &T) -> uint {
/// Returns the preferred alignment of a type
#[inline(always)]
pub fn pref_align_of<T>() -> uint {
unsafe { rusti::pref_align_of::<T>() }
unsafe { intrinsics::pref_align_of::<T>() }
}

/// Returns the preferred alignment of the type of the value that
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ pub extern "rust-intrinsic" {
/// `forget` is unsafe because the caller is responsible for
/// ensuring the argument is deallocated already.
pub unsafe fn forget<T>(_: T) -> ();
pub fn transmute<T,U>(e: T) -> U;

/// Returns `true` if a type requires drop glue.
pub fn needs_drop<T>() -> bool;

// 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() -> *();
Expand Down
15 changes: 4 additions & 11 deletions src/libstd/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(dst: &mut T, src: T);
fn needs_drop<T>() -> bool;
}
}
use core::unstable::intrinsics;

pub mod rustrt {
use core::libc::size_t;
Expand Down Expand Up @@ -208,7 +201,7 @@ pub impl Arena {
let tydesc = sys::get_type_desc::<T>();
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);
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -276,7 +269,7 @@ pub impl Arena {
unsafe {
// XXX: Borrow check
let this = transmute_mut_region(self);
if !rusti::needs_drop::<T>() {
if !intrinsics::needs_drop::<T>() {
return this.alloc_pod(op);
}
// XXX: Borrow check
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
priv data: ~[T],
Expand Down