Skip to content

Commit edaeb3e

Browse files
committed
---
yaml --- r: 64916 b: refs/heads/snap-stage3 c: 8261f2c h: refs/heads/master v: v3
1 parent aed0ffa commit edaeb3e

28 files changed

+400
-43
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: ebd14c92f8b15f6d9388ea9bf6f19793a1b77a59
4+
refs/heads/snap-stage3: 8261f2c37c7181fb4a40e8f8d9eaebb96deea9bb
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/configure

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ opt docs 1 "build documentation"
371371
opt optimize 1 "build optimized rust code"
372372
opt optimize-cxx 1 "build optimized C++ code"
373373
opt optimize-llvm 1 "build optimized LLVM"
374+
opt llvm-assertions 1 "build LLVM with assertions"
374375
opt debug 0 "build with extra debug fun"
375376
opt ratchet-bench 0 "ratchet benchmarks"
376377
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
@@ -793,10 +794,17 @@ do
793794
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
794795
# Just use LLVM straight from its build directory to
795796
# avoid 'make install' time
796-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts
797+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug
797798
else
798799
LLVM_DBG_OPTS="--enable-optimized"
799-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
800+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
801+
fi
802+
if [ ! -z "$CFG_DISABLE_LLVM_ASSERTIONS" ]
803+
then
804+
LLVM_ASSERTION_OPTS="--disable-assertions"
805+
else
806+
LLVM_ASSERTION_OPTS="--enable-assertions"
807+
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
800808
fi
801809
else
802810
msg "not reconfiguring LLVM, external LLVM root"
@@ -836,7 +844,7 @@ do
836844
LLVM_TARGET="--target=$t"
837845

838846
# Disable unused LLVM features
839-
LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs --enable-bindings=none"
847+
LLVM_OPTS="$LLVM_DBG_OPTS $LLVM_ASSERTION_OPTS --disable-docs --enable-bindings=none"
840848

841849
case "$CFG_C_COMPILER" in
842850
("ccache clang")

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,16 @@ mod tests {
576576
let (p, c) = comm::stream();
577577
578578
do task::spawn() || {
579+
let p = comm::PortSet::new();
580+
c.send(p.chan());
581+
579582
let arc_v : Arc<~[int]> = p.recv();
580583
581584
let v = (*arc_v.get()).clone();
582585
assert_eq!(v[3], 4);
583586
};
584587
588+
let c = p.recv();
585589
c.send(arc_v.clone());
586590
587591
assert_eq!(arc_v.get()[2], 3);

branches/snap-stage3/src/libstd/comm.rs

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ Message passing
1414

1515
#[allow(missing_doc)];
1616

17-
use cast::transmute;
17+
use cast::{transmute, transmute_mut};
18+
use container::Container;
1819
use either::{Either, Left, Right};
1920
use kinds::Send;
20-
use option::{Option, Some};
21+
use option::{Option, Some, None};
22+
use uint;
23+
use vec::OwnedVector;
24+
use util::replace;
2125
use unstable::sync::Exclusive;
2226
use rtcomm = rt::comm;
2327
use rt;
@@ -139,6 +143,81 @@ impl<T: Send> Selectable for Port<T> {
139143
}
140144
}
141145

