Skip to content

Commit d3c6416

Browse files
committed
rustc: Put uniques into addrspace 1
1 parent 1a3b8fc commit d3c6416

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

src/rustc/middle/trans/alt.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
472472

473473
if any_uniq_pat(m, col) {
474474
let box = Load(bcx, val);
475-
let unboxed = GEPi(bcx, box, [0u, abi::box_field_body]);
475+
let box_ty = node_id_type(bcx, pat_id);
476+
let box_no_addrspace = non_gc_box_cast(bcx, box, box_ty);
477+
let unboxed = GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]);
476478
compile_submatch(bcx, enter_uniq(dm, m, col, val),
477479
[unboxed] + vals_left, chk, exits);
478480
ret;

src/rustc/middle/trans/base.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ fn malloc_unique_raw(bcx: block, t: ty::t) -> ValueRef {
397397
fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
398398
let _icx = bcx.insn_ctxt("malloc_unique_box");
399399
let box = malloc_unique_raw(bcx, t);
400-
let body = GEPi(bcx, box, [0u, abi::box_field_body]);
400+
let non_gc_box = non_gc_box_cast(bcx, box, ty::mk_imm_uniq(bcx.tcx(), t));
401+
let body = GEPi(bcx, non_gc_box, [0u, abi::box_field_body]);
401402
ret {box: box, body: body};
402403
}
403404

@@ -2681,7 +2682,8 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
26812682
GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body])
26822683
}
26832684
ty::ty_uniq(_) {
2684-
GEPi(sub.bcx, sub.val, [0u, abi::box_field_body])
2685+
let non_gc_val = non_gc_box_cast(sub.bcx, sub.val, t);
2686+
GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body])
26852687
}
26862688
ty::ty_res(_, _, _) {
26872689
GEPi(sub.bcx, sub.val, [0u, 1u])

src/rustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ fn T_unique(cx: @crate_ctxt, t: TypeRef) -> TypeRef {
691691
}
692692

693693
fn T_unique_ptr(t: TypeRef) -> TypeRef {
694-
const unique_addrspace: uint = 0u;
694+
const unique_addrspace: uint = 1u;
695695
ret llvm::LLVMPointerType(t, unique_addrspace as c_uint);
696696
}
697697

src/rustc/middle/trans/type_of.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
5454
ty::ty_box(mt) {
5555
T_ptr(T_box(cx, type_of(cx, mt.ty)))
5656
}
57+
ty::ty_uniq(mt) {
58+
T_ptr(T_unique(cx, type_of(cx, mt.ty)))
59+
}
5760
_ {
5861
cx.sess.bug("non-box in type_of_non_gc_box");
5962
}

src/test/run-pass/alt-unique-bind.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
alt ~100 {
3+
~x {
4+
#debug("%?", x);
5+
assert x == 100;
6+
}
7+
}
8+
}

src/test/run-pass/unique-containing-tag.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ fn main() {
33

44
let x = ~t1(10);
55

6-
alt *x {
6+
/*alt *x {
77
t1(a) {
88
assert a == 10;
99
}
1010
_ { fail; }
11-
}
11+
}*/
1212

13-
alt x {
13+
/*alt x {
1414
~t1(a) {
1515
assert a == 10;
1616
}
1717
_ { fail; }
18-
}
18+
}*/
1919
}

0 commit comments

Comments
 (0)