Skip to content

Commit b2267f6

Browse files
---
yaml --- r: 144040 b: refs/heads/try2 c: 1dec27b h: refs/heads/master v: v3
1 parent 2c27805 commit b2267f6

File tree

439 files changed

+1372
-2172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

439 files changed

+1372
-2172
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: cb8a231eb8b730128c5b7e89c8eac9eab36642c4
8+
refs/heads/try2: 1dec27bed5b8aa609e091efdeedbd887cbc38fca
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/rt.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ RUNTIME_CXXS_$(1)_$(2) := \
6868
rt/sync/rust_thread.cpp \
6969
rt/rust_builtin.cpp \
7070
rt/rust_run_program.cpp \
71+
rt/rust_env.cpp \
7172
rt/rust_rng.cpp \
73+
rt/rust_stack.cpp \
7274
rt/rust_upcall.cpp \
7375
rt/rust_uv.cpp \
7476
rt/rust_crate_map.cpp \

branches/try2/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
6969
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7070
@$$(call E, compile_and_link: $$@)
7171
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
72-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
72+
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
7373
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
7474

7575
# Only build the compiler for host triples
@@ -90,7 +90,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
9090
| $$(TLIB$(1)_T_$(2)_H_$(3))/
9191
@$$(call E, compile_and_link: $$@)
9292
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
93-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
93+
$$(STAGE$(1)_T_$(2)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
9494
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
9595

9696
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \

branches/try2/mk/tools.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTDOC_$(4)): \
6767
| $$(TLIB$(1)_T_$(4)_H_$(3))/
6868
@$$(call E, compile_and_link: $$@)
6969
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
70-
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
70+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
7171
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
7272

7373
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X_$(4)): \
@@ -85,7 +85,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)): \
8585
| $$(TLIB$(1)_T_$(4)_H_$(3))/
8686
@$$(call E, compile_and_link: $$@)
8787
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
88-
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
88+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
8989
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
9090

9191
$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X_$(4)): \
@@ -106,7 +106,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUST_$(4)): \
106106
| $$(TLIB$(1)_T_$(4)_H_$(3))/
107107
@$$(call E, compile_and_link: $$@)
108108
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
109-
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
109+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
110110
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
111111

112112
$$(TBIN$(1)_T_$(4)_H_$(3))/rust$$(X_$(4)): \

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,16 @@ use procsrv;
2020
use util;
2121
use util::logv;
2222

23-
use std::cell::Cell;
2423
use std::io;
2524
use std::os;
2625
use std::str;
27-
use std::task::{spawn_sched, SingleThreaded};
2826
use std::vec;
2927

3028
use extra::test::MetricMap;
3129

3230
pub fn run(config: config, testfile: ~str) {
33-
let config = Cell::new(config);
34-
let testfile = Cell::new(testfile);
35-
// FIXME #6436: Creating another thread to run the test because this
36-
// is going to call waitpid. The new scheduler has some strange
37-
// interaction between the blocking tasks and 'friend' schedulers
38-
// that destroys parallelism if we let normal schedulers block.
39-
// It should be possible to remove this spawn once std::run is
40-
// rewritten to be non-blocking.
41-
do spawn_sched(SingleThreaded) {
42-
let config = config.take();
43-
let testfile = testfile.take();
44-
let mut _mm = MetricMap::new();
45-
run_metrics(config, testfile, &mut _mm);
46-
}
31+
let mut _mm = MetricMap::new();
32+
run_metrics(config, testfile, &mut _mm);
4733
}
4834

4935
pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {

branches/try2/src/libextra/crypto/cryptoutil.rs

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

11-
use std::num::{One, Zero, CheckedAdd};
11+
use std::num::One;
1212
use std::vec::bytes::{MutableByteVector, copy_memory};
1313

1414

@@ -36,18 +36,6 @@ pub fn write_u32_be(dst: &mut[u8], input: u32) {
3636
}
3737
}
3838

