1
Fork 0

rustc: Stop generating shape tables

This commit is contained in:
Patrick Walton 2012-09-25 16:39:52 -07:00
parent e85a3d8247
commit a66e23d236
3 changed files with 4 additions and 59 deletions

View file

@ -2701,11 +2701,7 @@ fn trans_crate(sess: session::session,
decl_gc_metadata(ccx, llmod_id);
fill_crate_map(ccx, crate_map);
// NB: Must call force_declare_tydescs before emit_tydescs to break
// cyclical dependency with shape code! See shape.rs for details.
force_declare_tydescs(ccx);
glue::emit_tydescs(ccx);
gen_shape_tables(ccx);
write_abi_version(ccx);
// Translate the metadata.

View file

@ -679,7 +679,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
let _icx = ccx.insn_ctxt("emit_tydescs");
// As of this point, allow no more tydescs to be created.
ccx.finished_tydescs = true;
for ccx.tydescs.each |key, val| {
for ccx.tydescs.each |_key, val| {
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
let ti = val;
@ -720,10 +720,8 @@ fn emit_tydescs(ccx: @crate_ctxt) {
}
};
let shape = shape_of(ccx, key);
let shape_tables =
llvm::LLVMConstPointerCast(ccx.shape_cx.llshapetables,
T_ptr(T_i8()));
let shape = C_null(T_ptr(T_i8()));
let shape_tables = C_null(T_ptr(T_i8()));
let tydesc =
C_named_struct(ccx.tydesc_type,
@ -733,7 +731,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
drop_glue, // drop_glue
free_glue, // free_glue
visit_glue, // visit_glue
C_shape(ccx, shape), // shape
shape, // shape
shape_tables]); // shape_tables
let gvar = ti.tydesc;

View file

@ -591,52 +591,3 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
return mk_global(ccx, ~"resource_shapes", C_struct(dtors), true);
}
// This function serves to break a cyclical dependence between
// emit_tydescs and gen_shape_tables.
//
// * emit_tydescs calls shape_of, which causes changes to the shape
// tables
// * gen_shape_tables transitively calls get_tydesc, which causes new
// tydescs to be created
//
// We force those tydescs to be emitted now, thus breaking the
// dependency.
fn force_declare_tydescs(ccx: @crate_ctxt) {
// Walk all known tydescs first to force shape code to declare
// dependencies.
for ccx.tydescs.each |key, _val| {
shape_of(ccx, key);
}
// Then walk all resource shapes to force emit all dtors.
let len = ccx.shape_cx.resources.len();
for uint::range(0u, len) |i| {
let ri = ccx.shape_cx.resources.get(i);
for ri.tps.each() |s| { assert !ty::type_has_params(*s); }
do ri.parent_id.iter |id| {
trans::base::get_res_dtor(ccx, ri.did, id, ri.tps);
}
}
}
fn gen_shape_tables(ccx: @crate_ctxt) {
let lltagstable = gen_enum_shapes(ccx);
let llresourcestable = gen_resource_shapes(ccx);
trans::common::set_struct_body(ccx.shape_cx.llshapetablesty,
~[val_ty(lltagstable),
val_ty(llresourcestable)]);
let lltables =
C_named_struct(ccx.shape_cx.llshapetablesty,
~[lltagstable, llresourcestable]);
lib::llvm::llvm::LLVMSetInitializer(ccx.shape_cx.llshapetables, lltables);
lib::llvm::llvm::LLVMSetGlobalConstant(ccx.shape_cx.llshapetables, True);
lib::llvm::SetLinkage(ccx.shape_cx.llshapetables,
lib::llvm::InternalLinkage);
}
// Computes the static size of a enum, without using mk_tup(), which is
// bad for performance.
//
// NB: Migrate trans over to use this.