Skip to content

Commit 6809b17

Browse files
committed
remove borrow_offset as ~ is now free of headers
1 parent 0e885e4 commit 6809b17

File tree

6 files changed

+3
-50
lines changed

6 files changed

+3
-50
lines changed

src/librustc/back/abi.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ pub static tydesc_field_align: uint = 1u;
4545
pub static tydesc_field_take_glue: uint = 2u;
4646
pub static tydesc_field_drop_glue: uint = 3u;
4747
pub static tydesc_field_visit_glue: uint = 4u;
48-
pub static tydesc_field_borrow_offset: uint = 5u;
49-
pub static tydesc_field_name_offset: uint = 6u;
50-
pub static n_tydesc_fields: uint = 7u;
48+
pub static tydesc_field_name_offset: uint = 5u;
49+
pub static n_tydesc_fields: uint = 6u;
5150

5251
// The two halves of a closure: code and environment.
5352
pub static fn_field_code: uint = 0u;

src/librustc/middle/trans/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub struct tydesc_info {
9090
tydesc: ValueRef,
9191
size: ValueRef,
9292
align: ValueRef,
93-
borrow_offset: ValueRef,
9493
name: ValueRef,
9594
take_glue: Cell<Option<ValueRef>>,
9695
drop_glue: Cell<Option<ValueRef>>,

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -398,29 +398,7 @@ pub fn trans_to_datum<'a>(bcx: &'a Block<'a>, expr: &ast::Expr)
398398
autoderefs));
399399
derefd_datum.to_rptr(bcx).to_value_llval(bcx)
400400
}
401-
ty::UniqTraitStore(..) => {
402-
// For a ~T box, there may or may not be a header,
403-
// depending on whether the type T references managed
404-
// boxes. However, since we do not *know* the type T
405-
// for objects, this presents a hurdle. Our solution is
406-
// to load the "borrow offset" from the type descriptor;
407-
// this value will either be 0 or sizeof(BoxHeader), depending
408-
// on the type T.
409-
let llopaque =
410-
PointerCast(bcx, source_data, Type::opaque().ptr_to());
411-
let lltydesc_ptr_ptr =
412-
PointerCast(bcx, vtable,
413-
bcx.ccx().tydesc_type.ptr_to().ptr_to());
414-
let lltydesc_ptr =
415-
Load(bcx, lltydesc_ptr_ptr);
416-
let borrow_offset_ptr =
417-
GEPi(bcx, lltydesc_ptr,
418-
[0, abi::tydesc_field_borrow_offset]);
419-
let borrow_offset =
420-
Load(bcx, borrow_offset_ptr);
421-
InBoundsGEP(bcx, llopaque, [borrow_offset])
422-
}
423-
ty::RegionTraitStore(..) => {
401+
ty::UniqTraitStore(..) | ty::RegionTraitStore(..) => {
424402
source_data
425403
}
426404
};

src/librustc/middle/trans/glue.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -546,17 +546,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
546546
ppaux::ty_to_str(ccx.tcx, t));
547547
}
548548

549-
let has_header = match ty::get(t).sty {
550-
ty::ty_box(..) => true,
551-
_ => false
552-
};
553-
554-
let borrow_offset = if has_header {
555-
ccx.offsetof_gep(llty, [0u, abi::box_field_body])
556-
} else {
557-
C_uint(ccx, 0)
558-
};
559-
560549
let llsize = llsize_of(ccx, llty);
561550
let llalign = llalign_of(ccx, llty);
562551
let name = mangle_internal_name_by_type_and_seq(ccx, t, "tydesc").to_managed();
@@ -575,7 +564,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
575564
tydesc: gvar,
576565
size: llsize,
577566
align: llalign,
578-
borrow_offset: borrow_offset,
579567
name: ty_name,
580568
take_glue: Cell::new(None),
581569
drop_glue: Cell::new(None),
@@ -685,15 +673,12 @@ pub fn emit_tydescs(ccx: &CrateContext) {
685673
}
686674
};
687675

688-
debug!("ti.borrow_offset: {}", ccx.tn.val_to_str(ti.borrow_offset));
689-
690676
let tydesc = C_named_struct(ccx.tydesc_type,
691677
[ti.size, // size
692678
ti.align, // align
693679
take_glue, // take_glue
694680
drop_glue, // drop_glue
695681
visit_glue, // visit_glue
696-
ti.borrow_offset, // borrow_offset
697682
ti.name]); // name
698683

699684
unsafe {

src/librustc/middle/trans/type_.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ impl Type {
220220
glue_fn_ty, // take
221221
glue_fn_ty, // drop
222222
glue_fn_ty, // visit
223-
int_ty, // borrow_offset
224223
Type::struct_([Type::i8p(), Type::int(arch)], false)]; // name
225224
tydesc.set_struct_body(elems, false);
226225

src/libstd/unstable/intrinsics.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ pub struct TyDesc {
9898
// Called by reflection visitor to visit a value of type `T`
9999
visit_glue: GlueFn,
100100

101-
// If T represents a box pointer (`@U` or `~U`), then
102-
// `borrow_offset` is the amount that the pointer must be adjusted
103-
// to find the payload. This is always derivable from the type
104-
// `U`, but in the case of `@Trait` or `~Trait` objects, the type
105-
// `U` is unknown.
106-
borrow_offset: uint,
107-
108101
// Name corresponding to the type
109102
name: &'static str
110103
}

0 commit comments

Comments
 (0)