Skip to content

Commit 1a75c26

Browse files
committed
---
yaml --- r: 139975 b: refs/heads/try2 c: 93c0888 h: refs/heads/master i: 139973: f4a3416 139971: 0f91b3c 139967: ba8009b v: v3
1 parent 24ac318 commit 1a75c26

File tree

6 files changed

+23
-103
lines changed

6 files changed

+23
-103
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2b09267b762398a3c851ecfd55d5d01aee906352
8+
refs/heads/try2: 93c0888b6c6111c645d5aa2ef78da6fe8ab2c307
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/iterator.rs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub trait IteratorUtil<A> {
3939
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, Self>;
4040
fn skip(self, n: uint) -> SkipIterator<Self>;
4141
fn take(self, n: uint) -> TakeIterator<Self>;
42-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
43-
-> ScanIterator<'r, A, B, Self, St>;
4442
fn advance(&mut self, f: &fn(A) -> bool);
4543
}
4644

@@ -95,12 +93,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
9593
TakeIterator{iter: self, n: n}
9694
}
9795

98-
#[inline(always)]
99-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
100-
-> ScanIterator<'r, A, B, T, St> {
101-
ScanIterator{iter: self, f: f, state: initial_state}
102-
}
103-
10496
/// A shim implementing the `for` loop iteration protocol for iterator objects
10597
#[inline]
10698
fn advance(&mut self, f: &fn(A) -> bool) {
@@ -314,13 +306,12 @@ impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
314306

315307
pub struct UnfoldrIterator<'self, A, St> {
316308
priv f: &'self fn(&mut St) -> Option<A>,
317-
state: St
309+
priv state: St
318310
}
319311

320312
pub impl<'self, A, St> UnfoldrIterator<'self, A, St> {
321313
#[inline]
322-
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St)
323-
-> UnfoldrIterator<'self, A, St> {
314+
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St) -> UnfoldrIterator<'self, A, St> {
324315
UnfoldrIterator {
325316
f: f,
326317
state: initial_state
@@ -335,19 +326,6 @@ impl<'self, A, St> Iterator<A> for UnfoldrIterator<'self, A, St> {
335326
}
336327
}
337328

