Skip to content

Commit e4b5d91

Browse files
committed
rustc: Directly emit calls to glue if possible
1 parent 4558167 commit e4b5d91

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,13 +2893,38 @@ fn lazily_emit_tydesc_glue(&@block_ctxt cx, int field,
28932893
fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v, ValueRef tydesc,
28942894
int field, &option::t[@tydesc_info] static_ti) {
28952895
lazily_emit_tydesc_glue(cx, field, static_ti);
2896+
2897+
auto static_glue_fn = none;
2898+
alt (static_ti) {
2899+
case (none) { /* no-op */ }
2900+
case (some(?sti)) {
2901+
if (field == abi::tydesc_field_take_glue) {
2902+
static_glue_fn = sti.take_glue;
2903+
} else if (field == abi::tydesc_field_drop_glue) {
2904+
static_glue_fn = sti.drop_glue;
2905+
} else if (field == abi::tydesc_field_free_glue) {
2906+
static_glue_fn = sti.free_glue;
2907+
} else if (field == abi::tydesc_field_cmp_glue) {
2908+
static_glue_fn = sti.cmp_glue;
2909+
}
2910+
}
2911+
}
2912+
28962913
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
28972914
auto lltydescs =
28982915
cx.build.GEP(tydesc,
28992916
[C_int(0), C_int(abi::tydesc_field_first_param)]);
29002917
lltydescs = cx.build.Load(lltydescs);
2901-
auto llfnptr = cx.build.GEP(tydesc, [C_int(0), C_int(field)]);
2902-
auto llfn = cx.build.Load(llfnptr);
2918+
2919+
auto llfn;
2920+
alt (static_glue_fn) {
2921+
case (none) {
2922+
auto llfnptr = cx.build.GEP(tydesc, [C_int(0), C_int(field)]);
2923+
llfn = cx.build.Load(llfnptr);
2924+
}
2925+
case (some(?sgf)) { llfn = sgf; }
2926+
}
2927+
29032928
cx.build.Call(llfn,
29042929
[C_null(T_ptr(T_nil())), cx.fcx.lltaskptr,
29052930
C_null(T_ptr(T_nil())), lltydescs, llrawptr]);

0 commit comments

Comments
 (0)