Skip to content

Commit 93729a0

Browse files
committed
---
yaml --- r: 2948 b: refs/heads/master c: 2736d63 h: refs/heads/master v: v3
1 parent 66d79eb commit 93729a0

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
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: 5f95766a40ae6f547e5bae473d8412e51a2e8adf
2+
refs/heads/master: 2736d63db073e5ae021177ff3ac3cb001789b493

trunk/src/comp/middle/trans.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7231,15 +7231,16 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
72317231
typarams_ty,
72327232
fields_ty]);
72337233

7234-
// Hand this thing we've constructed off to trans_malloc_boxed, which
7235-
// makes space for the refcount.
7234+
// Hand this type we've synthesized off to trans_malloc_boxed, which
7235+
// allocates a box, including space for a refcount.
72367236
auto box = trans_malloc_boxed(bcx, body_ty);
72377237
bcx = box.bcx;
72387238

7239-
// And mk_imm_box throws a refcount into the type we're synthesizing:
7240-
// [rc, [tydesc_ty, [typaram, ...], [field, ...]]]
7239+
// mk_imm_box throws a refcount into the type we're synthesizing, so
7240+
// that it looks like: [rc, [tydesc_ty, [typaram, ...], [field, ...]]]
72417241
let ty::t boxed_body_ty = ty::mk_imm_box(ccx.tcx, body_ty);
72427242

7243+
// Grab onto the refcount and body parts of the box we allocated.
72437244
auto rc = GEP_tup_like(bcx, boxed_body_ty, box.val,
72447245
[0,
72457246
abi::box_rc_field_refcnt]);
@@ -7253,6 +7254,12 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
72537254

72547255
// Put together a tydesc for the body, so that the object can later be
72557256
// freed by calling through its tydesc.
7257+
7258+
// Every object (not just those with type parameters) needs to have a
7259+
// tydesc to describe its body, since all objects have unknown type to
7260+
// the user of the object. So the tydesc is needed to keep track of
7261+
// the types of the object's fields, so that the fields can be freed
7262+
// later.
72567263
auto body_tydesc =
72577264
GEP_tup_like(bcx, body_ty, body.val,
72587265
[0, abi::obj_body_elt_tydesc]);
@@ -7263,17 +7270,16 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
72637270
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, ti);
72647271
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_free_glue, ti);
72657272

7266-
auto dtor = C_null(T_ptr(T_glue_fn(ccx.tn)));
7267-
alt (ob.dtor) {
7268-
case (some(?d)) {
7269-
dtor = trans_dtor(cx, llself_ty, self_ty, ty_params, d);
7270-
}
7271-
case (none) {}
7272-
}
7273-
72747273
bcx = body_td.bcx;
72757274
bcx.build.Store(body_td.val, body_tydesc.val);
72767275

7276+
// Copy the object's type parameters and fields into the space we
7277+
// allocated for the object body. (This is something like saving the
7278+
// lexical environment of a function in its closure: the "captured
7279+
// typarams" are any type parameters that are passed to the object
7280+
// constructor and are then available to the object's methods.
7281+
// Likewise for the object's fields.)
7282+
72777283
// Copy typarams into captured typarams.
72787284
auto body_typarams =
72797285
GEP_tup_like(bcx, body_ty, body.val,

0 commit comments

Comments
 (0)