auto merge of #11909 : thestinger/rust/tydesc, r=pcwalton

This commit is contained in:
bors 2014-01-30 03:36:25 -08:00
commit a6764c28e6
4 changed files with 10 additions and 18 deletions

View File

@ -376,7 +376,7 @@ pub fn malloc_raw_dyn<'a>(
// Get the tydesc for the body:
let static_ti = get_tydesc(ccx, t);
glue::lazily_emit_all_tydesc_glue(ccx, static_ti);
glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti);
// Allocate space:
let tydesc = PointerCast(bcx, static_ti.tydesc, Type::i8p());

View File

@ -131,7 +131,7 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
t
}
fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
let _icx = push_ctxt("lazily_emit_tydesc_glue");
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<'
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
// Only drop the value when it is non-null
with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| {
let llvtable = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
// Cast the vtable to a pointer to a pointer to a tydesc.
let llvtable = PointerCast(bcx, llvtable,
ccx.tydesc_type.ptr_to().ptr_to());
let lltydesc = Load(bcx, llvtable);
call_tydesc_glue_full(bcx,
lluniquevalue,
lltydesc,
abi::tydesc_field_drop_glue,
None);
let lldtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable]));
let lldtor = Load(bcx, lldtor_ptr);
Call(bcx, lldtor, [PointerCast(bcx, lluniquevalue, Type::i8p())], []);
bcx
})
}

View File

@ -481,7 +481,7 @@ pub fn get_vtable(bcx: &Block,
// Generate a type descriptor for the vtable.
let tydesc = get_tydesc(ccx, self_ty);
glue::lazily_emit_all_tydesc_glue(ccx, tydesc);
glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, tydesc);
let vtable = make_vtable(ccx, tydesc, methods);
@ -498,7 +498,7 @@ pub fn make_vtable(ccx: &CrateContext,
unsafe {
let _icx = push_ctxt("meth::make_vtable");
let mut components = ~[ tydesc.tydesc ];
let mut components = ~[tydesc.drop_glue.get().unwrap()];
for &ptr in ptrs.iter() {
components.push(ptr)
}

View File

@ -180,7 +180,7 @@ impl Type {
}
pub fn vtable() -> Type {
Type::array(&Type::i8().ptr_to(), 1)
Type::array(&Type::i8p().ptr_to(), 1)
}
pub fn generic_glue_fn(cx: &CrateContext) -> Type {
@ -246,13 +246,13 @@ impl Type {
}
pub fn opaque_trait(ctx: &CrateContext, store: ty::TraitStore) -> Type {
let tydesc_ptr = ctx.tydesc_type.ptr_to();
let vtable = Type::glue_fn(Type::i8p()).ptr_to().ptr_to();
let box_ty = match store {
ty::BoxTraitStore => Type::at_box(ctx, Type::i8()),
ty::UniqTraitStore => Type::i8(),
ty::RegionTraitStore(..) => Type::i8()
};
Type::struct_([tydesc_ptr, box_ty.ptr_to()], false)
Type::struct_([vtable, box_ty.ptr_to()], false)
}
pub fn kind(&self) -> TypeKind {