Skip to content

Commit ff75b0f

Browse files
committed
---
yaml --- r: 102517 b: refs/heads/auto c: 5afc63a h: refs/heads/master i: 102515: 86224c0 v: v3
1 parent a014eeb commit ff75b0f

File tree

22 files changed

+228
-256
lines changed

22 files changed

+228
-256
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: df044ea4ac8fb7f99622948f4f8c40fbd24eda13
16+
refs/heads/auto: 5afc63a2aef113d49944b6ee5f7a743198a6aff1
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libarena/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use std::ptr;
3636
use std::kinds::marker;
3737
use std::mem;
3838
use std::rt::global_heap;
39+
use std::uint;
3940
use std::unstable::intrinsics::{TyDesc, get_tydesc};
4041
use std::unstable::intrinsics;
4142
use std::util;
@@ -179,7 +180,7 @@ impl Arena {
179180
let new_min_chunk_size = num::max(n_bytes, chunk_size);
180181
self.chunks.set(@Cons(self.pod_head.clone(), self.chunks.get()));
181182
self.pod_head =
182-
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
183+
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
183184

184185
return self.alloc_pod_inner(n_bytes, align);
185186
}
@@ -221,7 +222,7 @@ impl Arena {
221222
let new_min_chunk_size = num::max(n_bytes, chunk_size);
222223
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
223224
self.head =
224-
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
225+
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
225226

226227
return self.alloc_nonpod_inner(n_bytes, align);
227228
}

branches/auto/src/libextra/ringbuf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {
303303
&mut self.remaining2
304304
};
305305
self.nelts -= 1;
306-
Some(r.mut_shift_ref().unwrap().get_mut_ref())
306+
Some(r.mut_shift_ref().get_mut_ref())
307307
}
308308

309309
#[inline]
@@ -325,7 +325,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> {
325325
&mut self.remaining1
326326
};
327327
self.nelts -= 1;
328-
Some(r.mut_pop_ref().unwrap().get_mut_ref())
328+
Some(r.mut_pop_ref().get_mut_ref())
329329
}
330330
}
331331

branches/auto/src/librustc/metadata/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ pub static tag_items_data_item_variant: uint = 0x0eu;
3535

3636
pub static tag_items_data_parent_item: uint = 0x0fu;
3737

38-
pub static tag_items_data_item_is_tuple_struct_ctor: uint = 0x10u;
39-
4038
pub static tag_index: uint = 0x11u;
4139

4240
pub static tag_index_buckets: uint = 0x12u;

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -980,26 +980,9 @@ pub fn get_static_methods_if_impl(intr: @IdentInterner,
980980
return Some(static_impl_methods);
981981
}
982982

