Skip to content

Commit 469f394

Browse files
committed
Remove intrinsic module
To achieve this, the following changes were made: * Move TyDesc, TyVisitor and Opaque to std::unstable::intrinsics * Convert TyDesc, TyVisitor and Opaque to lang items instead of specially handling the intrinsics module * Removed TypeDesc, FreeGlue and get_type_desc() from sys Fixes #3475.
1 parent f2c5642 commit 469f394

23 files changed

+298
-357
lines changed

src/libextra/arena.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,27 @@ use core::cast::{transmute, transmute_mut_region};
4343
use core::cast;
4444
use core::libc::size_t;
4545
use core::ptr;
46-
use core::sys::TypeDesc;
4746
use core::sys;
4847
use core::uint;
4948
use core::vec;
5049
use core::unstable::intrinsics;
5150

51+
#[cfg(stage0)]
52+
use intrinsic::{get_tydesc, TyDesc};
53+
#[cfg(not(stage0))]
54+
use core::unstable::intrinsics::{get_tydesc, TyDesc};
55+
5256
pub mod rustrt {
5357
use core::libc::size_t;
54-
use core::sys::TypeDesc;
58+
#[cfg(stage0)]
59+
use intrinsic::{TyDesc};
60+
#[cfg(not(stage0))]
61+
use core::unstable::intrinsics::{TyDesc};
5562

5663
pub extern {
5764
#[rust_stack]
5865
unsafe fn rust_call_tydesc_glue(root: *u8,
59-
tydesc: *TypeDesc,
66+
tydesc: *TyDesc,
6067
field: size_t);
6168
}
6269
}
@@ -136,7 +143,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
136143
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
137144
let (size, align) = ((*tydesc).size, (*tydesc).align);
138145

139-
let after_tydesc = idx + sys::size_of::<*TypeDesc>();
146+
let after_tydesc = idx + sys::size_of::<*TyDesc>();
140147

141148
let start = round_up_to(after_tydesc, align);
142149

@@ -148,7 +155,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
148155
}
149156

150157
// Find where the next tydesc lives
151-
idx = round_up_to(start + size, sys::pref_align_of::<*TypeDesc>());
158+
idx = round_up_to(start + size, sys::pref_align_of::<*TyDesc>());
152159
}
153160
}
154161

@@ -157,12 +164,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
157164
// is necessary in order to properly do cleanup if a failure occurs
158165
// during an initializer.
159166
#[inline]
160-
unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint {
167+
unsafe fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint {
161168
let p_bits: uint = transmute(p);
162169
p_bits | (is_done as uint)
163170
}
164171
#[inline]
165-
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
172+
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
166173
(transmute(p & !1), p & 1 == 1)
167174
}
168175