39-
/// Write a u32 into a vector, which must be 4 bytes long. The value is written in little-endian
40-
/// format.
41-
pub fn write_u32_le(dst: &mut[u8], input: u32) {
42-
use std::cast::transmute;
43-
use std::unstable::intrinsics::to_le32;
44-
assert!(dst.len() == 4);
45-
unsafe {
46-
let x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
47-
*x = to_le32(input as i32);
48-
}
49-
}
50-
5139
/// Read a vector of bytes into a vector of u64s. The values are read in big-endian format.
5240
pub fn read_u64v_be(dst: &mut[u64], input: &[u8]) {
5341
use std::cast::transmute;
@@ -80,90 +68,51 @@ pub fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
8068
}
8169
}
8270

83-
/// Read a vector of bytes into a vector of u32s. The values are read in little-endian format.
84-
pub fn read_u32v_le(dst: &mut[u32], input: &[u8]) {
85-
use std::cast::transmute;
86-
use std::unstable::intrinsics::to_le32;
87-
assert!(dst.len() * 4 == input.len());
88-
unsafe {
89-
let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
90-
let mut y: *i32 = transmute(input.unsafe_ref(0));
91-
do dst.len().times() {
92-
*x = to_le32(*y);
93-
x = x.offset(1);
94-
y = y.offset(1);
95-
}
96-
}
97-
}
98-
9971