146+
/// Treat many ports as one.
147+
#[unsafe_mut_field(ports)]
148+
pub struct PortSet<T> {
149+
ports: ~[pipesy::Port<T>],
150+
}
151+
152+
impl<T: Send> PortSet<T> {
153+
pub fn new() -> PortSet<T> {
154+
PortSet {
155+
ports: ~[]
156+
}
157+
}
158+
159+
pub fn add(&self, port: Port<T>) {
160+
let Port { inner } = port;
161+
let port = match inner {
162+
Left(p) => p,
163+
Right(_) => fail!("PortSet not implemented")
164+
};
165+
unsafe {
166+
let self_ports = transmute_mut(&self.ports);
167+
self_ports.push(port)
168+
}
169+
}
170+
171+
pub fn chan(&self) -> Chan<T> {
172+
let (po, ch) = stream();
173+
self.add(po);
174+
ch
175+
}
176+
}
177+
178+
impl<T:Send> GenericPort<T> for PortSet<T> {
179+
fn try_recv(&self) -> Option<T> {
180+
unsafe {
181+
let self_ports = transmute_mut(&self.ports);
182+
let mut result = None;
183+
// we have to swap the ports array so we aren't borrowing
184+
// aliasable mutable memory.
185+
let mut ports = replace(self_ports, ~[]);
186+
while result.is_none() && ports.len() > 0 {
187+
let i = wait_many(ports);
188+
match ports[i].try_recv() {
189+
Some(m) => {
190+
result = Some(m);
191+
}
192+
None => {
193+
// Remove this port.
194+
let _ = ports.swap_remove(i);
195+
}
196+
}
197+
}
198+
*self_ports = ports;
199+
result
200+
}
201+
}
202+
fn recv(&self) -> T {
203+
self.try_recv().expect("port_set: endpoints closed")
204+
}
205+
}
206+
207+
impl<T: Send> Peekable<T> for PortSet<T> {
208+
fn peek(&self) -> bool {
209+
// It'd be nice to use self.port.each, but that version isn't
210+
// pure.
211+
for uint::range(0, self.ports.len()) |i| {
212+
let port: &pipesy::Port<T> = &self.ports[i];
213+
if port.peek() {
214+
return true;
215+
}
216+
}
217+
false
218+
}
219+
}
220+
142221
/// A channel that can be shared between many senders.
143222
pub struct SharedChan<T> {
144223
inner: Either<Exclusive<pipesy::Chan<T>>, rtcomm::SharedChan<T>>

branches/snap-stage3/src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ pub fn std_macros() -> @str {
683683
($cond:expr) => {
684684
if !$cond {
685685
::std::sys::FailWithCause::fail_with(
686-
~\"assertion failed: \" + stringify!($cond), file!(), line!())
686+
\"assertion failed: \" + stringify!($cond), file!(), line!())
687687
}
688688
};
689689
($cond:expr, $msg:expr) => {

branches/snap-stage3/src/test/bench/msgsend-pipes.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
extern mod extra;
1818

19-
use std::comm::{SharedChan, Chan, stream};
19+
use std::comm::{PortSet, Chan, stream};
2020
use std::io;
2121
use std::os;
2222
use std::task;
@@ -30,7 +30,7 @@ enum request {
3030
stop
3131
}
3232

33-
fn server(requests: &Port<request>, responses: &Chan<uint>) {
33+
fn server(requests: &PortSet<request>, responses: &Chan<uint>) {
3434
let mut count: uint = 0;
3535
let mut done = false;
3636
while !done {
@@ -50,16 +50,18 @@ fn server(requests: &Port<request>, responses: &Chan<uint>) {
5050

5151
fn run(args: &[~str]) {
5252
let (from_child, to_parent) = stream();
53-
let (from_parent, to_child) = stream();
54-
let to_child = SharedChan::new(to_child);
53+
let (from_parent_, to_child) = stream();
54+
let from_parent = PortSet::new();
55+
from_parent.add(from_parent_);
5556

5657
let size = uint::from_str(args[1]).get();
5758
let workers = uint::from_str(args[2]).get();
5859
let num_bytes = 100;
5960
let start = extra::time::precise_time_s();
6061
let mut worker_results = ~[];
6162
for uint::range(0, workers) |_i| {
62-
let to_child = to_child.clone();
63+
let (from_parent_, to_child) = stream();
64+
from_parent.add(from_parent_);
6365
let mut builder = task::task();
6466
builder.future_result(|r| worker_results.push(r));
6567
do builder.spawn {

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@ use std::u64;
3333
use std::uint;
3434

3535
fn fib(n: int) -> int {
36-
fn pfib(c: &SharedChan<int>, n: int) {
36+
fn pfib(c: &Chan<int>, n: int) {
3737
if n == 0 {
3838
c.send(0);
3939
} else if n <= 2 {
4040
c.send(1);
4141
} else {
42-
let (pp, cc) = stream();
43-
let cc = SharedChan::new(cc);
44-
let ch = cc.clone();
42+
let p = PortSet::new();
43+
let ch = p.chan();
4544
task::spawn(|| pfib(&ch, n - 1) );
46-
let ch = cc.clone();
45+
let ch = p.chan();
4746
task::spawn(|| pfib(&ch, n - 2) );
48-
c.send(pp.recv() + pp.recv());
47+
c.send(p.recv() + p.recv());
4948
}
5049
}
5150

5251
let (p, ch) = stream();
53-
let ch = SharedChan::new(ch);
5452
let _t = task::spawn(|| pfib(&ch, n) );
5553
p.recv()
5654
}

branches/snap-stage3/src/test/codegen/iterate-over-array.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#include <stdlib.h>
212
#include <assert.h>
313

branches/snap-stage3/src/test/codegen/iterate-over-array.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#[no_mangle]
212
fn test(x: &[int]) -> int {
313
let mut y = 0;

branches/snap-stage3/src/test/codegen/scalar-function-call.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#include <stdlib.h>
212

313
size_t foo(size_t x) {

branches/snap-stage3/src/test/codegen/scalar-function-call.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
fn foo(x: int) -> int {
212
x * x
313
}

branches/snap-stage3/src/test/codegen/small-dense-int-switch.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#include <stdlib.h>
212

313
extern "C"

branches/snap-stage3/src/test/codegen/small-dense-int-switch.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#[no_mangle]
212
fn test(x: int, y: int) -> int {
313
match x {

branches/snap-stage3/src/test/codegen/stack-alloc-string-slice.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#include <stddef.h>
212

313
struct slice {

branches/snap-stage3/src/test/codegen/stack-alloc-string-slice.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 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
#[no_mangle]
212
fn test() {
313
let _x = "hello";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 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+
11+
#include <stdlib.h>
12+
13+
struct Struct {
14+
size_t field;
15+
size_t method(size_t x) {
16+
return this->field + x;
17+
}
18+
};
19+
20+
extern "C"
21+
size_t test(Struct &a,
22+
Struct &b,
23+
Struct &c,
24+
Struct &d,
25+
Struct &e) {
26+
return a.method(b.method(c.method(d.method(e.method(1)))));
27+
}

0 commit comments

Comments
 (0)