Skip to content

Commit dfcfef4

Browse files
committed
rustc: Rename take glue to copy glue
1 parent 1d37118 commit dfcfef4

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

src/comp/back/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const int tydesc_field_size = 1;
5252

5353
const int tydesc_field_align = 2;
5454

55-
const int tydesc_field_take_glue = 3;
55+
const int tydesc_field_copy_glue = 3;
5656

5757
const int tydesc_field_drop_glue = 4;
5858

src/comp/middle/trans.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type tydesc_info =
8686
ValueRef tydesc,
8787
ValueRef size,
8888
ValueRef align,
89-
mutable option::t[ValueRef] take_glue,
89+
mutable option::t[ValueRef] copy_glue,
9090
mutable option::t[ValueRef] drop_glue,
9191
mutable option::t[ValueRef] free_glue,
9292
mutable option::t[ValueRef] cmp_glue,
@@ -506,7 +506,7 @@ fn T_tydesc(&type_names tn) -> TypeRef {
506506
T_struct([tydescpp, // first_param
507507
T_int(), // size
508508
T_int(), // align
509-
glue_fn_ty, // take_glue
509+
glue_fn_ty, // copy_glue
510510
glue_fn_ty, // drop_glue
511511
glue_fn_ty, // free_glue
512512
glue_fn_ty, // sever_glue
@@ -1797,7 +1797,7 @@ fn declare_tydesc(&@local_ctxt cx, &span sp, &ty::t t, vec[uint] ty_params) ->
17971797
tydesc=gvar,
17981798
size=llsize,
17991799
align=llalign,
1800-
mutable take_glue=none[ValueRef],
1800+
mutable copy_glue=none[ValueRef],
18011801
mutable drop_glue=none[ValueRef],
18021802
mutable free_glue=none[ValueRef],
18031803
mutable cmp_glue=none[ValueRef],
@@ -1874,8 +1874,8 @@ fn emit_tydescs(&@crate_ctxt ccx) {
18741874
auto glue_fn_ty = T_ptr(T_glue_fn(ccx.tn));
18751875
auto cmp_fn_ty = T_ptr(T_cmp_glue_fn(ccx.tn));
18761876
auto ti = pair._1;
1877-
auto take_glue =
1878-
alt ({ ti.take_glue }) {
1877+
auto copy_glue =
1878+
alt ({ ti.copy_glue }) {
18791879
case (none) {
18801880
ccx.stats.n_null_glues += 1u;
18811881
C_null(glue_fn_ty)
@@ -1908,7 +1908,7 @@ fn emit_tydescs(&@crate_ctxt ccx) {
19081908
};
19091909
auto tydesc =
19101910
C_struct([C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))), ti.size,
1911-
ti.align, take_glue, // take_glue
1911+
ti.align, copy_glue, // copy_glue
19121912
drop_glue, // drop_glue
19131913
free_glue, // free_glue
19141914
C_null(glue_fn_ty), // sever_glue
@@ -1925,14 +1925,14 @@ fn emit_tydescs(&@crate_ctxt ccx) {
19251925
}
19261926
}
19271927

1928-
fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
1928+
fn make_copy_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
19291929
// NB: v is an *alias* of type t here, not a direct value.
19301930

19311931
auto bcx;
19321932
if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
19331933
bcx = incr_refcnt_of_boxed(cx, cx.build.Load(v)).bcx;
19341934
} else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
1935-
bcx = iter_structural_ty(cx, v, t, bind take_ty(_, _, _)).bcx;
1935+
bcx = iter_structural_ty(cx, v, t, bind copy_ty(_, _, _)).bcx;
19361936
} else { bcx = cx; }
19371937
bcx.build.RetVoid();
19381938
}
@@ -2839,7 +2839,7 @@ fn iter_sequence(@block_ctxt cx, ValueRef v, &ty::t t, &val_and_ty_fn f) ->
28392839

28402840
fn lazily_emit_all_tydesc_glue(&@block_ctxt cx,
28412841
&option::t[@tydesc_info] static_ti) {
2842-
lazily_emit_tydesc_glue(cx, abi::tydesc_field_take_glue, static_ti);
2842+
lazily_emit_tydesc_glue(cx, abi::tydesc_field_copy_glue, static_ti);
28432843
lazily_emit_tydesc_glue(cx, abi::tydesc_field_drop_glue, static_ti);
28442844
lazily_emit_tydesc_glue(cx, abi::tydesc_field_free_glue, static_ti);
28452845
lazily_emit_tydesc_glue(cx, abi::tydesc_field_cmp_glue, static_ti);
@@ -2857,8 +2857,8 @@ fn lazily_emit_tydesc_glue(&@block_ctxt cx, int field,
28572857
alt (static_ti) {
28582858
case (none) { }
28592859
case (some(?ti)) {
2860-
if (field == abi::tydesc_field_take_glue) {
2861-
alt ({ ti.take_glue }) {
2860+
if (field == abi::tydesc_field_copy_glue) {
2861+
alt ({ ti.copy_glue }) {
28622862
case (some(_)) { }
28632863
case (none) {
28642864
log #fmt("+++ lazily_emit_tydesc_glue TAKE %s",
@@ -2867,9 +2867,9 @@ fn lazily_emit_tydesc_glue(&@block_ctxt cx, int field,
28672867
auto glue_fn =
28682868
declare_generic_glue(lcx, ti.ty,
28692869
T_glue_fn(lcx.ccx.tn),
2870-
"take");
2871-
ti.take_glue = some[ValueRef](glue_fn);
2872-
auto tg = make_take_glue;
2870+
"copy");
2871+
ti.copy_glue = some[ValueRef](glue_fn);
2872+
auto tg = make_copy_glue;
28732873
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
28742874
mgghf_single(tg), ti.ty_params);
28752875
log #fmt("--- lazily_emit_tydesc_glue TAKE %s",
@@ -2945,8 +2945,8 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v, ValueRef tydesc,
29452945
alt (static_ti) {
29462946
case (none) { /* no-op */ }
29472947
case (some(?sti)) {
2948-
if (field == abi::tydesc_field_take_glue) {
2949-
static_glue_fn = sti.take_glue;
2948+
if (field == abi::tydesc_field_copy_glue) {
2949+
static_glue_fn = sti.copy_glue;
29502950
} else if (field == abi::tydesc_field_drop_glue) {
29512951
static_glue_fn = sti.drop_glue;
29522952
} else if (field == abi::tydesc_field_free_glue) {
@@ -3053,9 +3053,9 @@ fn compare(&@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
30533053
ret call_cmp_glue(cx, lhs, rhs, t, llop);
30543054
}
30553055

3056-
fn take_ty(&@block_ctxt cx, ValueRef v, ty::t t) -> result {
3056+
fn copy_ty(&@block_ctxt cx, ValueRef v, ty::t t) -> result {
30573057
if (ty::type_has_pointers(cx.fcx.lcx.ccx.tcx, t)) {
3058-
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue);
3058+
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_copy_glue);
30593059
}
30603060
ret rslt(cx, C_nil());
30613061
}
@@ -3168,14 +3168,14 @@ fn copy_val(&@block_ctxt cx, copy_action action, ValueRef dst, ValueRef src,
31683168
ty::type_is_bot(ccx.tcx, t)) {
31693169
ret rslt(cx, C_nil());
31703170
} else if (ty::type_is_boxed(ccx.tcx, t)) {
3171-
auto r = take_ty(cx, src, t);
3171+
auto r = copy_ty(cx, src, t);
31723172
if (action == DROP_EXISTING) {
31733173
r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
31743174
}
31753175
ret rslt(r.bcx, r.bcx.build.Store(src, dst));
31763176
} else if (ty::type_is_structural(ccx.tcx, t) ||
31773177
ty::type_has_dynamic_size(ccx.tcx, t)) {
3178-
auto r = take_ty(cx, src, t);
3178+
auto r = copy_ty(cx, src, t);
31793179
if (action == DROP_EXISTING) { r = drop_ty(r.bcx, dst, t); }
31803180
r = memmove_ty(r.bcx, dst, src, t);
31813181
if (ty::type_owns_heap_mem(ccx.tcx, t)) {
@@ -3376,7 +3376,7 @@ fn trans_vec_append(&@block_ctxt cx, &ty::t t, ValueRef lhs, ValueRef rhs) ->
33763376
bcx = llvec_tydesc.bcx;
33773377
ti = none[@tydesc_info];
33783378
auto llelt_tydesc = get_tydesc(bcx, elt_ty, false, ti);
3379-
lazily_emit_tydesc_glue(cx, abi::tydesc_field_take_glue, ti);
3379+
lazily_emit_tydesc_glue(cx, abi::tydesc_field_copy_glue, ti);
33803380
lazily_emit_tydesc_glue(cx, abi::tydesc_field_drop_glue, ti);
33813381
lazily_emit_tydesc_glue(cx, abi::tydesc_field_free_glue, ti);
33823382
bcx = llelt_tydesc.bcx;
@@ -3663,7 +3663,7 @@ mod ivec {
36633663
rs = get_tydesc(bcx, unit_ty, false, no_tydesc_info);
36643664
auto unit_tydesc = rs.val;
36653665
bcx = rs.bcx;
3666-
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, none);
3666+
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_copy_glue, none);
36673667
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, none);
36683668
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_free_glue, none);
36693669
auto rhs_len_and_data = get_len_and_data(bcx, rhs, unit_ty);
@@ -3950,7 +3950,7 @@ mod ivec {
39503950
}
39513951

39523952
// NB: This does *not* adjust reference counts. The caller must have done
3953-
// this via take_ty() beforehand.
3953+
// this via copy_ty() beforehand.
39543954
fn duplicate_heap_part(&@block_ctxt cx, ValueRef orig_vptr,
39553955
ty::t unit_ty) -> result {
39563956
// Cast to an opaque interior vector if we can't trust the pointer
@@ -5160,9 +5160,9 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
51605160
if (out_arg.mode == ty::mo_val) {
51615161
if (type_is_immediate(cx.ccx, e_ty)) {
51625162
val = bcx.build.Load(val);
5163-
bcx = take_ty(bcx, val, e_ty).bcx;
5163+
bcx = copy_ty(bcx, val, e_ty).bcx;
51645164
} else {
5165-
bcx = take_ty(bcx, val, e_ty).bcx;
5165+
bcx = copy_ty(bcx, val, e_ty).bcx;
51665166
val = bcx.build.Load(val);
51675167
}
51685168
} else if (ty::type_contains_params(cx.ccx.tcx, out_arg.ty)) {
@@ -5401,7 +5401,7 @@ fn trans_arg_expr(&@block_ctxt cx, &ty::arg arg, TypeRef lldestty0,
54015401
val = do_spill(lv.res.bcx, lv.res.val);
54025402
}
54035403
} else { auto re = trans_expr(bcx, e); val = re.val; bcx = re.bcx; }
5404-
if (arg.mode == ty::mo_val) { bcx = take_ty(bcx, val, e_ty).bcx; }
5404+
if (arg.mode == ty::mo_val) { bcx = copy_ty(bcx, val, e_ty).bcx; }
54055405
if (ty::type_is_bot(cx.fcx.lcx.ccx.tcx, e_ty)) {
54065406
// For values of type _|_, we generate an
54075407
// "undef" value, as such a value should never

src/rt/rust_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ struct type_desc {
212212
const type_desc **first_param;
213213
size_t size;
214214
size_t align;
215-
glue_fn *take_glue;
215+
glue_fn *copy_glue;
216216
glue_fn *drop_glue;
217217
glue_fn *free_glue;
218218
glue_fn *sever_glue; // For GC.

src/rt/rust_upcall.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,14 @@ copy_elements(rust_task *task, type_desc *elem_t,
453453
{
454454
char *dst = (char *)pdst, *src = (char *)psrc;
455455

456+
// FIXME: Copy glue doesn't work this way.
456457
// increment the refcount of each element of the vector
457-
if (elem_t->take_glue) {
458-
glue_fn *take_glue = elem_t->take_glue;
458+
if (elem_t->copy_glue) {
459+
glue_fn *copy_glue = elem_t->copy_glue;
459460
size_t elem_size = elem_t->size;
460461
const type_desc **tydescs = elem_t->first_param;
461462
for (char *p = src; p < src+n; p += elem_size) {
462-
take_glue(NULL, task, NULL, tydescs, p);
463+
copy_glue(NULL, task, NULL, tydescs, p);
463464
}
464465
}
465466
memmove(dst, src, n);

0 commit comments

Comments
 (0)