Skip to content

Commit a66e23d

Browse files
committed
rustc: Stop generating shape tables
1 parent e85a3d8 commit a66e23d

File tree

3 files changed

+4
-59
lines changed

3 files changed

+4
-59
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,11 +2701,7 @@ fn trans_crate(sess: session::session,
27012701

27022702
decl_gc_metadata(ccx, llmod_id);
27032703
fill_crate_map(ccx, crate_map);
2704-
// NB: Must call force_declare_tydescs before emit_tydescs to break
2705-
// cyclical dependency with shape code! See shape.rs for details.
2706-
force_declare_tydescs(ccx);
27072704
glue::emit_tydescs(ccx);
2708-
gen_shape_tables(ccx);
27092705
write_abi_version(ccx);
27102706

27112707
// Translate the metadata.

src/rustc/middle/trans/glue.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
679679
let _icx = ccx.insn_ctxt("emit_tydescs");
680680
// As of this point, allow no more tydescs to be created.
681681
ccx.finished_tydescs = true;
682-
for ccx.tydescs.each |key, val| {
682+
for ccx.tydescs.each |_key, val| {
683683
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
684684
let ti = val;
685685

@@ -720,10 +720,8 @@ fn emit_tydescs(ccx: @crate_ctxt) {
720720
}
721721
};
722722

723-
let shape = shape_of(ccx, key);
724-
let shape_tables =
725-
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
726-
T_ptr(T_i8()));
723+
let shape = C_null(T_ptr(T_i8()));
724+
let shape_tables = C_null(T_ptr(T_i8()));
727725

728726
let tydesc =
729727
C_named_struct(ccx.tydesc_type,
@@ -733,7 +731,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
733731
drop_glue, // drop_glue
734732
free_glue, // free_glue
735733
visit_glue, // visit_glue
736-
C_shape(ccx, shape), // shape
734+
shape, // shape
737735
shape_tables]); // shape_tables
738736

739737
let gvar = ti.tydesc;

src/rustc/middle/trans/shape.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -591,52 +591,3 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
591591
return mk_global(ccx, ~"resource_shapes", C_struct(dtors), true);
592592
}
593593

594-
// This function serves to break a cyclical dependence between
595-
// emit_tydescs and gen_shape_tables.
596-
//
597-
// * emit_tydescs calls shape_of, which causes changes to the shape
598-
// tables
599-
// * gen_shape_tables transitively calls get_tydesc, which causes new
600-
// tydescs to be created
601-
//
602-
// We force those tydescs to be emitted now, thus breaking the
603-
// dependency.
604-
fn force_declare_tydescs(ccx: @crate_ctxt) {
605-
// Walk all known tydescs first to force shape code to declare
606-
// dependencies.
607-
for ccx.tydescs.each |key, _val| {
608-
shape_of(ccx, key);
609-
}
610-
611-
// Then walk all resource shapes to force emit all dtors.
612-
let len = ccx.shape_cx.resources.len();
613-
for uint::range(0u, len) |i| {
614-
let ri = ccx.shape_cx.resources.get(i);
615-
for ri.tps.each() |s| { assert !ty::type_has_params(*s); }
616-
do ri.parent_id.iter |id| {
617-
trans::base::get_res_dtor(ccx, ri.did, id, ri.tps);
618-
}
619-
}
620-
}
621-
622-
fn gen_shape_tables(ccx: @crate_ctxt) {
623-
let lltagstable = gen_enum_shapes(ccx);
624-
let llresourcestable = gen_resource_shapes(ccx);
625-
trans::common::set_struct_body(ccx.shape_cx.llshapetablesty,
626-
~[val_ty(lltagstable),
627-
val_ty(llresourcestable)]);
628-
629-
let lltables =
630-
C_named_struct(ccx.shape_cx.llshapetablesty,
631-
~[lltagstable, llresourcestable]);
632-
lib::llvm::llvm::LLVMSetInitializer(ccx.shape_cx.llshapetables, lltables);
633-
lib::llvm::llvm::LLVMSetGlobalConstant(ccx.shape_cx.llshapetables, True);
634-
lib::llvm::SetLinkage(ccx.shape_cx.llshapetables,
635-
lib::llvm::InternalLinkage);
636-
}
637-
638-
// Computes the static size of a enum, without using mk_tup(), which is
639-
// bad for performance.
640-
//
641-
// NB: Migrate trans over to use this.
642-

0 commit comments

Comments
 (0)