Skip to content

Commit f78feb2

Browse files
committed
---
yaml --- r: 63629 b: refs/heads/snap-stage3 c: fe6a4fd h: refs/heads/master i: 63627: b779641 v: v3
1 parent 9ab85ac commit f78feb2

File tree

7 files changed

+57
-64
lines changed

7 files changed

+57
-64
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c6515ee6a7f424679e2b53336974a991dd3b71c8
4+
refs/heads/snap-stage3: fe6a4fd74a0a640fa9291f7cd4d31778da85e39b
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/arena.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -39,7 +39,7 @@ use core::prelude::*;
3939
use list::{MutList, MutCons, MutNil};
4040

4141
use core::at_vec;
42-
use core::cast::{transmute, transmute_mut, transmute_mut_region};
42+
use core::cast::{transmute, transmute_mut_region};
4343
use core::cast;
4444
use core::libc::size_t;
4545
use core::ptr;
@@ -74,7 +74,6 @@ struct Chunk {
7474
is_pod: bool,
7575
}
7676

77-
#[mutable]
7877
pub struct Arena {
7978
// The head is separated out from the list as a unbenchmarked
8079
// microoptimization, to avoid needing to case on the list to
@@ -270,22 +269,23 @@ impl Arena {
270269

271270
// The external interface
272271
#[inline]
273-
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
272+
pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
274273
unsafe {
275274
// XXX: Borrow check
276-
let this = transmute_mut(self);
277-
if intrinsics::needs_drop::<T>() {
278-
this.alloc_nonpod(op)
279-
} else {
280-
this.alloc_pod(op)
275+
let this = transmute_mut_region(self);
276+
if !intrinsics::needs_drop::<T>() {
277+
return this.alloc_pod(op);
281278
}
279+
// XXX: Borrow check
280+
let this = transmute_mut_region(self);
281+
this.alloc_nonpod(op)
282282
}
283283
}
284284
}
285285

286286
#[test]
287287
fn test_arena_destructors() {
288-
let arena = Arena();
288+
let mut arena = Arena();
289289
for uint::range(0, 10) |i| {
290290
// Arena allocate something with drop glue to make sure it
291291
// doesn't leak.
@@ -300,7 +300,7 @@ fn test_arena_destructors() {
300300
#[should_fail]
301301
#[ignore(cfg(windows))]
302302
fn test_arena_destructors_fail() {
303-
let arena = Arena();
303+
let mut arena = Arena();
304304
// Put some stuff in the arena.
305305
for uint::range(0, 10) |i| {
306306
// Arena allocate something with drop glue to make sure it
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// xfail-test
2+
3+
// Broken due to arena API problems.
4+
5+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
26
// file at the top-level directory of this distribution and at
37
// http://rust-lang.org/COPYRIGHT.
48
//
@@ -11,35 +15,33 @@
1115
extern mod extra;
1216
use extra::arena;
1317

14-
enum Tree<'self> {
15-
Nil,
16-
Node(&'self Tree<'self>, &'self Tree<'self>, int),
18+
enum tree<'self> {
19+
nil,
20+
node(&'self tree<'self>, &'self tree<'self>, int),
1721
}
1822

19-
fn item_check(t: &Tree) -> int {
23+
fn item_check(t: &tree) -> int {
2024
match *t {
21-
Nil => { return 0; }
22-
Node(left, right, item) => {
25+
nil => { return 0; }
26+
node(left, right, item) => {
2327
return item + item_check(left) - item_check(right);
2428
}
2529
}
2630
}
2731

28-
fn bottom_up_tree<'r>(arena: &'r arena::Arena, item: int, depth: int)
29-
-> &'r Tree<'r> {
32+
fn bottom_up_tree<'r>(arena: &'r mut arena::Arena, item: int, depth: int)
33+
-> &'r tree<'r> {
3034
if depth > 0 {
3135
return arena.alloc(
32-
|| Node(bottom_up_tree(arena, 2 * item - 1, depth - 1),
36+
|| node(bottom_up_tree(arena, 2 * item - 1, depth - 1),
3337
bottom_up_tree(arena, 2 * item, depth - 1),
3438
item));
3539
}
36-
return arena.alloc(|| Nil);
40+
return arena.alloc(|| nil);
3741
}
3842

3943
fn main() {
40-
use std::os;
41-
use std::int;
42-
let args = std::os::args();
44+
let args = os::args();
4345
let args = if os::getenv(~"RUST_BENCH").is_some() {
4446
~[~"", ~"17"]
4547
} else if args.len() <= 1u {
@@ -57,34 +59,34 @@ fn main() {
5759
max_depth = n;
5860
}
5961

60-
let stretch_arena = arena::Arena();
62+
let mut stretch_arena = arena::Arena();
6163
let stretch_depth = max_depth + 1;
62-
let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
64+
let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth);
6365

64-
println(fmt!("stretch tree of depth %d\t check: %d",
66+
io::println(fmt!("stretch tree of depth %d\t check: %d",
6567
stretch_depth,
6668
item_check(stretch_tree)));
6769

68-
let long_lived_arena = arena::Arena();
69-
let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
70+
let mut long_lived_arena = arena::Arena();
71+
let long_lived_tree = bottom_up_tree(&mut long_lived_arena, 0, max_depth);
7072
let mut depth = min_depth;
7173
while depth <= max_depth {
7274
let iterations = int::pow(2, (max_depth - depth + min_depth) as uint);
7375
let mut chk = 0;
7476
let mut i = 1;
7577
while i <= iterations {
76-
let mut temp_tree = bottom_up_tree(&long_lived_arena, i, depth);
78+
let mut temp_tree = bottom_up_tree(&mut long_lived_arena, i, depth);
7779
chk += item_check(temp_tree);
78-
temp_tree = bottom_up_tree(&long_lived_arena, -i, depth);
80+
temp_tree = bottom_up_tree(&mut long_lived_arena, -i, depth);
7981
chk += item_check(temp_tree);
8082
i += 1;
8183
}
82-
println(fmt!("%d\t trees of depth %d\t check: %d",
84+
io::println(fmt!("%d\t trees of depth %d\t check: %d",
8385
iterations * 2, depth,
8486
chk));
8587
depth += 2;
8688
}
87-
println(fmt!("long lived tree of depth %d\t check: %d",
89+
io::println(fmt!("long lived trees of depth %d\t check: %d",
8890
max_depth,
8991
item_check(long_lived_tree)));
9092
}

branches/snap-stage3/src/test/bench/shootout-chameneos-redux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn show_number(nn: uint) -> ~str {
8585
out = show_digit(dig) + " " + out;
8686
}
8787

88-
return ~" " + out;
88+
return out;
8989
}
9090

9191
fn transform(aa: color, bb: color) -> color {

branches/snap-stage3/src/test/bench/shootout-fasta.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -19,14 +19,16 @@ extern mod extra;
1919

2020
use std::int;
2121
use std::io;
22+
use std::option;
2223
use std::os;
2324
use std::rand::Rng;
2425
use std::rand;
2526
use std::result;
2627
use std::str;
2728
use std::uint;
29+
use std::vec;
2830

29-
static LINE_LENGTH: uint = 60u;
31+
fn LINE_LENGTH() -> uint { return 60u; }
3032

3133
struct MyRandom {
3234
last: u32
@@ -79,7 +81,7 @@ fn make_random_fasta(wr: @io::Writer,
7981
for uint::range(0u, n as uint) |_i| {
8082
op.push_char(select_random(myrandom_next(rng, 100u32),
8183
copy genelist));
82-
if op.len() >= LINE_LENGTH {
84+
if op.len() >= LINE_LENGTH() {
8385
wr.write_line(op);
8486
op = ~"";
8587
}
@@ -88,18 +90,18 @@ fn make_random_fasta(wr: @io::Writer,
8890
}
8991

9092
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
91-
wr.write_line(~">" + id + " " + desc);
92-
let mut op = str::with_capacity( LINE_LENGTH );
93-
let sl = s.len();
94-
for uint::range(0u, n as uint) |i| {
95-
if (op.len() >= LINE_LENGTH) {
96-
wr.write_line( op );
97-
op = str::with_capacity( LINE_LENGTH );
93+
unsafe {
94+
wr.write_line(~">" + id + " " + desc);
95+
let mut op: ~str = ~"";
96+
let sl: uint = s.len();
97+
for uint::range(0u, n as uint) |i| {
98+
str::raw::push_byte(&mut op, s[i % sl]);
99+
if op.len() >= LINE_LENGTH() {
100+
wr.write_line(op);
101+
op = ~"";
102+
}
98103
}
99-
op.push_char( s[i % sl] as char );
100-
}
101-
if op.len() > 0 {
102-
wr.write_line(op)
104+
if op.len() > 0u { wr.write_line(op); }
103105
}
104106
}
105107

@@ -109,7 +111,7 @@ fn acid(ch: char, prob: u32) -> AminoAcids {
109111

110112
fn main() {
111113
let args = os::args();
112-
let args = if os::getenv("RUST_BENCH").is_some() {
114+
let args = if os::getenv(~"RUST_BENCH").is_some() {
113115
// alioth tests k-nucleotide with this data at 25,000,000
114116
~[~"", ~"5000000"]
115117
} else if args.len() <= 1u {
@@ -118,9 +120,9 @@ fn main() {
118120
args
119121
};
120122

121-
let writer = if os::getenv("RUST_BENCH").is_some() {
123+
let writer = if os::getenv(~"RUST_BENCH").is_some() {
122124
result::get(&io::file_writer(&Path("./shootout-fasta.data"),
123-
[io::Truncate, io::Create]))
125+
~[io::Truncate, io::Create]))
124126
} else {
125127
io::stdout()
126128
};

branches/snap-stage3/src/test/bench/shootout-spectralnorm.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// Copyright 2012-2013 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-
111
use std::f64;
122
use std::from_str::FromStr;
133
use std::os;

branches/snap-stage3/src/test/run-pass/newlambdas-ret-infer2.rs

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

11-
// xfail-test ~fn is not inferred
1211
// Test that the lambda kind is inferred correctly as a return
1312
// expression
1413

0 commit comments

Comments
 (0)