Skip to content

Commit a9b9d2c

Browse files
committed
---
yaml --- r: 275150 b: refs/heads/stable c: a70ae2f h: refs/heads/master
1 parent f64837a commit a9b9d2c

File tree

18 files changed

+168
-332
lines changed

18 files changed

+168
-332
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 43ddfbdfb2cfc63646db395751f108617f0e39b4
32+
refs/heads/stable: a70ae2ffb9a5dd08d916b9938eeca820486ba7a0
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/mk/cfg/armv7-unknown-linux-gnueabihf.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ CFG_UNIXY_armv7-unknown-linux-gnueabihf := 1
2121
CFG_LDPATH_armv7-unknown-linux-gnueabihf :=
2222
CFG_RUN_armv7-unknown-linux-gnueabihf=$(2)
2323
CFG_RUN_TARG_armv7-unknown-linux-gnueabihf=$(call CFG_RUN_armv7-unknown-linux-gnueabihf,,$(2))
24-
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf :=
24+
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf := -C target-feature=+v7,+vfp2,+neon
2525
RUSTC_CROSS_FLAGS_armv7-unknown-linux-gnueabihf :=
2626
CFG_GNU_TRIPLE_armv7-unknown-linux-gnueabihf := armv7-unknown-linux-gnueabihf

branches/stable/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn target() -> Target {
2222
target_vendor: "unknown".to_string(),
2323

2424
options: TargetOptions {
25-
features: "+v7,+vfp3,+neon".to_string(),
25+
features: "+v7,+vfp2,+neon".to_string(),
2626
cpu: "cortex-a8".to_string(),
2727
.. base
2828
}

branches/stable/src/librustc_data_structures/bitvec.rs

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,6 @@ impl BitVector {
5050
let extra_words = self.data.len() - num_words;
5151
self.data.extend((0..extra_words).map(|_| 0));
5252
}
53-
54-
/// Iterates over indexes of set bits in a sorted order
55-
pub fn iter<'a>(&'a self) -> BitVectorIter<'a> {
56-
BitVectorIter {
57-
iter: self.data.iter(),
58-
current: 0,
59-
idx: 0
60-
}
61-
}
62-
}
63-
64-
pub struct BitVectorIter<'a> {
65-
iter: ::std::slice::Iter<'a, u64>,
66-
current: u64,
67-
idx: usize
68-
}
69-
70-
impl<'a> Iterator for BitVectorIter<'a> {
71-
type Item = usize;
72-
fn next(&mut self) -> Option<usize> {
73-
while self.current == 0 {
74-
self.current = if let Some(&i) = self.iter.next() {
75-
if i == 0 {
76-
self.idx += 64;
77-
continue;
78-
} else {
79-
self.idx = u64s(self.idx) * 64;
80-
i
81-
}
82-
} else {
83-
return None;
84-
}
85-
}
86-
let offset = self.current.trailing_zeros() as usize;
87-
self.current >>= offset;
88-
self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
89-
self.idx += offset + 1;
90-
return Some(self.idx - 1);
91-
}
9253
}
9354

9455
/// A "bit matrix" is basically a square matrix of booleans
@@ -192,46 +153,6 @@ fn word_mask(index: usize) -> (usize, u64) {
192153
(word, mask)
193154
}
194155

