Skip to content

Commit 8b23fd4

Browse files
committed
---
yaml --- r: 42451 b: refs/heads/try c: f405e41 h: refs/heads/master i: 42449: 6628401 42447: 1ac1260 v: v3
1 parent ce8d891 commit 8b23fd4

39 files changed

+527
-414
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: ed17ce1ddae2b8c80a6c97ab32efc15b5e4285b9
5+
refs/heads/try: f405e41d7a43ebd7fdd0fcd90f6e0542a5a6ccf6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libcore/at_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub mod raw {
216216
}
217217

218218
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
219-
reserve_at_least(v, v.len() + 1u);
219+
reserve_at_least(&mut *v, v.len() + 1u);
220220
push_fast(v, move initval);
221221
}
222222

@@ -234,7 +234,7 @@ pub mod raw {
234234
pub unsafe fn reserve<T>(v: &mut @[const T], n: uint) {
235235
// Only make the (slow) call into the runtime if we have to
236236
if capacity(*v) < n {
237-
let ptr: **VecRepr = transmute(copy v);
237+
let ptr: **VecRepr = transmute(v);
238238
rustrt::vec_reserve_shared_actual(sys::get_type_desc::<T>(),
239239
ptr, n as libc::size_t);
240240
}

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ pub mod at_vec;
9595
pub mod str;
9696

9797
pub mod ptr;
98-
pub mod managed;
9998
pub mod owned;
99+
pub mod managed;
100100

101101

102102
/* Core language traits */

branches/try/src/libcore/managed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#[forbid(deprecated_mode)];
1515
#[forbid(deprecated_pattern)];
1616

17+
use cast::transmute;
1718
use cmp::{Eq, Ord};
19+
use managed::raw::BoxRepr;
1820
use prelude::*;
1921
use ptr;
2022

branches/try/src/libcore/rt.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#[forbid(deprecated_pattern)];
1616
//! Runtime calls emitted by the compiler.
1717
18+
use cast::transmute;
1819
use libc::{c_char, c_void, size_t, uintptr_t};
20+
use managed::raw::BoxRepr;
1921
use str;
2022
use sys;
2123

@@ -24,6 +26,11 @@ use gc::{cleanup_stack_for_failure, gc, Word};
2426
#[allow(non_camel_case_types)]
2527
pub type rust_task = c_void;
2628

29+
#[cfg(target_word_size = "32")]
30+
const FROZEN_BIT: uint = 0x80000000;
31+
#[cfg(target_word_size = "64")]
32+
const FROZEN_BIT: uint = 0x8000000000000000;
33+
2734
extern mod rustrt {
2835
#[rust_stack]
2936
unsafe fn rust_upcall_exchange_malloc(td: *c_char, size: uintptr_t)
@@ -56,6 +63,15 @@ pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t,
5663
}
5764
}
5865

66+
pub unsafe fn rt_fail_borrowed() {
67+
let msg = "borrowed";
68+
do str::as_buf(msg) |msg_p, _| {
69+
do str::as_buf("???") |file_p, _| {
70+
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
71+
}
72+
}
73+
}
74+
5975
#[rt(exchange_malloc)]
6076
#[lang="exchange_malloc"]
6177
pub unsafe fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
@@ -86,6 +102,29 @@ pub unsafe fn rt_free(ptr: *c_char) {
86102
rustrt::rust_upcall_free(ptr);
87103
}
88104

105+
#[lang="borrow_as_imm"]
106+
#[inline(always)]
107+
pub unsafe fn borrow_as_imm(a: *u8) {
108+
let a: *mut BoxRepr = transmute(a);
109+
(*a).header.ref_count |= FROZEN_BIT;
110+
}
111+
112+
#[lang="return_to_mut"]
113+
#[inline(always)]
114+
pub unsafe fn return_to_mut(a: *u8) {
115+
let a: *mut BoxRepr = transmute(a);
116+
(*a).header.ref_count &= !FROZEN_BIT;
117+
}
118+
119+
#[lang="check_not_borrowed"]
120+
#[inline(always)]
121+
pub unsafe fn check_not_borrowed(a: *u8) {
122+
let a: *mut BoxRepr = transmute(a);
123+
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
124+
rt_fail_borrowed();
125+
}
126+
}
127+
89128
// Local Variables:
90129
// mode: rust;
91130
// fill-column: 78;

