Skip to content

Commit 7dd24af

Browse files
committed
---
yaml --- r: 13710 b: refs/heads/master c: bacf9e9 h: refs/heads/master v: v3
1 parent 6f95be0 commit 7dd24af

File tree

3 files changed

+28
-39
lines changed

3 files changed

+28
-39
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: b9d3ad0736dfc3a69f50155d2251f195de54b6c6
2+
refs/heads/master: bacf9e9887872a40d16798813aa66b6916cc6a4e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/trans/base.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,16 @@ fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) ->
398398
ret {box: box, body: body};
399399
}
400400

401-
fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
402-
malloc_general_dyn(bcx, t, heap_shared,
401+
fn malloc_general(bcx: block, t: ty::t, heap: heap) ->
402+
{box: ValueRef, body: ValueRef} {
403+
malloc_general_dyn(bcx, t, heap,
403404
llsize_of(bcx.ccx(), type_of(bcx.ccx(), t)))
404405
}
405-
fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
406-
malloc_general_dyn(bcx, t, heap_exchange,
407-
llsize_of(bcx.ccx(), type_of(bcx.ccx(), t)))
406+
fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
407+
malloc_general(bcx, t, heap_shared)
408408
}
409-
410-
fn malloc_unique_dyn(bcx: block, t: ty::t, size: ValueRef
411-
) -> {box: ValueRef, body: ValueRef} {
412-
malloc_general_dyn(bcx, t, heap_exchange, size)
409+
fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
410+
malloc_general(bcx, t, heap_exchange)
413411
}
414412

415413
// Type descriptor and type glue stuff
@@ -1487,6 +1485,19 @@ fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block {
14871485
}
14881486
}
14891487

1488+
1489+
fn trans_boxed_expr(bcx: block, contents: @ast::expr,
1490+
t: ty::t, heap: heap,
1491+
dest: dest) -> block {
1492+
let _icx = bcx.insn_ctxt("trans_boxed_expr");
1493+
let {box, body} = malloc_general(bcx, t, heap);
1494+
add_clean_free(bcx, box, true);
1495+
let bcx = trans_expr_save_in(bcx, contents, body);
1496+
revoke_clean(bcx, box);
1497+
ret store_in_dest(bcx, box, dest);
1498+
}
1499+
1500+
14901501
fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
14911502
un_expr: @ast::expr, dest: dest) -> block {
14921503
let _icx = bcx.insn_ctxt("trans_unary");
@@ -1509,35 +1520,25 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
15091520
alt op {
15101521
ast::not {
15111522
let {bcx, val} = trans_temp_expr(bcx, e);
1512-
ret store_in_dest(bcx, Not(bcx, val), dest);
1523+
store_in_dest(bcx, Not(bcx, val), dest)
15131524
}
15141525
ast::neg {
15151526
let {bcx, val} = trans_temp_expr(bcx, e);
15161527
let neg = if ty::type_is_fp(e_ty) {
15171528
FNeg(bcx, val)
15181529
} else { Neg(bcx, val) };
1519-
ret store_in_dest(bcx, neg, dest);
1530+
store_in_dest(bcx, neg, dest)
15201531
}
15211532
ast::box(_) {
1522-
let mut {box, body} = malloc_boxed(bcx, e_ty);
1523-
add_clean_free(bcx, box, false);
1524-
// Cast the body type to the type of the value. This is needed to
1525-
// make enums work, since enums have a different LLVM type depending
1526-
// on whether they're boxed or not
1527-
let ccx = bcx.ccx();
1528-
let llety = T_ptr(type_of(ccx, e_ty));
1529-
body = PointerCast(bcx, body, llety);
1530-
let bcx = trans_expr_save_in(bcx, e, body);
1531-
revoke_clean(bcx, box);
1532-
ret store_in_dest(bcx, box, dest);
1533+
trans_boxed_expr(bcx, e, e_ty, heap_shared, dest)
15331534
}
15341535
ast::uniq(_) {
1535-
ret uniq::trans_uniq(bcx, e, un_expr.id, dest);
1536+
trans_boxed_expr(bcx, e, e_ty, heap_exchange, dest)
15361537
}
15371538
ast::deref {
15381539
bcx.sess().bug("deref expressions should have been \
15391540
translated using trans_lval(), not \
1540-
trans_unary()");
1541+
trans_unary()")
15411542
}
15421543
}
15431544
}

trunk/src/rustc/middle/trans/uniq.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,7 @@ import build::*;
55
import base::*;
66
import shape::llsize_of;
77

8-
export trans_uniq, make_free_glue, autoderef, duplicate;
9-
10-
fn trans_uniq(bcx: block, contents: @ast::expr,
11-
node_id: ast::node_id, dest: dest) -> block {
12-
let _icx = bcx.insn_ctxt("uniq::trans_uniq");
13-
let uniq_ty = node_id_type(bcx, node_id);
14-
let contents_ty = content_ty(uniq_ty);
15-
let {box, body} = malloc_unique(bcx, contents_ty);
16-
add_clean_free(bcx, box, true);
17-
let bcx = trans_expr_save_in(bcx, contents, body);
18-
revoke_clean(bcx, box);
19-
ret store_in_dest(bcx, box, dest);
20-
}
8+
export make_free_glue, autoderef, duplicate;
219

2210
fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t)
2311
-> block {
@@ -64,4 +52,4 @@ fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result {
6452
Store(bcx, td, dst_tydesc_ptr);
6553

6654
ret rslt(bcx, dst_box);
67-
}
55+
}

0 commit comments

Comments
 (0)