Skip to content

Commit a9d241d

Browse files
committed
---
yaml --- r: 114396 b: refs/heads/master c: 6787e22 h: refs/heads/master v: v3
1 parent 460aff0 commit a9d241d

File tree

32 files changed

+86
-483
lines changed

32 files changed

+86
-483
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9411cec580932f38e0e017245ce28ad2ff8e936c
2+
refs/heads/master: 6787e22c0825f0d828986c1e5c9fc32b785e431e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/doc/guide-ffi.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ are:
493493
* `rust-intrinsic`
494494
* `system`
495495
* `C`
496-
* `win64`
497496

498497
Most of the abis in this list are self-explanatory, but the `system` abi may
499498
seem a little odd. This constraint selects whatever the appropriate ABI is for

trunk/src/liballoc/heap.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// FIXME: #13994: port to the sized deallocation API when available
12-
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias` and `nonnull`
12+
// FIXME: #13996: need a way to mark the `allocate` and `reallocate` return values as `noalias`
1313

1414
use core::intrinsics::{abort, cttz32};
1515
use core::option::{None, Option};
@@ -119,8 +119,14 @@ pub fn stats_print() {
119119
/// The allocator for unique pointers.
120120
#[cfg(not(test))]
121121
#[lang="exchange_malloc"]
122+
#[inline(always)]
123+
pub unsafe fn exchange_malloc_(size: uint, align: uint) -> *mut u8 {
124+
exchange_malloc(size, align)
125+
}
126+
127+
/// The allocator for unique pointers.
122128
#[inline]
123-
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
129+
pub unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
124130
// The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
125131
// allocations can point to this `static`. It would be incorrect to use a null
126132
// pointer, due to enums assuming types like unique pointers are never null.
@@ -133,20 +139,14 @@ unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
133139
}
134140
}
135141

136-
#[cfg(not(test), stage0)]
142+
#[cfg(not(test))]
137143
#[lang="exchange_free"]
138144
#[inline]
145+
// FIXME: #13994 (rustc should pass align and size here)
139146
unsafe fn exchange_free(ptr: *mut u8) {
140147
deallocate(ptr, 0, 8);
141148
}
142149

143-
#[cfg(not(test), not(stage0))]
144-
#[lang="exchange_free"]
145-
#[inline]
146-
unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
147-
deallocate(ptr, size, align);
148-
}
149-
150150
// FIXME: #7496
151151
#[cfg(not(test))]
152152
#[lang="closure_exchange_malloc"]
@@ -167,16 +167,16 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uin
167167
#[doc(hidden)]
168168
#[deprecated]
169169
#[cfg(not(test))]
170-
pub unsafe extern "C" fn rust_allocate(size: uint, align: uint) -> *mut u8 {
171-
allocate(size, align)
170+
pub unsafe extern "C" fn rust_malloc(size: uint, align: uint) -> *mut u8 {
171+
exchange_malloc(size, align)
172172
}
173173

174174
// hack for libcore
175175
#[no_mangle]
176176
#[doc(hidden)]
177177
#[deprecated]
178178
#[cfg(not(test))]
179-
pub unsafe extern "C" fn rust_deallocate(ptr: *mut u8, size: uint, align: uint) {
179+
pub unsafe extern "C" fn rust_free(ptr: *mut u8, size: uint, align: uint) {
180180
deallocate(ptr, size, align)
181181
}
182182

trunk/src/libarena/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::mem;
3838
use std::num;
3939
use std::ptr::read;
4040
use std::rc::Rc;
41-
use std::rt::heap::allocate;
41+
use std::rt::heap::exchange_malloc;
4242

4343
// The way arena uses arrays is really deeply awful. The arrays are
4444
// allocated, and have capacities reserved, but the fill for the array
@@ -358,7 +358,8 @@ impl<T> TypedArenaChunk<T> {
358358
size = size.checked_add(&elems_size).unwrap();
359359

360360
let mut chunk = unsafe {
361-
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>());
361+
let chunk = exchange_malloc(size,
362+
mem::min_align_of::<TypedArenaChunk<T>>());
362363
let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
363364
mem::overwrite(&mut chunk.next, next);
364365
chunk

trunk/src/libcore/should_not_exist.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ use str::StrSlice;
4444

4545
#[allow(ctypes)]
4646
extern {
47-
fn rust_allocate(size: uint, align: uint) -> *u8;
48-
fn rust_deallocate(ptr: *u8, size: uint, align: uint);
47+
fn rust_malloc(size: uint, align: uint) -> *u8;
48+
fn rust_free(ptr: *u8, size: uint, align: uint);
4949
}
5050

5151
unsafe fn alloc(cap: uint) -> *mut Vec<()> {
5252
let cap = cap.checked_add(&mem::size_of::<Vec<()>>()).unwrap();
5353
// this should use the real alignment, but the new representation will take care of that
54-
let ret = rust_allocate(cap, 8) as *mut Vec<()>;
54+
let ret = rust_malloc(cap, 8) as *mut Vec<()>;
5555
if ret.is_null() {
5656
intrinsics::abort();
5757
}
@@ -119,7 +119,7 @@ impl FromIterator<char> for ~str {
119119
&(*ptr).data,
120120
len);
121121
// FIXME: #13994: port to the sized deallocation API when available
122-
rust_deallocate(ptr as *u8, 0, 8);
122+
rust_free(ptr as *u8, 0, 8);
123123
mem::forget(ret);
124124
ret = mem::transmute(ptr2);
125125
ptr = ptr2;
@@ -191,7 +191,7 @@ impl<A: Clone> Clone for ~[A] {
191191
for j in range(0, *i as int) {
192192
ptr::read(&*p.offset(j));
193193
}
194-
rust_deallocate(ret as *u8, 0, 8);
194+
rust_free(ret as *u8, 0, 8);
195195
});
196196
mem::transmute(ret)
197197
}

trunk/src/libcore/str.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,6 @@ pub trait StrSlice<'a> {
11121112
///
11131113
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
11141114
/// assert_eq!(v, vec!["lion", "", "tiger", "leopard"]);
1115-
///
1116-
/// let v: Vec<&str> = "".split('X').collect();
1117-
/// assert_eq!(v, vec![""]);
11181115
/// ```
11191116
fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplits<'a, Sep>;
11201117

