Skip to content

Commit

Permalink
remove borrow_offset as ~ is now free of headers
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Jan 15, 2014
1 parent 0e885e4 commit 6809b17
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 50 deletions.
5 changes: 2 additions & 3 deletions src/librustc/back/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ pub static tydesc_field_align: uint = 1u;
pub static tydesc_field_take_glue: uint = 2u;
pub static tydesc_field_drop_glue: uint = 3u;
pub static tydesc_field_visit_glue: uint = 4u;
pub static tydesc_field_borrow_offset: uint = 5u;
pub static tydesc_field_name_offset: uint = 6u;
pub static n_tydesc_fields: uint = 7u;
pub static tydesc_field_name_offset: uint = 5u;
pub static n_tydesc_fields: uint = 6u;

// The two halves of a closure: code and environment.
pub static fn_field_code: uint = 0u;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub struct tydesc_info {
tydesc: ValueRef,
size: ValueRef,
align: ValueRef,
borrow_offset: ValueRef,
name: ValueRef,
take_glue: Cell<Option<ValueRef>>,
drop_glue: Cell<Option<ValueRef>>,
Expand Down
24 changes: 1 addition & 23 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,29 +398,7 @@ pub fn trans_to_datum<'a>(bcx: &'a Block<'a>, expr: &ast::Expr)
autoderefs));
derefd_datum.to_rptr(bcx).to_value_llval(bcx)
}
ty::UniqTraitStore(..) => {
// For a ~T box, there may or may not be a header,
// depending on whether the type T references managed
// boxes. However, since we do not *know* the type T
// for objects, this presents a hurdle. Our solution is
// to load the "borrow offset" from the type descriptor;
// this value will either be 0 or sizeof(BoxHeader), depending
// on the type T.
let llopaque =
PointerCast(bcx, source_data, Type::opaque().ptr_to());
let lltydesc_ptr_ptr =
PointerCast(bcx, vtable,
bcx.ccx().tydesc_type.ptr_to().ptr_to());
let lltydesc_ptr =
Load(bcx, lltydesc_ptr_ptr);
let borrow_offset_ptr =
GEPi(bcx, lltydesc_ptr,
[0, abi::tydesc_field_borrow_offset]);
let borrow_offset =
Load(bcx, borrow_offset_ptr);
InBoundsGEP(bcx, llopaque, [borrow_offset])
}
ty::RegionTraitStore(..) => {
ty::UniqTraitStore(..) | ty::RegionTraitStore(..) => {
source_data
}
};
Expand Down
15 changes: 0 additions & 15 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
ppaux::ty_to_str(ccx.tcx, t));
}

let has_header = match ty::get(t).sty {
ty::ty_box(..) => true,
_ => false
};

let borrow_offset = if has_header {
ccx.offsetof_gep(llty, [0u, abi::box_field_body])
} else {
C_uint(ccx, 0)
};

let llsize = llsize_of(ccx, llty);
let llalign = llalign_of(ccx, llty);
let name = mangle_internal_name_by_type_and_seq(ccx, t, "tydesc").to_managed();
Expand All @@ -575,7 +564,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
tydesc: gvar,
size: llsize,
align: llalign,
borrow_offset: borrow_offset,
name: ty_name,
take_glue: Cell::new(None),
drop_glue: Cell::new(None),
Expand Down Expand Up @@ -685,15 +673,12 @@ pub fn emit_tydescs(ccx: &CrateContext) {
}
};

debug!("ti.borrow_offset: {}", ccx.tn.val_to_str(ti.borrow_offset));

let tydesc = C_named_struct(ccx.tydesc_type,
[ti.size, // size
ti.align, // align
take_glue, // take_glue
drop_glue, // drop_glue
visit_glue, // visit_glue
ti.borrow_offset, // borrow_offset
ti.name]); // name

unsafe {
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/trans/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ impl Type {
glue_fn_ty, // take
glue_fn_ty, // drop
glue_fn_ty, // visit
int_ty, // borrow_offset
Type::struct_([Type::i8p(), Type::int(arch)], false)]; // name
tydesc.set_struct_body(elems, false);

Expand Down
7 changes: 0 additions & 7 deletions src/libstd/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ pub struct TyDesc {
// Called by reflection visitor to visit a value of type `T`
visit_glue: GlueFn,

// If T represents a box pointer (`@U` or `~U`), then
// `borrow_offset` is the amount that the pointer must be adjusted
// to find the payload. This is always derivable from the type
// `U`, but in the case of `@Trait` or `~Trait` objects, the type
// `U` is unknown.
borrow_offset: uint,

// Name corresponding to the type
name: &'static str
}
Expand Down

0 comments on commit 6809b17

Please sign in to comment.