Skip to content

Commit a201e3e

Browse files
committed
---
yaml --- r: 140710 b: refs/heads/try2 c: 8ca64a4 h: refs/heads/master v: v3
1 parent 003dc5f commit a201e3e

File tree

217 files changed

+4994
-1587
lines changed

Some content is hidden

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

217 files changed

+4994
-1587
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: 3db74ddd2e0ec7ea02ac1b82745439587f514cc4
8+
refs/heads/try2: 8ca64a423bea5dd9f4149fe343f7cec87e25316c
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: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,35 +1946,6 @@ 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-
19781949
#### Assignment expressions
19791950

19801951
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
@@ -2015,7 +1986,7 @@ as
20151986
== !=
20161987
&&
20171988
||
2018-
= <->
1989+
=
20191990
~~~~
20201991

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

branches/try2/doc/tutorial-ffi.md

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

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
250+
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32 -mno-compact-eh
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 -Wl,-znoexecstack
255+
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive
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/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
9191
return false;
9292

9393
fn xfail_target() -> ~str {
94-
~"xfail-" + str::from_slice(os::SYSNAME)
94+
~"xfail-" + str::to_owned(os::SYSNAME)
9595
}
9696
}
9797

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
371371
was_expected = true;
372372
}
373373

374-
if !was_expected && is_compiler_error_or_warning(str::from_slice(line)) {
374+
if !was_expected && is_compiler_error_or_warning(str::to_owned(line)) {
375375
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
376376
line),
377377
ProcRes);
@@ -596,7 +596,7 @@ fn make_lib_name(config: config, auxfile: &Path, testfile: &Path) -> Path {
596596

597597
fn make_exe_name(config: config, testfile: &Path) -> Path {
598598
Path(output_base_name(config, testfile).to_str() +
599-
str::from_slice(os::EXE_SUFFIX))
599+
str::to_owned(os::EXE_SUFFIX))
600600
}
601601

602602
fn make_run_args(config: config, _props: TestProps, testfile: &Path) ->

branches/try2/src/libcore/cell.rs

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

1617
/*
1718
A dynamic, mutable location.
@@ -48,9 +49,7 @@ pub impl<T> Cell<T> {
4849
fail!(~"attempt to take an empty cell");
4950
}
5051
51-
let mut value = None;
52-
value <-> self.value;
53-
value.unwrap()
52+
replace(&mut self.value, None).unwrap()
5453
}
5554
5655
/// Returns the value, failing if the cell is full.

branches/try2/src/libcore/cleanup.rs

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

130+
#[cfg(stage0)]
130131
unsafe fn each_live_alloc(read_next_before: bool,
131132
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
132133
//! Walks the internal list of allocations
@@ -141,8 +142,8 @@ unsafe fn each_live_alloc(read_next_before: bool,
141142
let uniq =
142143
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
143144

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

148149
if read_next_before {
@@ -152,6 +153,33 @@ unsafe fn each_live_alloc(read_next_before: bool,
152153
}
153154
}
154155
}
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+
}
155183

156184
#[cfg(unix)]
157185
fn debug_mem() -> bool {

branches/try2/src/libcore/comm.rs

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

2526
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
2627

@@ -149,9 +150,8 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
149150
#[inline(always)]
150151
fn send(&self, x: T) {
151152
unsafe {
152-
let mut endp = None;
153153
let mut self_endp = transmute_mut(&self.endp);
154-
endp <-> *self_endp;
154+
let endp = replace(self_endp, None);
155155
*self_endp = Some(streamp::client::data(endp.unwrap(), x))
156156
}
157157
}
@@ -161,9 +161,8 @@ 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;
165164
let mut self_endp = transmute_mut(&self.endp);
166-
endp <-> *self_endp;
165+
let endp = replace(self_endp, None);
167166
match streamp::client::try_data(endp.unwrap(), x) {
168167
Some(next) => {
169168
*self_endp = Some(next);
@@ -179,9 +178,8 @@ impl<T: Owned> GenericPort<T> for Port<T> {
179178
#[inline(always)]
180179
fn recv(&self) -> T {
181180
unsafe {
182-
let mut endp = None;
183181
let mut self_endp = transmute_mut(&self.endp);
184-
endp <-> *self_endp;
182+
let endp = replace(self_endp, None);
185183
let streamp::data(x, endp) = recv(endp.unwrap());
186184
*self_endp = Some(endp);
187185
x
@@ -191,9 +189,8 @@ impl<T: Owned> GenericPort<T> for Port<T> {
191189
#[inline(always)]
192190
fn try_recv(&self) -> Option<T> {
193191
unsafe {
194-
let mut endp = None;
195192
let mut self_endp = transmute_mut(&self.endp);
196-
endp <-> *self_endp;
193+
let endp = replace(self_endp, None);
197194
match try_recv(endp.unwrap()) {
198195
Some(streamp::data(x, endp)) => {
199196
*self_endp = Some(endp);
@@ -209,14 +206,13 @@ impl<T: Owned> Peekable<T> for Port<T> {
209206
#[inline(always)]
210207
fn peek(&self) -> bool {
211208
unsafe {
212-
let mut endp = None;
213209
let mut self_endp = transmute_mut(&self.endp);
214-
endp <-> *self_endp;
210+
let mut endp = replace(self_endp, None);
215211
let peek = match endp {
216212
Some(ref mut endp) => peek(endp),
217213
None => fail!(~"peeking empty stream")
218214
};
219-
*self_endp <-> endp;
215+
*self_endp = endp;
220216
peek
221217
}
222218
}
@@ -267,8 +263,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
267263
let mut result = None;
268264
// we have to swap the ports array so we aren't borrowing
269265
// aliasable mutable memory.
270-
let mut ports = ~[];
271-
ports <-> *self_ports;
266+
let mut ports = replace(self_ports, ~[]);
272267
while result.is_none() && ports.len() > 0 {
273268
let i = wait_many(ports);
274269
match ports[i].try_recv() {
@@ -281,7 +276,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
281276
}
282277
}
283278
}
284-
ports <-> *self_ports;
279+
*self_ports = ports;
285280
result
286281
}
287282
}
@@ -320,8 +315,7 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> {
320315
fn send(&self, x: T) {
321316
let mut xx = Some(x);
322317
do self.ch.with_imm |chan| {
323-
let mut x = None;
324-
x <-> xx;
318+
let x = replace(&mut xx, None);
325319
chan.send(x.unwrap())
326320
}
327321
}
@@ -331,8 +325,7 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
331325
fn try_send(&self, x: T) -> bool {
332326
let mut xx = Some(x);
333327
do self.ch.with_imm |chan| {
334-
let mut x = None;
335-
x <-> xx;
328+
let x = replace(&mut xx, None);
336329
chan.try_send(x.unwrap())
337330
}
338331
}

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 task::local_data::{local_data_pop, local_data_set};
15+
use 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: task::local_data::LocalDataKey<'self, Handler<T, U>>
27+
key: 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 = task::local_data::local_data_get(self.key);
34+
let prev = local_data::local_data_get(self.key);
3535
let h = @Handler { handle: *p, prev: prev };
3636
Trap { cond: self, handler: h }
3737
}

0 commit comments

Comments
 (0)