@@ -202,7 +209,7 @@ impl Arena {
202209
#[inline]
203210
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
204211
unsafe {
205-
let tydesc = sys::get_type_desc::<T>();
212+
let tydesc = get_tydesc::<T>();
206213
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
207214
let ptr: *mut T = transmute(ptr);
208215
intrinsics::move_val_init(&mut (*ptr), op());
@@ -230,13 +237,13 @@ impl Arena {
230237
let head = transmute_mut_region(&mut self.head);
231238

232239
let tydesc_start = head.fill;
233-
let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
240+
let after_tydesc = head.fill + sys::size_of::<*TyDesc>();
234241
let start = round_up_to(after_tydesc, align);
235242
let end = start + n_bytes;
236243
if end > at_vec::capacity(head.data) {
237244
return self.alloc_nonpod_grow(n_bytes, align);
238245
}
239-
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
246+
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
240247

241248
//debug!("idx = %u, size = %u, align = %u, fill = %u",
242249
// start, n_bytes, align, head.fill);
@@ -249,7 +256,7 @@ impl Arena {
249256
#[inline]
250257
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
251258
unsafe {
252-
let tydesc = sys::get_type_desc::<T>();
259+
let tydesc = get_tydesc::<T>();
253260
let (ty_ptr, ptr) =
254261
self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align);
255262
let ty_ptr: *mut uint = transmute(ty_ptr);

src/libextra/dbg.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,62 @@
1313
#[allow(missing_doc)];
1414

1515
use core::cast::transmute;
16-
use core::sys;
16+
#[cfg(stage0)]
17+
use intrinsic::{get_tydesc};
18+
#[cfg(not(stage0))]
19+
use core::unstable::intrinsics::{get_tydesc};
1720

1821
pub mod rustrt {
19-
use core::sys;
22+
#[cfg(stage0)]
23+
use intrinsic::{TyDesc};
24+
#[cfg(not(stage0))]
25+
use core::unstable::intrinsics::{TyDesc};
2026

2127
#[abi = "cdecl"]
2228
pub extern {
23-
pub unsafe fn debug_tydesc(td: *sys::TypeDesc);
24-
pub unsafe fn debug_opaque(td: *sys::TypeDesc, x: *());
25-
pub unsafe fn debug_box(td: *sys::TypeDesc, x: *());
26-
pub unsafe fn debug_tag(td: *sys::TypeDesc, x: *());
27-
pub unsafe fn debug_fn(td: *sys::TypeDesc, x: *());
28-
pub unsafe fn debug_ptrcast(td: *sys::TypeDesc, x: *()) -> *();
29+
pub unsafe fn debug_tydesc(td: *TyDesc);
30+
pub unsafe fn debug_opaque(td: *TyDesc, x: *());
31+
pub unsafe fn debug_box(td: *TyDesc, x: *());
32+
pub unsafe fn debug_tag(td: *TyDesc, x: *());
33+
pub unsafe fn debug_fn(td: *TyDesc, x: *());
34+
pub unsafe fn debug_ptrcast(td: *TyDesc, x: *()) -> *();
2935
pub unsafe fn rust_dbg_breakpoint();
3036
}
3137
}
3238

3339
pub fn debug_tydesc<T>() {
3440
unsafe {
35-
rustrt::debug_tydesc(sys::get_type_desc::<T>());
41+
rustrt::debug_tydesc(get_tydesc::<T>());
3642
}
3743
}
3844

3945
pub fn debug_opaque<T>(x: T) {
4046
unsafe {
41-
rustrt::debug_opaque(sys::get_type_desc::<T>(), transmute(&x));
47+
rustrt::debug_opaque(get_tydesc::<T>(), transmute(&x));
4248
}
4349
}
4450

4551
pub fn debug_box<T>(x: @T) {
4652
unsafe {
47-
rustrt::debug_box(sys::get_type_desc::<T>(), transmute(&x));
53+
rustrt::debug_box(get_tydesc::<T>(), transmute(&x));
4854
}
4955
}
5056

5157
pub fn debug_tag<T>(x: T) {
5258
unsafe {
53-
rustrt::debug_tag(sys::get_type_desc::<T>(), transmute(&x));
59+
rustrt::debug_tag(get_tydesc::<T>(), transmute(&x));
5460
}
5561
}
5662

5763
pub fn debug_fn<T>(x: T) {
5864
unsafe {
59-
rustrt::debug_fn(sys::get_type_desc::<T>(), transmute(&x));
65+
rustrt::debug_fn(get_tydesc::<T>(), transmute(&x));
6066
}
6167
}
6268

6369
pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {
6470
transmute(
65-
rustrt::debug_ptrcast(sys::get_type_desc::<T>(), transmute(x)))
71+
rustrt::debug_ptrcast(get_tydesc::<T>(), transmute(x)))
6672
}
6773

6874
/// Triggers a debugger breakpoint

src/librustc/driver/driver.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ pub fn compile_rest(sess: Session,
206206
let mut crate = crate_opt.unwrap();
207207

208208
let (llcx, llmod, link_meta) = {
209-
crate = time(time_passes, ~"intrinsic injection", ||
210-
front::intrinsic_inject::inject_intrinsic(sess, crate));
211-
212209
crate = time(time_passes, ~"extra injection", ||
213210
front::std_inject::maybe_inject_libstd_ref(sess, crate));
214211

src/librustc/front/intrinsic.rs

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/librustc/front/intrinsic_inject.rs

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)