Skip to content

Commit 44540e8

Browse files
committed
---
yaml --- r: 2353 b: refs/heads/master c: 898e089 h: refs/heads/master i: 2351: ffb19d3 v: v3
1 parent dc3a48d commit 44540e8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
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: cdb68224054eddddb0c1d2519f9c12b654a6ff8f
2+
refs/heads/master: 898e089d7b15696035391ab8d1e2675c2fb96a2f

trunk/src/comp/middle/trans.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,9 +1971,7 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
19711971
C_int(abi.obj_body_elt_tydesc)));
19721972
auto tydesc = cx.build.Load(tydescptr);
19731973

1974-
// FIXME: disabled for now.
1975-
// auto cx_ = maybe_call_dtor(cx, o);
1976-
auto cx_ = cx;
1974+
auto cx_ = maybe_call_dtor(cx, o);
19771975

19781976
// Call through the obj's own fields-drop glue first.
19791977
call_tydesc_glue_full(cx_, body, tydesc,
@@ -2771,18 +2769,19 @@ fn maybe_call_dtor(@block_ctxt cx, ValueRef v) -> @block_ctxt {
27712769
vtbl = cx.build.Load(vtbl);
27722770
auto dtor_ptr = cx.build.GEP(vtbl, vec(C_int(0), C_int(0)));
27732771
dtor_ptr = cx.build.Load(dtor_ptr);
2772+
auto self_t = llvm.LLVMGetElementType(val_ty(v));
27742773
dtor_ptr = cx.build.BitCast(dtor_ptr,
2775-
T_ptr(T_dtor(cx.fcx.lcx.ccx, val_ty(v))));
2774+
T_ptr(T_dtor(cx.fcx.lcx.ccx, self_t)));
27762775

27772776
auto dtor_cx = new_sub_block_ctxt(cx, "dtor");
27782777
auto after_cx = new_sub_block_ctxt(cx, "after_dtor");
27792778
auto test = cx.build.ICmp(lib.llvm.LLVMIntNE, dtor_ptr,
27802779
C_null(val_ty(dtor_ptr)));
27812780
cx.build.CondBr(test, dtor_cx.llbb, after_cx.llbb);
27822781

2783-
// FIXME need to pass type params (?)
2782+
auto me = dtor_cx.build.Load(v);
27842783
dtor_cx.build.FastCall(dtor_ptr, vec(C_null(T_ptr(T_nil())),
2785-
cx.fcx.lltaskptr, v));
2784+
cx.fcx.lltaskptr, me));
27862785
dtor_cx.build.Br(after_cx.llbb);
27872786
ret after_cx;
27882787
}
@@ -6357,6 +6356,8 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
63576356

63586357
let TypeRef llbox_ty = T_opaque_obj_ptr(ccx.tn);
63596358

6359+
// FIXME we should probably also allocate a box for empty objs that have a
6360+
// dtor, since otherwise they are never dropped, and the dtor never runs
63606361
if (_vec.len[ast.ty_param](ty_params) == 0u &&
63616362
_vec.len[ty.arg](arg_tys) == 0u) {
63626363
// Store null into pair, if no args or typarams.

0 commit comments

Comments
 (0)