@@ -1133,12 +1130,6 @@ pub trait StrSlice<'a> {
11331130
///
11341131
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn('X', 2).collect();
11351132
/// assert_eq!(v, vec!["lion", "", "tigerXleopard"]);
1136-
///
1137-
/// let v: Vec<&str> = "abcXdef".splitn('X', 0).collect();
1138-
/// assert_eq!(v, vec!["abcXdef"]);
1139-
///
1140-
/// let v: Vec<&str> = "".splitn('X', 1).collect();
1141-
/// assert_eq!(v, vec![""]);
11421133
/// ```
11431134
fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitsN<'a, Sep>;
11441135

trunk/src/librustc/middle/check_match.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
247247
_ => *r.get(0)
248248
}
249249
}
250-
None if v.len() == 0 => return not_useful,
251250
None => v[0]
252251
};
253252
let left_ty = if real_pat.id == 0 { ty::mk_nil() }
@@ -342,10 +341,8 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
342341
let ms = m.iter().filter_map(|r| {
343342
specialize(cx, r.as_slice(), &ctor, arity, lty)
344343
}).collect::<matrix>();
345-
let could_be_useful = match specialize(cx, v, &ctor, arity, lty) {
346-
Some(v) => is_useful(cx, &ms, v.as_slice()),
347-
None => return not_useful,
348-
};
344+
let could_be_useful = is_useful(
345+
cx, &ms, specialize(cx, v, &ctor, arity, lty).unwrap().as_slice());
349346
match could_be_useful {
350347
useful_ => useful(lty, ctor),
351348
u => u,

trunk/src/librustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ impl<'a> Resolver<'a> {
20402040
return;
20412041
}
20422042

2043-
let imports = module.imports.borrow();
2043+
let mut imports = module.imports.borrow_mut();
20442044
let import_count = imports.len();
20452045
while module.resolved_import_count.get() < import_count {
20462046
let import_index = module.resolved_import_count.get();

trunk/src/librustc/middle/trans/cleanup.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,13 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> {
278278
fn schedule_free_value(&self,
279279
cleanup_scope: ScopeId,
280280
val: ValueRef,
281-
heap: Heap,
282-
content_ty: ty::t) {
281+
heap: Heap) {
283282
/*!
284283
* Schedules a call to `free(val)`. Note that this is a shallow
285284
* operation.
286285
*/
287286

288-
let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty };
287+
let drop = box FreeValue { ptr: val, heap: heap };
289288

290289
debug!("schedule_free_value({:?}, val={}, heap={:?})",
291290
cleanup_scope,
@@ -848,7 +847,6 @@ pub enum Heap {
848847
pub struct FreeValue {
849848
ptr: ValueRef,
850849
heap: Heap,
851-
content_ty: ty::t
852850
}
853851

854852
impl Cleanup for FreeValue {
@@ -862,7 +860,7 @@ impl Cleanup for FreeValue {
862860
glue::trans_free(bcx, self.ptr)
863861
}
864862
HeapExchange => {
865-
glue::trans_exchange_free_ty(bcx, self.ptr, self.content_ty)
863+
glue::trans_exchange_free(bcx, self.ptr)
866864
}
867865
}
868866
}
@@ -933,8 +931,7 @@ pub trait CleanupMethods<'a> {
933931
fn schedule_free_value(&self,
934932
cleanup_scope: ScopeId,
935933
val: ValueRef,
936-
heap: Heap,
937-
content_ty: ty::t);
934+
heap: Heap);
938935
fn schedule_clean(&self,
939936
cleanup_scope: ScopeId,
940937
cleanup: Box<Cleanup>);

trunk/src/librustc/middle/trans/expr.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ fn trans_uniq_expr<'a>(bcx: &'a Block<'a>,
11831183
} else {
11841184
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
11851185
fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
1186-
val, cleanup::HeapExchange, contents_ty);
1186+
val, cleanup::HeapExchange);
11871187
let bcx = trans_into(bcx, contents, SaveIn(val));
11881188
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
11891189
bcx
@@ -1205,7 +1205,7 @@ fn trans_managed_expr<'a>(bcx: &'a Block<'a>,
12051205

12061206
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
12071207
fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
1208-
bx, cleanup::HeapManaged, contents_ty);
1208+
bx, cleanup::HeapManaged);
12091209
let bcx = trans_into(bcx, contents, SaveIn(body));
12101210
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
12111211
immediate_rvalue_bcx(bcx, bx, box_ty).to_expr_datumblock()
@@ -1789,14 +1789,13 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
17891789
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
17901790
let ptr = Load(bcx, datum.val);
17911791
if !type_is_zero_size(bcx.ccx(), content_ty) {
1792-
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange, content_ty);
1792+
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange);
17931793
}
17941794
}
17951795
RvalueExpr(Rvalue { mode: ByValue }) => {
17961796
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
17971797
if !type_is_zero_size(bcx.ccx(), content_ty) {
1798-
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange,
1799-
content_ty);
1798+
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange);
18001799
}
18011800
}
18021801
LvalueExpr => { }

