Skip to content

Commit ad1cbbb

Browse files
committed
---
yaml --- r: 140694 b: refs/heads/try2 c: 9482ed7 h: refs/heads/master v: v3
1 parent 135c3d0 commit ad1cbbb

File tree

201 files changed

+1647
-5005
lines changed

Some content is hidden

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

201 files changed

+1647
-5005
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: 842e304ab505f6c0d8f6b29ec3c0dfa8dc9e1aac
8+
refs/heads/try2: 9482ed729eaf9ade87a3aec057a56c4a48f49653
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,35 @@ fn avg(v: &[float]) -> float {
19461946
}
19471947
~~~~
19481948

1949+
#### Swap expressions
1950+
1951+
A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a bi-directional arrow (`<->`) and another [lvalue](#lvalues-rvalues-and-temporaries).
1952+
1953+
Evaluating a swap expression causes, as a side effect, the values held in the left-hand-side and right-hand-side [lvalues](#lvalues-rvalues-and-temporaries) to be exchanged indivisibly.
1954+
1955+
Evaluating a swap expression neither changes reference counts,
1956+
nor deeply copies any owned structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1957+
Instead, the swap expression represents an indivisible *exchange of ownership*,
1958+
between the right-hand-side and the left-hand-side of the expression.
1959+
No allocation or destruction is entailed.
1960+
1961+
An example of three different swap expressions:
1962+
1963+
~~~~~~~~
1964+
# let mut x = &mut [0];
1965+
# let mut a = &mut [0];
1966+
# let i = 0;
1967+
# struct S1 { z: int };
1968+
# struct S2 { c: int };
1969+
# let mut y = S1{z: 0};
1970+
# let mut b = S2{c: 0};
1971+
1972+
x <-> a;
1973+
x[i] <-> a[i];
1974+
y.z <-> b.c;
1975+
~~~~~~~~
1976+
1977+
19491978
#### Assignment expressions
19501979

19511980
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
@@ -1986,7 +2015,7 @@ as
19862015
== !=
19872016
&&
19882017
||
1989-
=
2018+
= <->
19902019
~~~~
19912020

19922021
Operators at the same precedence level are evaluated left-to-right.

branches/try2/doc/tutorial-ffi.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ wrapping `malloc` and `free`:
151151
~~~~
152152
use core::libc::{c_void, size_t, malloc, free};
153153
use core::unstable::intrinsics;
154-
use core::util;
155154
156155
// a wrapper around the handle returned by the foreign code
157156
pub struct Unique<T> {
@@ -185,8 +184,7 @@ impl<T: Owned> Drop for Unique<T> {
185184
fn finalize(&self) {
186185
unsafe {
187186
let mut x = intrinsics::init(); // dummy value to swap in
188-
// moving the object out is needed to call the destructor
189-
util::replace_ptr(self.ptr, x);
187+
x <-> *self.ptr; // moving the object out is needed to call the destructor
190188
free(self.ptr as *c_void)
191189
}
192190
}

branches/try2/mk/platform.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ AR_mips-unknown-linux-gnu=mips-linux-gnu-ar
247247
CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
248248
CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
249249
CFG_LIB_DSYM_GLOB_mips-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
250-
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32 -mno-compact-eh
250+
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32
251251
CFG_GCCISH_CXXFLAGS_mips-unknown-linux-gnu := -fno-rtti
252252
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32
253253
CFG_GCCISH_DEF_FLAG_mips-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
254254
CFG_GCCISH_PRE_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-whole-archive
255-
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive
255+
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack
256256
CFG_DEF_SUFFIX_mips-unknown-linux-gnu := .linux.def
257257
CFG_INSTALL_NAME_mips-unknown-linux-gnu =
258258
CFG_LIBUV_LINK_FLAGS_mips-unknown-linux-gnu =

branches/try2/src/libcore/cast.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ pub mod rusti {
2424
}
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
27-
#[cfg(not(stage0))]
28-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
29-
let mut dest: U = unstable::intrinsics::uninit();
30-
{
31-
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
32-
let src_ptr: *u8 = rusti::transmute(src);
33-
unstable::intrinsics::memmove64(dest_ptr,
34-
src_ptr,
35-
sys::size_of::<U>() as u64);
36-
}
37-
dest
38-
}
39-
40-
#[cfg(stage0)]
4127
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
4228
let mut dest: U = unstable::intrinsics::init();
4329
{

branches/try2/src/libcore/cell.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
use cast::transmute_mut;
1414
use prelude::*;
15-
use util::replace;
1615

1716
/*
1817
A dynamic, mutable location.
@@ -49,7 +48,9 @@ pub impl<T> Cell<T> {
4948
fail!(~"attempt to take an empty cell");
5049
}
5150
52-
replace(&mut self.value, None).unwrap()
51+
let mut value = None;
52+
value <-> self.value;
53+
value.unwrap()
5354
}
5455
5556
/// Returns the value, failing if the cell is full.

branches/try2/src/libcore/cleanup.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ struct AnnihilateStats {
127127
n_bytes_freed: uint
128128
}
129129

130-
#[cfg(stage0)]
131130
unsafe fn each_live_alloc(read_next_before: bool,
132131
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
133132
//! Walks the internal list of allocations
@@ -142,8 +141,8 @@ unsafe fn each_live_alloc(read_next_before: bool,
142141
let uniq =
143142
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
144143

145-
if !f(box, uniq) {
146-
return;
144+
if ! f(box, uniq) {
145+
break
147146
}
148147

149148
if read_next_before {
@@ -153,33 +152,6 @@ unsafe fn each_live_alloc(read_next_before: bool,
153152
}
154153
}
155154
}
156-
#[cfg(not(stage0))]
157-
unsafe fn each_live_alloc(read_next_before: bool,
158-
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool {
159-
//! Walks the internal list of allocations
160-
161-
use managed;
162-
163-
let task: *Task = transmute(rustrt::rust_get_task());
164-
let box = (*task).boxed_region.live_allocs;
165-
let mut box: *mut BoxRepr = transmute(copy box);
166-
while box != mut_null() {
167-
let next_before = transmute(copy (*box).header.next);
168-
let uniq =
169-
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
170-
171-
if !f(box, uniq) {
172-
return false;
173-
}
174-
175-
if read_next_before {
176-
box = next_before;
177-
} else {
178-
box = transmute(copy (*box).header.next);
179-
}
180-
}
181-
return true;
182-
}
183155

184156
#[cfg(unix)]
185157
fn debug_mem() -> bool {

branches/try2/src/libcore/comm.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use uint;
2121
use unstable;
2222
use vec;
2323
use unstable::Exclusive;
24-
use util::replace;
2524

2625
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
2726

@@ -150,8 +149,9 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
150149
#[inline(always)]
151150
fn send(&self, x: T) {
152151
unsafe {
152+
let mut endp = None;
153153
let mut self_endp = transmute_mut(&self.endp);
154-
let endp = replace(self_endp, None);
154+
endp <-> *self_endp;
155155
*self_endp = Some(streamp::client::data(endp.unwrap(), x))
156156
}
157157
}
@@ -161,8 +161,9 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
161161
#[inline(always)]
162162
fn try_send(&self, x: T) -> bool {
163163
unsafe {
164+
let mut endp = None;
164165
let mut self_endp = transmute_mut(&self.endp);
165-
let endp = replace(self_endp, None);
166+
endp <-> *self_endp;
166167
match streamp::client::try_data(endp.unwrap(), x) {
167168
Some(next) => {
168169
*self_endp = Some(next);
@@ -178,8 +179,9 @@ impl<T: Owned> GenericPort<T> for Port<T> {
178179
#[inline(always)]
179180
fn recv(&self) -> T {
180181
unsafe {
182+
let mut endp = None;
181183
let mut self_endp = transmute_mut(&self.endp);
182-
let endp = replace(self_endp, None);
184+
endp <-> *self_endp;
183185
let streamp::data(x, endp) = recv(endp.unwrap());
184186
*self_endp = Some(endp);
185187
x
@@ -189,8 +191,9 @@ impl<T: Owned> GenericPort<T> for Port<T> {
189191
#[inline(always)]
190192
fn try_recv(&self) -> Option<T> {
191193
unsafe {
194+
let mut endp = None;
192195
let mut self_endp = transmute_mut(&self.endp);
193-
let endp = replace(self_endp, None);
196+
endp <-> *self_endp;
194197
match try_recv(endp.unwrap()) {
195198
Some(streamp::data(x, endp)) => {
196199
*self_endp = Some(endp);
@@ -206,13 +209,14 @@ impl<T: Owned> Peekable<T> for Port<T> {
206209
#[inline(always)]
207210
fn peek(&self) -> bool {
208211
unsafe {
212+
let mut endp = None;
209213
let mut self_endp = transmute_mut(&self.endp);
210-
let mut endp = replace(self_endp, None);
214+
endp <-> *self_endp;
211215
let peek = match endp {
212216
Some(ref mut endp) => peek(endp),
213217
None => fail!(~"peeking empty stream")
214218
};
215-
*self_endp = endp;
219+
*self_endp <-> endp;
216220
peek
217221
}
218222
}
@@ -263,7 +267,8 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
263267
let mut result = None;
264268
// we have to swap the ports array so we aren't borrowing
265269
// aliasable mutable memory.
266-
let mut ports = replace(self_ports, ~[]);
270+
let mut ports = ~[];
271+
ports <-> *self_ports;
267272
while result.is_none() && ports.len() > 0 {
268273
let i = wait_many(ports);
269274
match ports[i].try_recv() {
@@ -276,7 +281,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
276281
}
277282
}
278283
}
279-
*self_ports = ports;
284+
ports <-> *self_ports;
280285
result
281286
}
282287
}
@@ -315,7 +320,8 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> {
315320
fn send(&self, x: T) {
316321
let mut xx = Some(x);
317322
do self.ch.with_imm |chan| {
318-
let x = replace(&mut xx, None);
323+
let mut x = None;
324+
x <-> xx;
319325
chan.send(x.unwrap())
320326
}
321327
}
@@ -325,7 +331,8 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
325331
fn try_send(&self, x: T) -> bool {
326332
let mut xx = Some(x);
327333
do self.ch.with_imm |chan| {
328-
let x = replace(&mut xx, None);
334+
let mut x = None;
335+
x <-> xx;
329336
chan.try_send(x.unwrap())
330337
}
331338
}

branches/try2/src/libcore/condition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use prelude::*;
1414
use task;
15-
use local_data::{local_data_pop, local_data_set};
15+
use task::local_data::{local_data_pop, local_data_set};
1616

1717
// helper for transmutation, shown below.
1818
type RustClosure = (int, int);
@@ -24,14 +24,14 @@ pub struct Handler<T, U> {
2424

2525
pub struct Condition<'self, T, U> {
2626
name: &'static str,
27-
key: local_data::LocalDataKey<'self, Handler<T, U>>
27+
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
2828
}
2929

3030
pub impl<'self, T, U> Condition<'self, T, U> {
3131
fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
3232
unsafe {
3333
let p : *RustClosure = ::cast::transmute(&h);
34-
let prev = local_data::local_data_get(self.key);
34+
let prev = task::local_data::local_data_get(self.key);
3535
let h = @Handler { handle: *p, prev: prev };
3636
Trap { cond: self, handler: h }
3737
}

branches/try2/src/libcore/container.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,16 @@ pub trait Map<K, V>: Mutable {
3030
fn contains_key(&self, key: &K) -> bool;
3131

3232
// Visits all keys and values
33-
#[cfg(stage0)]
3433
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool);
35-
// Visits all keys and values
36-
#[cfg(not(stage0))]
37-
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool) -> bool;
3834

3935
/// Visit all keys
40-
#[cfg(stage0)]
4136
fn each_key(&self, f: &fn(&K) -> bool);
42-
/// Visit all keys
43-
#[cfg(not(stage0))]
44-
fn each_key(&self, f: &fn(&K) -> bool) -> bool;
4537

4638
/// Visit all values
47-
#[cfg(stage0)]
4839
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool);
49-
/// Visit all values
50-
#[cfg(not(stage0))]
51-
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool;
5240

5341
/// Iterate over the map and mutate the contained values
54-
#[cfg(stage0)]
5542
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
56-
/// Iterate over the map and mutate the contained values
57-
#[cfg(not(stage0))]
58-
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool;
5943

6044
/// Return a reference to the value corresponding to the key
6145
fn find<'a>(&'a self, key: &K) -> Option<&'a V>;
@@ -81,7 +65,6 @@ pub trait Map<K, V>: Mutable {
8165
fn pop(&mut self, k: &K) -> Option<V>;
8266
}
8367

84-
#[cfg(stage0)]
8568
pub trait Set<T>: Mutable {
8669
/// Return true if the set contains a value
8770
fn contains(&self, value: &T) -> bool;
@@ -116,39 +99,3 @@ pub trait Set<T>: Mutable {
11699
/// Visit the values representing the union
117100
fn union(&self, other: &Self, f: &fn(&T) -> bool);
118101
}
119-
120-
#[cfg(not(stage0))]
121-
pub trait Set<T>: Mutable {
122-
/// Return true if the set contains a value
123-
fn contains(&self, value: &T) -> bool;
124-
125-
/// Add a value to the set. Return true if the value was not already
126-
/// present in the set.
127-
fn insert(&mut self, value: T) -> bool;
128-
129-
/// Remove a value from the set. Return true if the value was
130-
/// present in the set.
131-
fn remove(&mut self, value: &T) -> bool;
132-
133-
/// Return true if the set has no elements in common with `other`.
134-
/// This is equivalent to checking for an empty intersection.
135-
fn is_disjoint(&self, other: &Self) -> bool;
136-
137-
/// Return true if the set is a subset of another
138-
fn is_subset(&self, other: &Self) -> bool;
139-
140-
/// Return true if the set is a superset of another
141-
fn is_superset(&self, other: &Self) -> bool;
142-
143-
/// Visit the values representing the difference
144-
fn difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
145-
146-
/// Visit the values representing the symmetric difference
147-
fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
148-
149-
/// Visit the values representing the intersection
150-
fn intersection(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
151-
152-
/// Visit the values representing the union
153-
fn union(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
154-
}

branches/try2/src/libcore/core

-9.02 MB
Binary file not shown.

0 commit comments

Comments
 (0)