Skip to content

Commit a6764c2

Browse files
committed
auto merge of #11909 : thestinger/rust/tydesc, r=pcwalton
2 parents 6b305f3 + 383e3fd commit a6764c2

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ pub fn malloc_raw_dyn<'a>(
376376

377377
// Get the tydesc for the body:
378378
let static_ti = get_tydesc(ccx, t);
379-
glue::lazily_emit_all_tydesc_glue(ccx, static_ti);
379+
glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti);
380380

381381
// Allocate space:
382382
let tydesc = PointerCast(bcx, static_ti.tydesc, Type::i8p());

src/librustc/middle/trans/glue.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
131131
t
132132
}
133133

134-
fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
134+
pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
135135
let _icx = push_ctxt("lazily_emit_tydesc_glue");
136136

137137
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
@@ -367,17 +367,9 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
367367
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
368368
// Only drop the value when it is non-null
369369
with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| {
370-
let llvtable = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
371-
372-
// Cast the vtable to a pointer to a pointer to a tydesc.
373-
let llvtable = PointerCast(bcx, llvtable,
374-
ccx.tydesc_type.ptr_to().ptr_to());
375-
let lltydesc = Load(bcx, llvtable);
376-
call_tydesc_glue_full(bcx,
377-
lluniquevalue,
378-
lltydesc,
379-
abi::tydesc_field_drop_glue,
380-
None);
370+
let lldtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
371+
let lldtor = Load(bcx, lldtor_ptr);
372+
Call(bcx, lldtor, [PointerCast(bcx, lluniquevalue, Type::i8p())], []);
381373
bcx
382374
})
383375
}

src/librustc/middle/trans/meth.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pub fn get_vtable(bcx: &Block,
481481

482482
// Generate a type descriptor for the vtable.
483483
let tydesc = get_tydesc(ccx, self_ty);
484-
glue::lazily_emit_all_tydesc_glue(ccx, tydesc);
484+
glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, tydesc);
485485

486486
let vtable = make_vtable(ccx, tydesc, methods);
487487

@@ -498,7 +498,7 @@ pub fn make_vtable(ccx: &CrateContext,
498498
unsafe {
499499
let _icx = push_ctxt("meth::make_vtable");
500500

501-
let mut components = ~[ tydesc.tydesc ];
501+
let mut components = ~[tydesc.drop_glue.get().unwrap()];
502502
for &ptr in ptrs.iter() {
503503
components.push(ptr)
504504
}

src/librustc/middle/trans/type_.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Type {
180180
}
181181

182182
pub fn vtable() -> Type {
183-
Type::array(&Type::i8().ptr_to(), 1)
183+
Type::array(&Type::i8p().ptr_to(), 1)
184184
}
185185

186186
pub fn generic_glue_fn(cx: &CrateContext) -> Type {
@@ -246,13 +246,13 @@ impl Type {
246246
}
247247

248248
pub fn opaque_trait(ctx: &CrateContext, store: ty::TraitStore) -> Type {
249-
let tydesc_ptr = ctx.tydesc_type.ptr_to();
249+
let vtable = Type::glue_fn(Type::i8p()).ptr_to().ptr_to();
250250
let box_ty = match store {
251251
ty::BoxTraitStore => Type::at_box(ctx, Type::i8()),
252252
ty::UniqTraitStore => Type::i8(),
253253
ty::RegionTraitStore(..) => Type::i8()
254254
};
255-
Type::struct_([tydesc_ptr, box_ty.ptr_to()], false)
255+
Type::struct_([vtable, box_ty.ptr_to()], false)
256256
}
257257

258258
pub fn kind(&self) -> TypeKind {

0 commit comments

Comments
 (0)