Skip to content

Commit 4ffafb2

Browse files
committed
---
yaml --- r: 126767 b: refs/heads/snap-stage3 c: 87ef2f3 h: refs/heads/master i: 126765: 18d79d0 126763: 203dffd 126759: 538176a 126751: 2a0270a v: v3
1 parent 787b184 commit 4ffafb2

File tree

6 files changed

+37
-65
lines changed

6 files changed

+37
-65
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: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e70ee120bf70d5b6195c2b355b9820a8609564cf
4+
refs/heads/snap-stage3: 87ef2f390b7e463ce3e64973abce02be8c7a9ceb
55
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn main() {
276276
277277
spawn(proc() {
278278
let numbers = rx.recv();
279-
println!("{:d}", numbers[num]);
279+
println!("{:d}", numbers[num as uint]);
280280
})
281281
}
282282
}

branches/snap-stage3/src/libcollections/priority_queue.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@ impl<T: Ord> Default for PriorityQueue<T> {
180180
}
181181

182182
impl<T: Ord> PriorityQueue<T> {
183+
/// Create an empty PriorityQueue
184+
pub fn new() -> PriorityQueue<T> { PriorityQueue{data: vec!(),} }
185+
186+
/// Create an empty PriorityQueue with capacity `capacity`
187+
pub fn with_capacity(capacity: uint) -> PriorityQueue<T> {
188+
PriorityQueue { data: Vec::with_capacity(capacity) }
189+
}
190+
191+
/// Create a PriorityQueue from a vector (heapify)
192+
pub fn from_vec(xs: Vec<T>) -> PriorityQueue<T> {
193+
let mut q = PriorityQueue{data: xs,};
194+
let mut n = q.len() / 2;
195+
while n > 0 {
196+
n -= 1;
197+
q.siftdown(n)
198+
}
199+
q
200+
}
201+
183202
/// An iterator visiting all values in underlying vector, in
184203
/// arbitrary order.
185204
pub fn iter<'a>(&'a self) -> Items<'a, T> {
@@ -278,25 +297,6 @@ impl<T: Ord> PriorityQueue<T> {
278297
q.into_vec()
279298
}
280299

281-
/// Create an empty PriorityQueue
282-
pub fn new() -> PriorityQueue<T> { PriorityQueue{data: vec!(),} }
283-
284-
/// Create an empty PriorityQueue with capacity `capacity`
285-
pub fn with_capacity(capacity: uint) -> PriorityQueue<T> {
286-
PriorityQueue { data: Vec::with_capacity(capacity) }
287-
}
288-
289-
/// Create a PriorityQueue from a vector (heapify)
290-
pub fn from_vec(xs: Vec<T>) -> PriorityQueue<T> {
291-
let mut q = PriorityQueue{data: xs,};
292-
let mut n = q.len() / 2;
293-
while n > 0 {
294-
n -= 1;
295-
q.siftdown(n)
296-
}
297-
q
298-
}
299-
300300
// The implementations of siftup and siftdown use unsafe blocks in
301301
// order to move an element out of the vector (leaving behind a
302302
// zeroed element), shift along the others and move it back into the

branches/snap-stage3/src/librustc/middle/trans/_match.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -892,12 +892,7 @@ fn insert_lllocals<'a>(mut bcx: &'a Block<'a>, bindings_map: &BindingsMap,
892892
TrByCopy(llbinding) => {
893893
let llval = Load(bcx, binding_info.llmatch);
894894
let datum = Datum::new(llval, binding_info.ty, Lvalue);
895-
call_lifetime_start(bcx, llbinding);
896895
bcx = datum.store_to(bcx, llbinding);
897-
match cs {
898-
Some(cs) => bcx.fcx.schedule_lifetime_end(cs, llbinding),
899-
_ => {}
900-
}
901896

902897
llbinding
903898
},
@@ -911,10 +906,7 @@ fn insert_lllocals<'a>(mut bcx: &'a Block<'a>, bindings_map: &BindingsMap,
911906

912907
let datum = Datum::new(llval, binding_info.ty, Lvalue);
913908
match cs {
914-
Some(cs) => {
915-
bcx.fcx.schedule_drop_and_zero_mem(cs, llval, binding_info.ty);
916-
bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch);
917-
}
909+
Some(cs) => bcx.fcx.schedule_drop_and_zero_mem(cs, llval, binding_info.ty),
918910
_ => {}
919911
}
920912