trunk/src/librustc/middle/trans/glue.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,15 @@ pub fn trans_free<'a>(cx: &'a Block<'a>, v: ValueRef) -> &'a Block<'a> {
5050
Some(expr::Ignore)).bcx
5151
}
5252

53-
fn trans_exchange_free<'a>(cx: &'a Block<'a>, v: ValueRef, size: u64,
54-
align: u64) -> &'a Block<'a> {
53+
pub fn trans_exchange_free<'a>(cx: &'a Block<'a>, v: ValueRef)
54+
-> &'a Block<'a> {
5555
let _icx = push_ctxt("trans_exchange_free");
56-
let ccx = cx.ccx();
5756
callee::trans_lang_call(cx,
5857
langcall(cx, None, "", ExchangeFreeFnLangItem),
59-
[PointerCast(cx, v, Type::i8p(ccx)), C_uint(ccx, size as uint), C_uint(ccx, align as uint)],
58+
[PointerCast(cx, v, Type::i8p(cx.ccx()))],
6059
Some(expr::Ignore)).bcx
6160
}
6261

63-
pub fn trans_exchange_free_ty<'a>(bcx: &'a Block<'a>, ptr: ValueRef,
64-
content_ty: ty::t) -> &'a Block<'a> {
65-
let sizing_type = sizing_type_of(bcx.ccx(), content_ty);
66-
let content_size = llsize_of_alloc(bcx.ccx(), sizing_type);
67-
68-
// `Box<ZeroSizeType>` does not allocate.
69-
if content_size != 0 {
70-
let content_align = llalign_of_min(bcx.ccx(), sizing_type);
71-
trans_exchange_free(bcx, ptr, content_size, content_align)
72-
} else {
73-
bcx
74-
}
75-
}
76-
7762
pub fn take_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t)
7863
-> &'a Block<'a> {
7964
// NB: v is an *alias* of type t here, not a direct value.
@@ -102,15 +87,17 @@ fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t {
10287
ty::ty_vec(_, None) | ty::ty_str => t,
10388
_ => {
10489
let llty = sizing_type_of(ccx, typ);
105-
// `Box<ZeroSizeType>` does not allocate.
90+
// Unique boxes do not allocate for zero-size types. The standard
91+
// library may assume that `free` is never called on the pointer
92+
// returned for `Box<ZeroSizeType>`.
10693
if llsize_of_alloc(ccx, llty) == 0 {
10794
ty::mk_i8()
10895
} else {
10996
ty::mk_uniq(tcx, ty::mk_i8())
11097
}
98+
}
99+
}
111100
}
112-
}
113-
}
114101
_ => t
115102
}
116103
}
@@ -298,22 +285,20 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
298285
ty::ty_vec(mt, None) => {
299286
with_cond(bcx, not_null, |bcx| {
300287
let bcx = tvec::make_drop_glue_unboxed(bcx, llbox, mt.ty);
301-
// FIXME: #13994: the old `Box<[T]>` will not support sized deallocation
302-
trans_exchange_free(bcx, llbox, 0, 8)
288+
trans_exchange_free(bcx, llbox)
303289
})
304290
}
305291
ty::ty_str => {
306292
with_cond(bcx, not_null, |bcx| {
307293
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
308294
let bcx = tvec::make_drop_glue_unboxed(bcx, llbox, unit_ty);
309-
// FIXME: #13994: the old `Box<str>` will not support sized deallocation
310-
trans_exchange_free(bcx, llbox, 0, 8)
295+
trans_exchange_free(bcx, llbox)
311296
})
312297
}
313298
_ => {
314299
with_cond(bcx, not_null, |bcx| {
315300
let bcx = drop_ty(bcx, llbox, content_ty);
316-
trans_exchange_free_ty(bcx, llbox, content_ty)
301+
trans_exchange_free(bcx, llbox)
317302
})
318303
}
319304
}
@@ -355,8 +340,7 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
355340
Call(bcx, dtor, [PointerCast(bcx, cdata, Type::i8p(bcx.ccx()))], []);
356341

