Skip to content

Commit 389aff3

Browse files
committed
Make the cleanup tag in resource types a u8
Closes #1184
1 parent 5458da0 commit 389aff3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/comp/middle/trans/base.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
139139
ty::ty_iface(_, _) { T_opaque_iface(cx) }
140140
ty::ty_res(_, sub, tps) {
141141
let sub1 = ty::substitute_type_params(cx.tcx, tps, sub);
142-
// FIXME #1184: Resource flag is larger than necessary
143-
ret T_struct([cx.int_type, type_of(cx, sub1)]);
142+
ret T_struct([T_i8(), type_of(cx, sub1)]);
144143
}
145144
ty::ty_param(_, _) { T_typaram(cx.tn) }
146145
ty::ty_send_type | ty::ty_type { T_ptr(cx.tydesc_type) }
@@ -1050,8 +1049,7 @@ fn trans_res_drop(bcx: block, rs: ValueRef, did: ast::def_id,
10501049
Call(bcx, dtor_addr, args + [val_cast]);
10511050

10521051
bcx = drop_ty(bcx, valptr, inner_t_s);
1053-
// FIXME #1184: Resource flag is larger than necessary
1054-
Store(bcx, C_int(ccx, 0), drop_flag);
1052+
Store(bcx, C_u8(0u), drop_flag);
10551053
bcx
10561054
}
10571055
}
@@ -1479,9 +1477,10 @@ fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
14791477

14801478
fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
14811479
n_bytes: ValueRef) -> result {
1482-
// FIXME: Provide LLVM with better alignment information when the alignment
1483-
// is statically known (it must be nothing more than a constant int, or
1484-
// LLVM complains -- not even a constant element of a tydesc works).
1480+
// FIXME: Provide LLVM with better alignment information when the
1481+
// alignment is statically known (it must be nothing more than a constant
1482+
// int, or LLVM complains -- not even a constant element of a tydesc
1483+
// works).
14851484

14861485
let ccx = cx.ccx();
14871486
let key = alt ccx.sess.targ_cfg.arch {
@@ -1493,7 +1492,6 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
14931492
let memmove = i.get(key);
14941493
let src_ptr = PointerCast(cx, src, T_ptr(T_i8()));
14951494
let dst_ptr = PointerCast(cx, dst, T_ptr(T_i8()));
1496-
// FIXME #1184: Resource flag is larger than necessary
14971495
let size = IntCast(cx, n_bytes, ccx.int_type);
14981496
let align = C_i32(1i32);
14991497
let volatile = C_bool(false);
@@ -4114,7 +4112,8 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
41144112
let bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
41154113
let fty = node_id_type(bcx, ctor_id);
41164114
let arg_t = ty::ty_fn_args(fty)[0].ty;
4117-
let tup_t = ty::mk_tup(ccx.tcx, [ty::mk_int(ccx.tcx), arg_t]);
4115+
let tup_t = ty::mk_tup(ccx.tcx, [ty::mk_mach_uint(ccx.tcx, ast::ty_u8),
4116+
arg_t]);
41184117
let arg = alt fcx.llargs.find(dtor.inputs[0].id) {
41194118
some(local_mem(x)) { x }
41204119
_ { ccx.sess.bug("Someone forgot to document an invariant \
@@ -4130,8 +4129,7 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
41304129
bcx = memmove_ty(bcx, dst, arg, arg_t);
41314130
let flag = GEP_tup_like(bcx, tup_t, llretptr, [0, 0]);
41324131
bcx = flag.bcx;
4133-
// FIXME #1184: Resource flag is larger than necessary
4134-
let one = C_int(ccx, 1);
4132+
let one = C_u8(1u);
41354133
Store(bcx, one, flag.val);
41364134
build_return(bcx);
41374135
finish_fn(fcx, lltop);

0 commit comments

Comments
 (0)