@@ -953,17 +945,9 @@ fn compile_guard<'a, 'b>(
953945
let val = unpack_datum!(bcx, expr::trans(bcx, guard_expr));
954946
let val = val.to_llbool(bcx);
955947

956-
for (_, &binding_info) in data.bindings_map.iter() {
957-
match binding_info.trmode {
958-
TrByCopy(llbinding) => call_lifetime_end(bcx, llbinding),
959-
_ => {}
960-
}
961-
}
962-
963948
return with_cond(bcx, Not(bcx, val), |bcx| {
964949
// Guard does not match: remove all bindings from the lllocals table
965950
for (_, &binding_info) in data.bindings_map.iter() {
966-
call_lifetime_end(bcx, binding_info.llmatch);
967951
bcx.fcx.lllocals.borrow_mut().remove(&binding_info.id);
968952
}
969953
match chk {
@@ -1004,7 +988,6 @@ fn compile_submatch<'a, 'b>(
1004988
let data = &m[0].data;
1005989
for &(ref ident, ref value_ptr) in m[0].bound_ptrs.iter() {
1006990
let llmatch = data.bindings_map.get(ident).llmatch;
1007-
call_lifetime_start(bcx, llmatch);
1008991
Store(bcx, *value_ptr, llmatch);
1009992
}
1010993
match data.arm.guard {
@@ -1311,24 +1294,24 @@ fn create_bindings_map(bcx: &Block, pat: Gc<ast::Pat>) -> BindingsMap {
13111294
match bm {
13121295
ast::BindByValue(_)
13131296
if !ty::type_moves_by_default(tcx, variable_ty) => {
1314-
llmatch = alloca_no_lifetime(bcx,
1297+
llmatch = alloca(bcx,
13151298
llvariable_ty.ptr_to(),
13161299
"__llmatch");
1317-
trmode = TrByCopy(alloca_no_lifetime(bcx,
1300+
trmode = TrByCopy(alloca(bcx,
13181301
llvariable_ty,
13191302
bcx.ident(ident).as_slice()));
13201303
}
13211304
ast::BindByValue(_) => {
13221305
// in this case, the final type of the variable will be T,
13231306
// but during matching we need to store a *T as explained
13241307
// above
1325-
llmatch = alloca_no_lifetime(bcx,
1308+
llmatch = alloca(bcx,
13261309
llvariable_ty.ptr_to(),
13271310
bcx.ident(ident).as_slice());
13281311
trmode = TrByMove;
13291312
}
13301313
ast::BindByRef(_) => {
1331-
llmatch = alloca_no_lifetime(bcx,
1314+
llmatch = alloca(bcx,
13321315
llvariable_ty,
13331316
bcx.ident(ident).as_slice());
13341317
trmode = TrByRef;

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,32 +1169,25 @@ pub fn alloc_ty(bcx: &Block, t: ty::t, name: &str) -> ValueRef {
11691169
}
11701170

11711171
pub fn alloca(cx: &Block, ty: Type, name: &str) -> ValueRef {
1172-
let p = alloca_no_lifetime(cx, ty, name);
1173-
call_lifetime_start(cx, p);
1174-
p
1172+
alloca_maybe_zeroed(cx, ty, name, false)
11751173
}
11761174

1177-
pub fn alloca_no_lifetime(cx: &Block, ty: Type, name: &str) -> ValueRef {
1175+
pub fn alloca_maybe_zeroed(cx: &Block, ty: Type, name: &str, zero: bool) -> ValueRef {
11781176
let _icx = push_ctxt("alloca");
11791177
if cx.unreachable.get() {
11801178
unsafe {
11811179
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
11821180
}
11831181
}
11841182
debuginfo::clear_source_location(cx.fcx);
1185-
Alloca(cx, ty, name)
1186-
}
1187-
1188-
pub fn alloca_zeroed(cx: &Block, ty: Type, name: &str) -> ValueRef {
1189-
if cx.unreachable.get() {
1190-
unsafe {
1191-
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
1192-
}
1183+
let p = Alloca(cx, ty, name);
1184+
if zero {
1185+
let b = cx.fcx.ccx.builder();
1186+
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
1187+
memzero(&b, p, ty);
1188+
} else {
1189+
call_lifetime_start(cx, p);
11931190
}
1194-
let p = alloca_no_lifetime(cx, ty, name);
1195-
let b = cx.fcx.ccx.builder();
1196-
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
1197-
memzero(&b, p, ty);
11981191
p
11991192
}
12001193

branches/snap-stage3/src/librustc/middle/trans/datum.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ pub fn lvalue_scratch_datum<'a, A>(bcx: &'a Block<'a>,
120120
*/
121121

122122
let llty = type_of::type_of(bcx.ccx(), ty);
123-
let scratch = if zero {
124-
alloca_zeroed(bcx, llty, name)
125-
} else {
126-
alloca(bcx, llty, name)
127-
};
123+
let scratch = alloca_maybe_zeroed(bcx, llty, name, zero);
128124

129125
// Subtle. Populate the scratch memory *before* scheduling cleanup.
130126
let bcx = populate(arg, bcx, scratch);
@@ -149,7 +145,7 @@ pub fn rvalue_scratch_datum(bcx: &Block,
149145
*/
150146

151147
let llty = type_of::type_of(bcx.ccx(), ty);
152-
let scratch = alloca(bcx, llty, name);
148+
let scratch = alloca_maybe_zeroed(bcx, llty, name, false);
153149
Datum::new(scratch, ty, Rvalue::new(ByRef))
154150
}
155151

0 commit comments

Comments
 (0)