338-
pub struct ScanIterator<'self, A, B, T, St> {
339-
priv iter: T,
340-
priv f: &'self fn(&mut St, A) -> Option<B>,
341-
state: St
342-
}
343-
344-
impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B, T, St> {
345-
#[inline]
346-
fn next(&mut self) -> Option<B> {
347-
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
348-
}
349-
}
350-
351329
#[cfg(test)]
352330
mod tests {
353331
use super::*;
@@ -428,25 +406,6 @@ mod tests {
428406
assert_eq!(i, ys.len());
429407
}
430408

431-
#[test]
432-
fn test_iterator_scan() {
433-
// test the type inference
434-
fn add(old: &mut int, new: &uint) -> Option<float> {
435-
*old += *new as int;
436-
Some(*old as float)
437-
}
438-
let xs = [0u, 1, 2, 3, 4];
439-
let ys = [0f, 1f, 3f, 6f, 10f];
440-
441-
let mut it = xs.iter().scan(0, add);
442-
let mut i = 0;
443-
for it.advance |x| {
444-
assert_eq!(x, ys[i]);
445-
i += 1;
446-
}
447-
assert_eq!(i, ys.len());
448-
}
449-
450409
#[test]
451410
fn test_unfoldr() {
452411
fn count(st: &mut uint) -> Option<uint> {

branches/try2/src/libcore/sys.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,12 @@ pub fn get_type_desc<T>() -> *TypeDesc {
8383
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
8484
}
8585

86-
/// Returns a pointer to a type descriptor.
87-
#[inline(always)]
88-
pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
89-
get_type_desc::<T>()
90-
}
91-
9286
/// Returns the size of a type
9387
#[inline(always)]
9488
pub fn size_of<T>() -> uint {
9589
unsafe { rusti::size_of::<T>() }
9690
}
9791

98-
/// Returns the size of the type that `_val` points to
99-
#[inline(always)]
100-
pub fn size_of_val<T>(_val: &T) -> uint {
101-
size_of::<T>()
102-
}
103-
10492
/**
10593
* Returns the size of a type, or 1 if the actual size is zero.
10694
*
@@ -112,13 +100,6 @@ pub fn nonzero_size_of<T>() -> uint {
112100
if s == 0 { 1 } else { s }
113101
}
114102

115-
/// Returns the size of the type of the value that `_val` points to
116-
#[inline(always)]
117-
pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
118-
nonzero_size_of::<T>()
119-
}
120-
121-
122103
/**
123104
* Returns the ABI-required minimum alignment of a type
124105
*
@@ -130,26 +111,12 @@ pub fn min_align_of<T>() -> uint {
130111
unsafe { rusti::min_align_of::<T>() }
131112
}
132113

133-
/// Returns the ABI-required minimum alignment of the type of the value that
134-
/// `_val` points to
135-
#[inline(always)]
136-
pub fn min_align_of_val<T>(_val: &T) -> uint {
137-
min_align_of::<T>()
138-
}
139-
140114
/// Returns the preferred alignment of a type
141115
#[inline(always)]
142116
pub fn pref_align_of<T>() -> uint {
143117
unsafe { rusti::pref_align_of::<T>() }
144118
}
145119

146-
/// Returns the preferred alignment of the type of the value that
147-
/// `_val` points to
148-
#[inline(always)]
149-
pub fn pref_align_of_val<T>(_val: &T) -> uint {
150-
pref_align_of::<T>()
151-
}
152-
153120
/// Returns the refcount of a shared box (as just before calling this)
154121
#[inline(always)]
155122
pub fn refcount<T>(t: @T) -> uint {
@@ -195,7 +162,7 @@ pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! {
195162
#[cfg(test)]
196163
mod tests {
197164
use cast;
198-
use sys::*;
165+
use sys::{Closure, pref_align_of, size_of, nonzero_size_of};
199166
200167
#[test]
201168
fn size_of_basic() {
@@ -221,14 +188,6 @@ mod tests {
221188
assert!(size_of::<*uint>() == 8u);
222189
}
223190

224-
#[test]
225-
fn size_of_val_basic() {
226-
assert_eq!(size_of_val(&1u8), 1);
227-
assert_eq!(size_of_val(&1u16), 2);
228-
assert_eq!(size_of_val(&1u32), 4);
229-
assert_eq!(size_of_val(&1u64), 8);
230-
}
231-
232191
#[test]
233192
fn nonzero_size_of_basic() {
234193
type Z = [i8, ..0];
@@ -237,14 +196,6 @@ mod tests {
237196
assert!(nonzero_size_of::<uint>() == size_of::<uint>());
238197
}
239198

240-
#[test]
241-
fn nonzero_size_of_val_basic() {
242-
let z = [0u8, ..0];
243-
assert_eq!(size_of_val(&z), 0u);
244-
assert_eq!(nonzero_size_of_val(&z), 1u);
245-
assert_eq!(nonzero_size_of_val(&1u), size_of_val(&1u));
246-
}
247-
248199
#[test]
249200
fn align_of_basic() {
250201
assert!(pref_align_of::<u8>() == 1u);
@@ -268,13 +219,6 @@ mod tests {
268219
assert!(pref_align_of::<*uint>() == 8u);
269220
}
270221

271-
#[test]
272-
fn align_of_val_basic() {
273-
assert_eq!(pref_align_of_val(&1u8), 1u);
274-
assert_eq!(pref_align_of_val(&1u16), 2u);
275-
assert_eq!(pref_align_of_val(&1u32), 4u);
276-
}
277-
278222
#[test]
279223
fn synthesize_closure() {
280224
unsafe {

branches/try2/src/libcore/unstable/intrinsics.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,28 @@ pub extern "rust-intrinsic" {
7070
pub fn powif32(a: f32, x: i32) -> f32;
7171
pub fn powif64(a: f64, x: i32) -> f64;
7272

73+
// the following kill the stack canary without
74+
// `fixed_stack_segment`. This possibly only affects the f64
75+
// variants, but it's hard to be sure since it seems to only
76+
// occur with fairly specific arguments.
77+
#[fixed_stack_segment]
7378
pub fn sinf32(x: f32) -> f32;
79+
#[fixed_stack_segment]
7480
pub fn sinf64(x: f64) -> f64;
7581

82+
#[fixed_stack_segment]
7683
pub fn cosf32(x: f32) -> f32;
84+
#[fixed_stack_segment]
7785
pub fn cosf64(x: f64) -> f64;
7886

87+
#[fixed_stack_segment]
7988
pub fn powf32(a: f32, x: f32) -> f32;
89+
#[fixed_stack_segment]
8090
pub fn powf64(a: f64, x: f64) -> f64;
8191

92+
#[fixed_stack_segment]
8293
pub fn expf32(x: f32) -> f32;
94+
#[fixed_stack_segment]
8395
pub fn expf64(x: f64) -> f64;
8496

8597
pub fn exp2f32(x: f32) -> f32;
@@ -128,4 +140,3 @@ pub extern "rust-intrinsic" {
128140
pub fn bswap32(x: i32) -> i32;
129141
pub fn bswap64(x: i64) -> i64;
130142
}
131-

branches/try2/src/librustc/middle/trans/foreign.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
546546
item: @ast::foreign_item,
547547
path: ast_map::path,
548548
substs: @param_substs,
549+
attributes: &[ast::attribute],
549550
ref_id: Option<ast::node_id>) {
550551
debug!("trans_intrinsic(item.ident=%s)", *ccx.sess.str_of(item.ident));
551552

@@ -561,6 +562,11 @@ pub fn trans_intrinsic(ccx: @CrateContext,
561562
Some(copy substs),
562563
Some(item.span));
563564

565+
// Set the fixed stack segment flag if necessary.
566+
if attr::attrs_contains_name(attributes, "fixed_stack_segment") {
567+
set_fixed_stack_segment(fcx.llfn);
568+
}
569+
564570
let mut bcx = top_scope_block(fcx, None), lltop = bcx.llbb;
565571
match *ccx.sess.str_of(item.ident) {
566572
~"atomic_cxchg" => {

branches/try2/src/librustc/middle/trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
212212
}
213213
ast_map::node_foreign_item(i, _, _, _) => {
214214
let d = mk_lldecl();
215-
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(),
215+
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(), i.attrs,
216216
ref_id);
217217
d
218218
}

0 commit comments

Comments
 (0)