983-
/// If node_id is the constructor of a tuple struct, retrieve the NodeId of
984-
/// the actual type definition, otherwise, return None
985-
pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
986-
node_id: ast::NodeId) -> Option<ast::NodeId> {
987-
let item = lookup_item(node_id, cdata.data());
988-
let mut ret = None;
989-
reader::tagged_docs(item, tag_items_data_item_is_tuple_struct_ctor, |_| {
990-
ret = Some(item_reqd_and_translated_parent_item(cdata.cnum, item));
991-
false
992-
});
993-
ret.map(|x| x.node)
994-
}
995-
996983
pub fn get_item_attrs(cdata: Cmd,
997984
node_id: ast::NodeId,
998985
f: |~[@ast::MetaItem]|) {
999-
// The attributes for a tuple struct are attached to the definition, not the ctor;
1000-
// we assume that someone passing in a tuple struct ctor is actually wanting to
1001-
// look at the definition
1002-
let node_id = get_tuple_struct_definition_if_ctor(cdata, node_id).unwrap_or(node_id);
1003986
let item = lookup_item(node_id, cdata.data());
1004987
reader::tagged_docs(item, tag_attributes, |attributes| {
1005988
reader::tagged_docs(attributes, tag_attribute, |attribute| {

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,6 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
778778
encode_symbol(ecx, ebml_w, ctor_id);
779779
}
780780

781-
// indicate that this is a tuple struct ctor, because downstream users will normally want
782-
// the tuple struct definition, but without this there is no way for them to tell that
783-
// they actually have a ctor rather than a normal function
784-
ebml_w.start_tag(tag_items_data_item_is_tuple_struct_ctor);
785-
ebml_w.end_tag();
786-
787781
ebml_w.end_tag();
788782
}
789783

branches/auto/src/librustc/middle/trans/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> {
662662
// Check if a landing pad block exists; if not, create one.
663663
{
664664
let mut scopes = self.scopes.borrow_mut();
665-
let last_scope = scopes.get().mut_last().unwrap();
665+
let last_scope = scopes.get().mut_last();
666666
match last_scope.cached_landing_pad {
667667
Some(llbb) => { return llbb; }
668668
None => {

branches/auto/src/libstd/at_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ pub mod raw {
177177
use cast::{transmute, transmute_copy};
178178
use container::Container;
179179
use option::None;
180-
use mem;
181-
use num::next_power_of_two;
182180
use ptr;
181+
use mem;
182+
use uint;
183183
use unstable::intrinsics::{move_val_init, TyDesc};
184184
use unstable::intrinsics;
185185
use unstable::raw::{Box, Vec};
@@ -293,7 +293,7 @@ pub mod raw {
293293
*/
294294
#[inline]
295295
pub unsafe fn reserve_at_least<T>(v: &mut @[T], n: uint) {
296-
reserve(v, next_power_of_two(n));
296+
reserve(v, uint::next_power_of_two(n));
297297
}
298298
}
299299

branches/auto/src/libstd/hashmap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ use num;
6464
use option::{None, Option, Some};
6565
use rand::Rng;
6666
use rand;
67+
use uint;
6768
use util::replace;
6869
use vec::{ImmutableVector, MutableVector, OwnedVector, Items, MutItems};
6970
use vec_ng;
@@ -387,7 +388,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
387388
pub fn reserve_at_least(&mut self, n: uint) {
388389
if n > self.buckets.len() {
389390
let buckets = n * 4 / 3 + 1;
390-
self.resize(num::next_power_of_two(buckets));
391+
self.resize(uint::next_power_of_two(buckets));
391392
}
392393
}
393394

branches/auto/src/libstd/io/extensions.rs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,16 @@ impl<'r, R: Reader> Iterator<u8> for Bytes<'r, R> {
5151
}
5252

5353
pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
54+
use unstable::intrinsics::{to_le16, to_le32, to_le64};
55+
use cast::transmute;
56+
57+
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
5458
assert!(size <= 8u);
5559
match size {
5660
1u => f(&[n as u8]),
57-
2u => f(&[n as u8,
58-
(n >> 8) as u8]),
59-
4u => f(&[n as u8,
60-
(n >> 8) as u8,
61-
(n >> 16) as u8,
62-
(n >> 24) as u8]),
63-
8u => f(&[n as u8,
64-
(n >> 8) as u8,
65-
(n >> 16) as u8,
66-
(n >> 24) as u8,
67-
(n >> 32) as u8,
68-
(n >> 40) as u8,
69-
(n >> 48) as u8,
70-
(n >> 56) as u8]),
61+
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_le16(n as i16)) }),
62+
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_le32(n as i32)) }),
63+
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }),
7164
_ => {
7265

7366
let mut bytes: ~[u8] = ~[];
@@ -84,23 +77,16 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
8477
}
8578

8679
pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
80+
use unstable::intrinsics::{to_be16, to_be32, to_be64};
81+
use cast::transmute;
82+
83+
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
8784
assert!(size <= 8u);
8885
match size {
8986
1u => f(&[n as u8]),
90-
2u => f(&[(n >> 8) as u8,
91-
n as u8]),
92-
4u => f(&[(n >> 24) as u8,
93-
(n >> 16) as u8,
94-
(n >> 8) as u8,
95-
n as u8]),
96-
8u => f(&[(n >> 56) as u8,
97-
(n >> 48) as u8,
98-
(n >> 40) as u8,
99-
(n >> 32) as u8,
100-
(n >> 24) as u8,
101-
(n >> 16) as u8,
102-
(n >> 8) as u8,
103-
n as u8]),
87+
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_be16(n as i16)) }),
88+
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }),
89+
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }),
10490
_ => {
10591
let mut bytes: ~[u8] = ~[];
10692
let mut i = size;

branches/auto/src/libstd/num/int.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,10 @@ impl CheckedMul for int {
120120
}
121121
}
122122
}
123+
124+
#[test]
125+
fn test_overflows() {
126+
assert!((::int::MAX > 0));
127+
assert!((::int::MIN <= 0));
128+
assert!((::int::MIN + ::int::MAX + 1 == 0));
129+
}