195-
#[test]
196-
fn bitvec_iter_works() {
197-
let mut bitvec = BitVector::new(100);
198-
bitvec.insert(1);
199-
bitvec.insert(10);
200-
bitvec.insert(19);
201-
bitvec.insert(62);
202-
bitvec.insert(63);
203-
bitvec.insert(64);
204-
bitvec.insert(65);
205-
bitvec.insert(66);
206-
bitvec.insert(99);
207-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 63, 64, 65, 66, 99]);
208-
}
209-
210-
#[test]
211-
fn bitvec_iter_works_2() {
212-
let mut bitvec = BitVector::new(300);
213-
bitvec.insert(1);
214-
bitvec.insert(10);
215-
bitvec.insert(19);
216-
bitvec.insert(62);
217-
bitvec.insert(66);
218-
bitvec.insert(99);
219-
bitvec.insert(299);
220-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 66, 99, 299]);
221-
222-
}
223-
224-
#[test]
225-
fn bitvec_iter_works_3() {
226-
let mut bitvec = BitVector::new(319);
227-
bitvec.insert(0);
228-
bitvec.insert(127);
229-
bitvec.insert(191);
230-
bitvec.insert(255);
231-
bitvec.insert(319);
232-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [0, 127, 191, 255, 319]);
233-
}
234-
235156
#[test]
236157
fn union_two_vecs() {
237158
let mut vec1 = BitVector::new(65);

branches/stable/src/librustc_mir/transform/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ pub mod simplify_cfg;
1313
pub mod erase_regions;
1414
pub mod no_landing_pads;
1515
pub mod type_check;
16+
mod util;

branches/stable/src/librustc_mir/transform/simplify_cfg.rs

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc_data_structures::bitvec::BitVector;
1211
use rustc::middle::const_eval::ConstVal;
1312
use rustc::middle::infer;
1413
use rustc::mir::repr::*;
14+
use transform::util;
1515
use rustc::mir::transform::MirPass;
1616

1717
pub struct SimplifyCfg;
@@ -22,21 +22,23 @@ impl SimplifyCfg {
2222
}
2323

2424
fn remove_dead_blocks(&self, mir: &mut Mir) {
25-
let mut seen = BitVector::new(mir.basic_blocks.len());
25+
let mut seen = vec![false; mir.basic_blocks.len()];
26+
2627
// These blocks are always required.
27-
seen.insert(START_BLOCK.index());
28-
seen.insert(END_BLOCK.index());
28+
seen[START_BLOCK.index()] = true;
29+
seen[END_BLOCK.index()] = true;
2930

30-
let mut worklist = Vec::with_capacity(4);
31-
worklist.push(START_BLOCK);
31+
let mut worklist = vec![START_BLOCK];
3232
while let Some(bb) = worklist.pop() {
3333
for succ in mir.basic_block_data(bb).terminator().successors().iter() {
34-
if seen.insert(succ.index()) {
34+
if !seen[succ.index()] {
35+
seen[succ.index()] = true;
3536
worklist.push(*succ);
3637
}
3738
}
3839
}
39-
retain_basic_blocks(mir, &seen);
40+
41+
util::retain_basic_blocks(mir, &seen);
4042
}
4143

4244
fn remove_goto_chains(&self, mir: &mut Mir) -> bool {
@@ -88,12 +90,12 @@ impl SimplifyCfg {
8890
for bb in mir.all_basic_blocks() {
8991
let basic_block = mir.basic_block_data_mut(bb);
9092
let mut terminator = basic_block.terminator_mut();
93+
9194
*terminator = match *terminator {
9295
Terminator::If { ref targets, .. } if targets.0 == targets.1 => {
9396
changed = true;
9497
Terminator::Goto { target: targets.0 }
9598
}
96-
9799
Terminator::If { ref targets, cond: Operand::Constant(Constant {
98100
literal: Literal::Value {
99101
value: ConstVal::Bool(cond)
@@ -106,7 +108,6 @@ impl SimplifyCfg {
106108
Terminator::Goto { target: targets.1 }
107109
}
108110
}
109-
110111
Terminator::SwitchInt { ref targets, .. } if targets.len() == 1 => {
111112
Terminator::Goto { target: targets[0] }
112113
}
@@ -130,27 +131,3 @@ impl MirPass for SimplifyCfg {
130131
mir.basic_blocks.shrink_to_fit();
131132
}
132133
}
133-
134-
/// Mass removal of basic blocks to keep the ID-remapping cheap.
135-
fn retain_basic_blocks(mir: &mut Mir, keep: &BitVector) {
136-
let num_blocks = mir.basic_blocks.len();
137-
138-
let mut replacements: Vec<_> = (0..num_blocks).map(BasicBlock::new).collect();
139-
let mut used_blocks = 0;
140-
for alive_index in keep.iter() {
141-
replacements[alive_index] = BasicBlock::new(used_blocks);
142-
if alive_index != used_blocks {
143-
// Swap the next alive block data with the current available slot. Since alive_index is
144-
// non-decreasing this is a valid operation.
145-
mir.basic_blocks.swap(alive_index, used_blocks);
146-
}
147-
used_blocks += 1;
148-
}
149-
mir.basic_blocks.truncate(used_blocks);
150-
151-
for bb in mir.all_basic_blocks() {
152-
for target in mir.basic_block_data_mut(bb).terminator_mut().successors_mut() {
153-
*target = replacements[target.index()];
154-
}
155-
}
156-
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use rustc::mir::repr::*;
12+
13+
/// Update basic block ids in all terminators using the given replacements,
14+
/// useful e.g. after removal of several basic blocks to update all terminators
15+
/// in a single pass
16+
pub fn update_basic_block_ids(mir: &mut Mir, replacements: &[BasicBlock]) {
17+
for bb in mir.all_basic_blocks() {
18+
for target in mir.basic_block_data_mut(bb).terminator_mut().successors_mut() {
19+
*target = replacements[target.index()];
20+
}
21+
}
22+
}
23+
24+
/// Mass removal of basic blocks to keep the ID-remapping cheap.
25+
pub fn retain_basic_blocks(mir: &mut Mir, keep: &[bool]) {
26+
let num_blocks = mir.basic_blocks.len();
27+
28+
// Check that we have a usage flag for every block
29+
assert_eq!(num_blocks, keep.len());
30+
31+
let first_dead = match keep.iter().position(|&k| !k) {
32+
None => return,
33+
Some(first_dead) => first_dead,
34+
};
35+
36+
// `replacements` maps the old block ids to the new ones
37+
let mut replacements: Vec<_> = (0..num_blocks).map(BasicBlock::new).collect();
38+
39+
let mut dead = 0;
40+
for i in first_dead..num_blocks {
41+
if keep[i] {
42+
replacements[i] = BasicBlock::new(i - dead);
43+
mir.basic_blocks.swap(i, i - dead);
44+
} else {
45+
dead += 1;
46+
}
47+
}
48+
mir.basic_blocks.truncate(num_blocks - dead);
49+
50+
update_basic_block_ids(mir, &replacements);
51+
}

branches/stable/src/libstd/ffi/c_str.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,57 @@ impl CStr {
436436
mem::transmute(slice::from_raw_parts(ptr, len as usize + 1))
437437
}
438438

439+
/// Creates a C string wrapper from a byte slice.
440+
///
441+
/// This function will cast the provided `bytes` to a `CStr` wrapper after
442+
/// ensuring that it is null terminated but does not contain any interior
443+
/// nul bytes.
444+
///
445+
/// # Examples
446+
///
447+
/// ```
448+
/// # #![feature(cstr_from_bytes)]
449+
/// use std::ffi::CStr;
450+
///
451+
/// # fn main() {
452+
/// let cstr = CStr::from_bytes(b"hello\0");
453+
/// assert!(cstr.is_some());
454+
/// # }
455+
/// ```
456+
#[unstable(feature = "cstr_from_bytes", reason = "recently added", issue = "0")]
457+
pub fn from_bytes<'a>(bytes: &'a [u8]) -> Option<&'a CStr> {
458+
if bytes.is_empty() || memchr::memchr(0, &bytes) != Some(bytes.len() - 1) {
459+
None
460+
} else {
461+
Some(unsafe { Self::from_bytes_unchecked(bytes) })
462+
}
463+
}
464+
465+
/// Unsafely creates a C string wrapper from a byte slice.
466+
///
467+
/// This function will cast the provided `bytes` to a `CStr` wrapper without
468+
/// performing any sanity checks. The provided slice must be null terminated
469+
/// and not contain any interior nul bytes.
470+
///
471+
/// # Examples
472+
///
473+
/// ```
474+
/// # #![feature(cstr_from_bytes)]
475+
/// use std::ffi::{CStr, CString};
476+
///
477+
/// # fn main() {
478+
/// unsafe {
479+
/// let cstring = CString::new("hello").unwrap();
480+
/// let cstr = CStr::from_bytes_unchecked(cstring.to_bytes_with_nul());
481+
/// assert_eq!(cstr, &*cstring);
482+
/// }
483+
/// # }
484+
/// ```
485+
#[unstable(feature = "cstr_from_bytes", reason = "recently added", issue = "0")]
486+
pub unsafe fn from_bytes_unchecked<'a>(bytes: &'a [u8]) -> &'a CStr {
487+
mem::transmute(bytes)
488+
}
489+
439490
/// Returns the inner pointer to this C string.
440491
///
441492
/// The returned pointer will be valid for as long as `self` is and points

branches/stable/src/libstd/ffi/os_str.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -411,44 +411,6 @@ impl Ord for OsStr {
411411
fn cmp(&self, other: &OsStr) -> cmp::Ordering { self.bytes().cmp(other.bytes()) }
412412
}
413413

414-
macro_rules! impl_cmp {
415-
($lhs:ty, $rhs: ty) => {
416-
#[stable(feature = "cmp_os_str", since = "1.8.0")]
417-
impl<'a, 'b> PartialEq<$rhs> for $lhs {
418-
#[inline]
419-
fn eq(&self, other: &$rhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
420-
}
421-
422-
#[stable(feature = "cmp_os_str", since = "1.8.0")]
423-
impl<'a, 'b> PartialEq<$lhs> for $rhs {
424-
#[inline]
425-
fn eq(&self, other: &$lhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
426-
}
427-
428-
#[stable(feature = "cmp_os_str", since = "1.8.0")]
429-
impl<'a, 'b> PartialOrd<$rhs> for $lhs {
430-
#[inline]
431-
fn partial_cmp(&self, other: &$rhs) -> Option<cmp::Ordering> {
432-
<OsStr as PartialOrd>::partial_cmp(self, other)
433-
}
434-
}
435-
436-
#[stable(feature = "cmp_os_str", since = "1.8.0")]
437-
impl<'a, 'b> PartialOrd<$lhs> for $rhs {
438-
#[inline]
439-
fn partial_cmp(&self, other: &$lhs) -> Option<cmp::Ordering> {
440-
<OsStr as PartialOrd>::partial_cmp(self, other)
441-
}
442-
}
443-
}
444-
}
445-
446-
impl_cmp!(OsString, OsStr);
447-
impl_cmp!(OsString, &'a OsStr);
448-
impl_cmp!(Cow<'a, OsStr>, OsStr);
449-
impl_cmp!(Cow<'a, OsStr>, &'b OsStr);
450-
impl_cmp!(Cow<'a, OsStr>, OsString);
451-
452414
#[stable(feature = "rust1", since = "1.0.0")]
453415
impl Hash for OsStr {
454416
#[inline]

0 commit comments

Comments
 (0)