357342
// Free the environment itself
358-
// FIXME: #13994: pass align and size here
359-
trans_exchange_free(bcx, env, 0, 8)
343+
trans_exchange_free(bcx, env)
360344
})
361345
}
362346
_ => {

trunk/src/librustc/middle/trans/tvec.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,8 @@ pub fn trans_uniq_vstore<'a>(bcx: &'a Block<'a>,
287287
// Create a temporary scope lest execution should fail while
288288
// constructing the vector.
289289
let temp_scope = fcx.push_custom_cleanup_scope();
290-
291-
// FIXME: #13994: the old `Box<[T]> will not support sized deallocation, this is a placeholder
292-
let content_ty = vt.unit_ty;
293290
fcx.schedule_free_value(cleanup::CustomScope(temp_scope),
294-
val, cleanup::HeapExchange, content_ty);
291+
val, cleanup::HeapExchange);
295292

296293
let dataptr = get_dataptr(bcx, val);
297294

trunk/src/librustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,9 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
433433
}
434434
}))
435435
}
436-
this.tcx().sess.span_err(path.span,
436+
this.tcx().sess.span_bug(path.span,
437437
"not enough type parameters \
438-
supplied to `Box<T>`");
439-
Some(ty::mk_err())
438+
supplied to `Box<T>`")
440439
}
441440
_ => None
442441
}

0 commit comments

Comments
 (0)