branches/auto/src/libstd/num/int_macros.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,6 @@ mod tests {
445445
use num::CheckedDiv;
446446
use num::Bitwise;
447447

448-
#[test]
449-
fn test_overflows() {
450-
assert!(MAX > 0);
451-
assert!(MIN <= 0);
452-
assert_eq!(MIN + MAX + 1, 0);
453-
}
454-
455448
#[test]
456449
fn test_num() {
457450
num::test_num(10 as $T, 2 as $T);

branches/auto/src/libstd/num/mod.rs

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -440,39 +440,7 @@ pub trait Primitive: Clone
440440
/// A collection of traits relevant to primitive signed and unsigned integers
441441
pub trait Int: Integer
442442
+ Primitive
443-
+ Bitwise
444-
+ CheckedAdd
445-
+ CheckedSub
446-
// + CheckedMul // FIXME #8849: currently not impled on 32-bit
447-
+ CheckedDiv {}
448-
449-
/// Returns the smallest power of 2 greater than or equal to `n`.
450-
#[inline]
451-
pub fn next_power_of_two<T: Unsigned + Int>(n: T) -> T {
452-
let halfbits: T = cast(size_of::<T>() * 4).unwrap();
453-
let mut tmp: T = n - one();
454-
let mut shift: T = one();
455-
while shift <= halfbits {
456-
tmp = tmp | (tmp >> shift);
457-
shift = shift << one();
458-
}
459-
tmp + one()
460-
}
461-
462-
/// Returns the smallest power of 2 greater than or equal to `n`. If the next
463-
/// power of two is greater than the type's maximum value, `None` is returned,
464-
/// otherwise the power of 2 is wrapped in `Some`.
465-
#[inline]
466-
pub fn checked_next_power_of_two<T: Unsigned + Int>(n: T) -> Option<T> {
467-
let halfbits: T = cast(size_of::<T>() * 4).unwrap();
468-
let mut tmp: T = n - one();
469-
let mut shift: T = one();
470-
while shift <= halfbits {
471-
tmp = tmp | (tmp >> shift);
472-
shift = shift << one();
473-
}
474-
tmp.checked_add(&one())
475-
}
443+
+ Bitwise {}
476444

477445
/// Used for representing the classification of floating point numbers
478446
#[deriving(Eq)]
@@ -1621,48 +1589,6 @@ mod tests {
16211589
assert_eq!(third.checked_mul(&4), None);
16221590
}
16231591

1624-
macro_rules! test_next_power_of_two(
1625-
($test_name:ident, $T:ident) => (
1626-
fn $test_name() {
1627-
#[test];
1628-
assert_eq!(next_power_of_two::<$T>(0), 0);
1629-
let mut next_power = 1;
1630-
for i in range::<$T>(1, 40) {
1631-
assert_eq!(next_power_of_two(i), next_power);
1632-
if i == next_power { next_power *= 2 }
1633-
}
1634-
}
1635-
)
1636-
)
1637-
1638-
test_next_power_of_two!(test_next_power_of_two_u8, u8)
1639-
test_next_power_of_two!(test_next_power_of_two_u16, u16)
1640-
test_next_power_of_two!(test_next_power_of_two_u32, u32)
1641-
test_next_power_of_two!(test_next_power_of_two_u64, u64)
1642-
test_next_power_of_two!(test_next_power_of_two_uint, uint)
1643-
1644-
macro_rules! test_checked_next_power_of_two(
1645-
($test_name:ident, $T:ident) => (
1646-
fn $test_name() {
1647-
#[test];
1648-
assert_eq!(checked_next_power_of_two::<$T>(0), None);
1649-
let mut next_power = 1;
1650-
for i in range::<$T>(1, 40) {
1651-
assert_eq!(checked_next_power_of_two(i), Some(next_power));
1652-
if i == next_power { next_power *= 2 }
1653-
}
1654-
assert!(checked_next_power_of_two::<$T>($T::MAX / 2).is_some());
1655-
assert_eq!(checked_next_power_of_two::<$T>($T::MAX - 1), None);
1656-
assert_eq!(checked_next_power_of_two::<$T>($T::MAX), None);
1657-
}
1658-
)
1659-
)
1660-
1661-
test_checked_next_power_of_two!(test_checked_next_power_of_two_u8, u8)
1662-
test_checked_next_power_of_two!(test_checked_next_power_of_two_u16, u16)
1663-
test_checked_next_power_of_two!(test_checked_next_power_of_two_u32, u32)
1664-
test_checked_next_power_of_two!(test_checked_next_power_of_two_u64, u64)
1665-
test_checked_next_power_of_two!(test_checked_next_power_of_two_uint, uint)
16661592

16671593
#[deriving(Eq)]
16681594
struct Value { x: int }

0 commit comments

Comments
 (0)