Skip to content

Commit e72bbed

Browse files
committed
---
yaml --- r: 4771 b: refs/heads/master c: 702fe5c h: refs/heads/master i: 4769: 15bc573 4767: 1c784cc v: v3
1 parent 62b8551 commit e72bbed

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3aab46b0209adad0fd6f24b5b94b6401b13257b7
2+
refs/heads/master: 702fe5cdac4f6852689c1e74c3ca95af249f4285

trunk/src/comp/middle/trans.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,17 @@ fn alloca(cx: &@block_ctxt, t: TypeRef) -> ValueRef {
466466
}
467467

468468
fn array_alloca(cx: &@block_ctxt, t: TypeRef, n: ValueRef) -> ValueRef {
469+
let builder = new_builder(cx.fcx.lldynamicallocas);
469470
alt bcx_fcx(cx).llobstacktoken {
470471
none. {
472+
let dynastack_mark = bcx_ccx(cx).upcalls.dynastack_mark;
473+
let lltaskptr = bcx_fcx(cx).lltaskptr;
471474
bcx_fcx(cx).llobstacktoken =
472-
some(cx.build.Call(bcx_ccx(cx).upcalls.dynastack_mark,
473-
~[bcx_fcx(cx).lltaskptr]));
475+
some(builder.Call(dynastack_mark, ~[lltaskptr]));
474476
}
475477
some(_) { /* no-op */ }
476478
}
477-
ret new_builder(cx.fcx.lldynamicallocas).ArrayAlloca(t, n);
479+
ret builder.ArrayAlloca(t, n);
478480
}
479481

480482

@@ -1266,6 +1268,8 @@ fn make_copy_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t) {
12661268
bcx = duplicate_heap_parts_if_necessary(cx, v, t).bcx;
12671269
bcx = iter_structural_ty(bcx, v, t, bind copy_ty(_, _, _)).bcx;
12681270
} else { bcx = cx; }
1271+
1272+
trans_fn_cleanups(bcx);
12691273
bcx.build.RetVoid();
12701274
}
12711275

@@ -1371,7 +1375,9 @@ fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
13711375
}
13721376
_ { rslt(cx, C_nil()) }
13731377
};
1374-
rs.bcx.build.RetVoid();
1378+
1379+
let bcx = trans_fn_cleanups(rs.bcx);
1380+
bcx.build.RetVoid();
13751381
}
13761382

13771383
fn maybe_free_ivec_heap_part(cx: &@block_ctxt, v0: ValueRef, unit_ty: ty::t)
@@ -1439,7 +1445,9 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
14391445
} else { rslt(cx, C_nil()) }
14401446
}
14411447
};
1442-
rs.bcx.build.RetVoid();
1448+
1449+
let bcx = trans_fn_cleanups(rs.bcx);
1450+
bcx.build.RetVoid();
14431451
}
14441452

14451453
fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
@@ -3719,7 +3727,8 @@ fn trans_for_each(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr,
37193727

37203728
if !r.bcx.build.is_terminated() {
37213729
// if terminated is true, no need for the ret-fail
3722-
r.bcx.build.RetVoid();
3730+
let bcx = trans_fn_cleanups(r.bcx);
3731+
bcx.build.RetVoid();
37233732
}
37243733

37253734
// Step 3: Call iter passing [lliterbody, llenv], plus other args.
@@ -5439,6 +5448,7 @@ fn trans_ret(cx: &@block_ctxt, e: &option::t<@ast::expr>) -> result {
54395448
parent_none. { more_cleanups = false; }
54405449
}
54415450
}
5451+
bcx = trans_fn_cleanups(bcx);
54425452
bcx.build.RetVoid();
54435453
ret rslt(new_sub_block_ctxt(bcx, "ret.unreachable"), C_nil());
54445454
}
@@ -5600,6 +5610,18 @@ fn trans_block_cleanups(cx: &@block_ctxt, cleanup_cx: &@block_ctxt) ->
56005610
ret bcx;
56015611
}
56025612

5613+
fn trans_fn_cleanups(bcx: &@block_ctxt) -> @block_ctxt {
5614+
alt bcx_fcx(bcx).llobstacktoken {
5615+
some(lltoken_) {
5616+
let lltoken = lltoken_; // satisfy alias checker
5617+
bcx.build.Call(bcx_ccx(bcx).upcalls.dynastack_free,
5618+
~[bcx_fcx(bcx).lltaskptr, lltoken]);
5619+
}
5620+
none. { /* nothing to do */ }
5621+
}
5622+
ret bcx;
5623+
}
5624+
56035625
iter block_locals(b: &ast::blk) -> @ast::local {
56045626
// FIXME: putting from inside an iter block doesn't work, so we can't
56055627
// use the index here.
@@ -6048,6 +6070,7 @@ fn trans_closure(bcx_maybe: &option::t<@block_ctxt>,
60486070
if !is_terminated(bcx) {
60496071
// FIXME: until LLVM has a unit type, we are moving around
60506072
// C_nil values rather than their void type.
6073+
bcx = trans_fn_cleanups(bcx);
60516074
bcx.build.RetVoid();
60526075
}
60536076

@@ -6204,6 +6227,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
62046227
i += 1u;
62056228
}
62066229
bcx = trans_block_cleanups(bcx, find_scope_cx(bcx));
6230+
bcx = trans_fn_cleanups(bcx);
62076231
bcx.build.RetVoid();
62086232
finish_fn(fcx, lltop);
62096233
}

trunk/src/rt/rust_obstack.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ rust_obstack_chunk::free(void *ptr) {
4444
uint8_t *p = (uint8_t *)ptr;
4545
if (p < data || p >= data + size)
4646
return false;
47-
assert(p < data + alen);
47+
assert(p <= data + alen);
4848
alen = (size_t)(p - data);
4949
return true;
5050
}
@@ -71,7 +71,8 @@ rust_obstack::alloc(size_t len) {
7171
if (!chunk)
7272
return alloc_new(len);
7373
void *ptr = chunk->alloc(len);
74-
return ptr ? ptr : alloc_new(len);
74+
ptr = ptr ? ptr : alloc_new(len);
75+
return ptr;
7576
}
7677

7778
void

0 commit comments

Comments
 (0)