100-
trait ToBits {
101-
/// Convert the value in bytes to the number of bits, a tuple where the 1st item is the
102-
/// high-order value and the 2nd item is the low order value.
103-
fn to_bits(self) -> (Self, Self);
72+
/// Returns true if adding the two parameters will result in integer overflow
73+
pub fn will_add_overflow<T: Int + Unsigned>(x: T, y: T) -> bool {
74+
// This doesn't handle negative values! Don't copy this code elsewhere without considering if
75+
// negative values are important to you!
76+
let max: T = Bounded::max_value();
77+
return x > max - y;
10478
}
10579

106-
impl ToBits for u64 {
107-
fn to_bits(self) -> (u64, u64) {
108-
return (self >> 61, self << 3);
80+
/// Shifts the second parameter and then adds it to the first. fails!() if there would be unsigned
81+
/// integer overflow.
82+
pub fn shift_add_check_overflow<T: Int + Unsigned + Clone>(x: T, mut y: T, shift: T) -> T {
83+
if y.leading_zeros() < shift {
84+
fail!("Could not add values - integer overflow.");
10985
}
110-
}
86+
y = y << shift;
11187

112-
/// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric
113-
/// overflow.
114-
pub fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
115-
let (new_high_bits, new_low_bits) = bytes.to_bits();
116-
117-
if new_high_bits > Zero::zero() {
118-
fail!("Numeric overflow occured.")
88+
if will_add_overflow(x.clone(), y.clone()) {
89+
fail!("Could not add values - integer overflow.");
11990
}
12091

121-
match bits.checked_add(&new_low_bits) {
122-
Some(x) => return x,
123-
None => fail!("Numeric overflow occured.")
124-
}
92+
return x + y;
12593
}
12694

127-
/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
128-
/// the high order value. fail!() if this would cause numeric overflow.
129-
pub fn add_bytes_to_bits_tuple
130-
<T: Int + Unsigned + CheckedAdd + ToBits>
131-
(bits: (T, T), bytes: T) -> (T, T) {
132-
let (new_high_bits, new_low_bits) = bytes.to_bits();
133-
let (hi, low) = bits;
134-
135-
// Add the low order value - if there is no overflow, then add the high order values
136-
// If the addition of the low order values causes overflow, add one to the high order values
137-
// before adding them.
138-
match low.checked_add(&new_low_bits) {
139-
Some(x) => {
140-
if new_high_bits == Zero::zero() {
141-
// This is the fast path - every other alternative will rarely occur in practice
142-
// considering how large an input would need to be for those paths to be used.
143-
return (hi, x);
144-
} else {
145-
match hi.checked_add(&new_high_bits) {
146-
Some(y) => return (y, x),
147-
None => fail!("Numeric overflow occured.")
148-
}
149-
}
150-
},
151-
None => {
95+
/// Shifts the second parameter and then adds it to the first, which is a tuple where the first
96+
/// element is the high order value. fails!() if there would be unsigned integer overflow.
97+
pub fn shift_add_check_overflow_tuple
98+
<T: Int + Unsigned + Clone>
99+
(x: (T, T), mut y: T, shift: T) -> (T, T) {
100+
if y.leading_zeros() < shift {
101+
fail!("Could not add values - integer overflow.");
102+
}
103+
y = y << shift;
104+
105+
match x {
106+
(hi, low) => {
152107
let one: T = One::one();
153-
let z = match new_high_bits.checked_add(&one) {
154-
Some(w) => w,
155-
None => fail!("Numeric overflow occured.")
156-
};
157-
match hi.checked_add(&z) {
158-
// This re-executes the addition that was already performed earlier when overflow
159-
// occured, this time allowing the overflow to happen. Technically, this could be
160-
// avoided by using the checked add intrinsic directly, but that involves using
161-
// unsafe code and is not really worthwhile considering how infrequently code will
162-
// run in practice. This is the reason that this function requires that the type T
163-
// be Unsigned - overflow is not defined for Signed types. This function could be
164-
// implemented for signed types as well if that were needed.
165-
Some(y) => return (y, low + new_low_bits),
166-
None => fail!("Numeric overflow occured.")
108+
if will_add_overflow(low.clone(), y.clone()) {
109+
if will_add_overflow(hi.clone(), one.clone()) {
110+
fail!("Could not add values - integer overflow.");
111+
} else {
112+
return (hi + one, low + y);
113+
}
114+
} else {
115+
return (hi, low + y);
167116
}
168117
}
169118
}
@@ -351,7 +300,6 @@ mod test {
351300
use std::rand::RngUtil;
352301
use std::vec;
353302

354-
use cryptoutil::{add_bytes_to_bits, add_bytes_to_bits_tuple};
355303
use digest::Digest;
356304

357305
/// Feed 1,000,000 'a's into the digest with varying input sizes and check that the result is
@@ -376,50 +324,4 @@ mod test {
376324

377325
assert!(expected == result_str);
378326
}
379-
380-
// A normal addition - no overflow occurs
381-
#[test]
382-
fn test_add_bytes_to_bits_ok() {
383-
assert!(add_bytes_to_bits::<u64>(100, 10) == 180);
384-
}
385-
386-
// A simple failure case - adding 1 to the max value
387-
#[test]
388-
#[should_fail]
389-
fn test_add_bytes_to_bits_overflow() {
390-
add_bytes_to_bits::<u64>(Bounded::max_value(), 1);
391-
}
392-
393-
// A normal addition - no overflow occurs (fast path)
394-
#[test]
395-
fn test_add_bytes_to_bits_tuple_ok() {
396-
assert!(add_bytes_to_bits_tuple::<u64>((5, 100), 10) == (5, 180));
397-
}
398-
399-
// The low order value overflows into the high order value
400-
#[test]
401-
fn test_add_bytes_to_bits_tuple_ok2() {
402-
assert!(add_bytes_to_bits_tuple::<u64>((5, Bounded::max_value()), 1) == (6, 7));
403-
}
404-
405-
// The value to add is too large to be converted into bits without overflowing its type
406-
#[test]
407-
fn test_add_bytes_to_bits_tuple_ok3() {
408-
assert!(add_bytes_to_bits_tuple::<u64>((5, 0), 0x4000000000000001) == (7, 8));
409-
}
410-
411-
// A simple failure case - adding 1 to the max value
412-
#[test]
413-
#[should_fail]
414-
fn test_add_bytes_to_bits_tuple_overflow() {
415-
add_bytes_to_bits_tuple::<u64>((Bounded::max_value(), Bounded::max_value()), 1);
416-
}
417-
418-
// The value to add is too large to convert to bytes without overflowing its type, but the high
419-
// order value from this conversion overflows when added to the existing high order value
420-
#[test]
421-
#[should_fail]
422-
fn test_add_bytes_to_bits_tuple_overflow2() {
423-
add_bytes_to_bits_tuple::<u64>((Bounded::max_value::<u64>() - 1, 0), 0x8000000000000000);
424-
}
425327
}

0 commit comments

Comments
 (0)