branches/try/src/libcore/str.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub fn push_char(s: &mut ~str, ch: char) {
8080
else { 6u };
8181
let len = len(*s);
8282
let new_len = len + nb;
83-
reserve_at_least(s, new_len);
83+
reserve_at_least(&mut *s, new_len);
8484
let off = len;
8585
do as_buf(*s) |buf, _len| {
8686
let buf: *mut u8 = ::cast::reinterpret_cast(&buf);
@@ -164,7 +164,7 @@ pub fn push_str_no_overallocate(lhs: &mut ~str, rhs: &str) {
164164
unsafe {
165165
let llen = lhs.len();
166166
let rlen = rhs.len();
167-
reserve(lhs, llen + rlen);
167+
reserve(&mut *lhs, llen + rlen);
168168
do as_buf(*lhs) |lbuf, _llen| {
169169
do as_buf(rhs) |rbuf, _rlen| {
170170
let dst = ptr::offset(lbuf, llen);
@@ -181,7 +181,7 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) {
181181
unsafe {
182182
let llen = lhs.len();
183183
let rlen = rhs.len();
184-
reserve_at_least(lhs, llen + rlen);
184+
reserve_at_least(&mut *lhs, llen + rlen);
185185
do as_buf(*lhs) |lbuf, _llen| {
186186
do as_buf(rhs) |rbuf, _rlen| {
187187
let dst = ptr::offset(lbuf, llen);
@@ -2056,18 +2056,18 @@ pub mod raw {
20562056

20572057
/// Appends a byte to a string. (Not UTF-8 safe).
20582058
pub unsafe fn push_byte(s: &mut ~str, b: u8) {
2059-
reserve_at_least(s, s.len() + 1);
2059+
reserve_at_least(&mut *s, s.len() + 1);
20602060
do as_buf(*s) |buf, len| {
20612061
let buf: *mut u8 = ::cast::reinterpret_cast(&buf);
20622062
*ptr::mut_offset(buf, len) = b;
20632063
}
2064-
set_len(s, s.len() + 1);
2064+
set_len(&mut *s, s.len() + 1);
20652065
}
20662066

20672067
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
20682068
unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) {
2069-
reserve_at_least(s, s.len() + bytes.len());
2070-
for vec::each(bytes) |byte| { push_byte(s, *byte); }
2069+
reserve_at_least(&mut *s, s.len() + bytes.len());
2070+
for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); }
20712071
}
20722072

20732073
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
@@ -2090,7 +2090,7 @@ pub mod raw {
20902090

20912091
/// Sets the length of the string and adds the null terminator
20922092
pub unsafe fn set_len(v: &mut ~str, new_len: uint) {
2093-
let v: **vec::raw::VecRepr = cast::transmute(copy v);
2093+
let v: **vec::raw::VecRepr = cast::transmute(v);
20942094
let repr: *vec::raw::VecRepr = *v;
20952095
(*repr).unboxed.fill = new_len + 1u;
20962096
let null = ptr::mut_offset(ptr::mut_addr_of(&((*repr).unboxed.data)),

branches/try/src/libcore/task/spawn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn each_ancestor(list: &mut AncestorList,
187187
forward_blk: fn(TaskGroupInner) -> bool,
188188
last_generation: uint) -> bool {
189189
// Need to swap the list out to use it, to appease borrowck.
190-
let tmp_list = util::replace(list, AncestorList(None));
190+
let tmp_list = util::replace(&mut *list, AncestorList(None));
191191
let (coalesce_this, early_break) =
192192
iterate(&tmp_list, bail_opt, forward_blk, last_generation);
193193
// What should our next ancestor end up being?
@@ -289,7 +289,7 @@ fn each_ancestor(list: &mut AncestorList,
289289
fn with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>,
290290
blk: fn(TaskGroupInner) -> U) -> U {
291291
// If this trips, more likely the problem is 'blk' failed inside.
292-
let tmp_arc = option::swap_unwrap(parent_group);
292+
let tmp_arc = option::swap_unwrap(&mut *parent_group);
293293
let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
294294
*parent_group = move Some(move tmp_arc);
295295
move result
@@ -363,7 +363,7 @@ fn AutoNotify(chan: Chan<TaskResult>) -> AutoNotify {
363363

364364
fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
365365
is_member: bool) -> bool {
366-
let newstate = util::replace(state, None);
366+
let newstate = util::replace(&mut *state, None);
367367
// If 'None', the group was failing. Can't enlist.
368368
if newstate.is_some() {
369369
let group = option::unwrap(move newstate);
@@ -379,7 +379,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
379379
// NB: Runs in destructor/post-exit context. Can't 'fail'.
380380
fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
381381
is_member: bool) {
382-
let newstate = util::replace(state, None);
382+
let newstate = util::replace(&mut *state, None);
383383
// If 'None', already failing and we've already gotten a kill signal.
384384
if newstate.is_some() {
385385
let group = option::unwrap(move newstate);

branches/try/src/libcore/vec.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ pub fn shift<T>(v: &mut ~[T]) -> T unsafe {
472472
assert capacity(v) >= ln;
473473
// Pretend like we have the original length so we can use
474474
// the vector copy_memory to overwrite the hole we just made
475-
raw::set_len(v, ln);
475+
raw::set_len(&mut *v, ln);
476476

477477
// Memcopy the head element (the one we want) to the location we just
478478
// popped. For the moment it unsafely exists at both the head and last
@@ -487,7 +487,7 @@ pub fn shift<T>(v: &mut ~[T]) -> T unsafe {
487487
raw::copy_memory(init_slice, tail_slice, next_ln);
488488

489489
// Set the new length. Now the vector is back to normal
490-
raw::set_len(v, next_ln);
490+
raw::set_len(&mut *v, next_ln);
491491

492492
// Swap out the element we want from the end
493493
let vp = raw::to_mut_ptr(*v);
@@ -592,7 +592,7 @@ pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
592592
#[inline(always)]
593593
pub fn push<T>(v: &mut ~[T], initval: T) {
594594
unsafe {
595-
let repr: **raw::VecRepr = ::cast::transmute(copy v);
595+
let repr: **raw::VecRepr = ::cast::transmute(&mut *v);
596596
let fill = (**repr).unboxed.fill;
597597
if (**repr).unboxed.alloc > fill {
598598
push_fast(v, initval);
@@ -616,30 +616,30 @@ unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
616616

617617
#[inline(never)]
618618
fn push_slow<T>(v: &mut ~[T], initval: T) {
619-
reserve_at_least(v, v.len() + 1u);
619+
reserve_at_least(&mut *v, v.len() + 1u);
620620
unsafe { push_fast(v, initval) }
621621
}
622622

623623
#[inline(always)]
624624
pub fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T]) {
625-
reserve(v, v.len() + rhs.len());
625+
reserve(&mut *v, v.len() + rhs.len());
626626

627627
for uint::range(0u, rhs.len()) |i| {
628-
push(v, unsafe { raw::get(rhs, i) })
628+
push(&mut *v, unsafe { raw::get(rhs, i) })
629629
}
630630
}
631631

632632
#[inline(always)]
633633
pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) {
634634
let mut rhs = rhs; // FIXME(#3488)
635-
reserve(v, v.len() + rhs.len());
635+
reserve(&mut *v, v.len() + rhs.len());
636636
unsafe {
637637
do as_mut_buf(rhs) |p, len| {
638638
for uint::range(0, len) |i| {
639639
// FIXME #4204 Should be rusti::uninit() - don't need to zero
640640
let mut x = rusti::init();
641641
x <-> *ptr::mut_offset(p, i);
642-
push(v, x);
642+
push(&mut *v, x);
643643
}
644644
}
645645
raw::set_len(&mut rhs, 0);
@@ -657,7 +657,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
657657
let mut dropped = rusti::init();
658658
dropped <-> *ptr::mut_offset(p, i);
659659
}
660-
raw::set_len(v, newlen);
660+
raw::set_len(&mut *v, newlen);
661661
}
662662
}
663663
}
@@ -731,7 +731,7 @@ pub pure fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] {
731731
* * initval - The value for the new elements
732732
*/
733733
pub fn grow<T: Copy>(v: &mut ~[T], n: uint, initval: &T) {
734-
reserve_at_least(v, v.len() + n);
734+
reserve_at_least(&mut *v, v.len() + n);
735735
let mut i: uint = 0u;
736736

737737
while i < n {
@@ -754,7 +754,7 @@ pub fn grow<T: Copy>(v: &mut ~[T], n: uint, initval: &T) {
754754
* value
755755
*/
756756
pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) {
757-
reserve_at_least(v, v.len() + n);
757+
reserve_at_least(&mut *v, v.len() + n);
758758
let mut i: uint = 0u;
759759
while i < n {
760760
v.push(op(i));
@@ -772,7 +772,7 @@ pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) {
772772
*/
773773
pub fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) {
774774
let l = v.len();
775-
if index >= l { grow(v, index - l + 1u, initval); }
775+
if index >= l { grow(&mut *v, index - l + 1u, initval); }
776776
v[index] = val;
777777
}
778778

branches/try/src/libfuzzer/fuzzer.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) {
6969
&& !contains(path.to_str(), ~"compile-fail")
7070
&& !contains(path.to_str(), ~"build") {
7171
for os::list_dir_path(path).each |p| {
72-
find_rust_files(files, *p);
72+
find_rust_files(&mut *files, *p);
7373
}
7474
}
7575
}

branches/try/src/librustc/driver/driver.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn compile_upto(sess: Session, cfg: ast::crate_cfg,
291291
time(time_passes, ~"liveness checking", ||
292292
middle::liveness::check_crate(ty_cx, method_map, crate));
293293

294-
let (root_map, mutbl_map) =
294+
let (root_map, mutbl_map, write_guard_map) =
295295
time(time_passes, ~"borrow checking", ||
296296
middle::borrowck::check_crate(ty_cx, method_map,
297297
last_use_map, crate));
@@ -308,7 +308,8 @@ fn compile_upto(sess: Session, cfg: ast::crate_cfg,
308308
root_map: root_map,
309309
last_use_map: last_use_map,
310310
method_map: method_map,
311-
vtable_map: vtable_map};
311+
vtable_map: vtable_map,
312+
write_guard_map: write_guard_map};
312313

313314
time(time_passes, ~"translation", ||
314315
trans::base::trans_crate(sess, crate, ty_cx,

branches/try/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type maps = {
6060
last_use_map: middle::liveness::last_use_map,
6161
method_map: middle::typeck::method_map,
6262
vtable_map: middle::typeck::vtable_map,
63+
write_guard_map: middle::borrowck::write_guard_map,
6364
};
6465

6566
type decode_ctxt = @{

0 commit comments

Comments
 (0)