mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Revert "rustc: Avoid SHA-1 hashing every type, since they're interned"
This reverts commit df90f57a5f
.
This commit is contained in:
parent
b49bdad499
commit
a44fb04d57
@ -399,18 +399,38 @@ fn truncated_sha1_result(sha1 sha) -> str {
|
|||||||
ret str::substr(sha.result_str(), 0u, 16u);
|
ret str::substr(sha.result_str(), 0u, 16u);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_link_meta(sha1 sha, &link_meta link_meta) -> str {
|
|
||||||
|
// This calculates STH for a symbol, as defined above
|
||||||
|
fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
|
||||||
|
&link_meta link_meta) -> str {
|
||||||
|
// NB: do *not* use abbrevs here as we want the symbol names
|
||||||
|
// to be independent of one another in the crate.
|
||||||
|
|
||||||
sha.reset();
|
sha.reset();
|
||||||
sha.input_str(link_meta.name);
|
sha.input_str(link_meta.name);
|
||||||
sha.input_str("-");
|
sha.input_str("-");
|
||||||
sha.input_str(link_meta.vers);
|
// FIXME: This wants to be link_meta.meta_hash
|
||||||
|
sha.input_str(link_meta.name);
|
||||||
sha.input_str("-");
|
sha.input_str("-");
|
||||||
sha.input_str(link_meta.extras_hash);
|
sha.input_str(encoder::encoded_ty(tcx, t));
|
||||||
ret truncated_sha1_result(sha);
|
auto hash = truncated_sha1_result(sha);
|
||||||
|
// Prefix with _ so that it never blends into adjacent digits
|
||||||
|
|
||||||
|
ret "_" + hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_symbol_hash(&@crate_ctxt ccx, &ty::t t) -> str {
|
fn get_symbol_hash(&@crate_ctxt ccx, &ty::t t) -> str {
|
||||||
ret #fmt("_%s_%u", ccx.link_meta_hash, t);
|
auto hash = "";
|
||||||
|
alt (ccx.type_sha1s.find(t)) {
|
||||||
|
case (some(?h)) { hash = h; }
|
||||||
|
case (none) {
|
||||||
|
hash =
|
||||||
|
symbol_hash(ccx.tcx, ccx.sha, t,
|
||||||
|
ccx.link_meta);
|
||||||
|
ccx.type_sha1s.insert(t, hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mangle(&str[] ss) -> str {
|
fn mangle(&str[] ss) -> str {
|
||||||
|
@ -136,7 +136,6 @@ type crate_ctxt =
|
|||||||
hashmap[ast::node_id, str] item_symbols,
|
hashmap[ast::node_id, str] item_symbols,
|
||||||
mutable option::t[ValueRef] main_fn,
|
mutable option::t[ValueRef] main_fn,
|
||||||
link::link_meta link_meta,
|
link::link_meta link_meta,
|
||||||
str link_meta_hash,
|
|
||||||
|
|
||||||
// TODO: hashmap[tup(tag_id,subtys), @tag_info]
|
// TODO: hashmap[tup(tag_id,subtys), @tag_info]
|
||||||
hashmap[ty::t, uint] tag_sizes,
|
hashmap[ty::t, uint] tag_sizes,
|
||||||
@ -151,6 +150,7 @@ type crate_ctxt =
|
|||||||
@glue_fns glues,
|
@glue_fns glues,
|
||||||
namegen names,
|
namegen names,
|
||||||
std::sha1::sha1 sha,
|
std::sha1::sha1 sha,
|
||||||
|
hashmap[ty::t, str] type_sha1s,
|
||||||
hashmap[ty::t, str] type_short_names,
|
hashmap[ty::t, str] type_short_names,
|
||||||
ty::ctxt tcx,
|
ty::ctxt tcx,
|
||||||
stats stats,
|
stats stats,
|
||||||
@ -8601,9 +8601,9 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
|
|||||||
auto tag_sizes = map::mk_hashmap[ty::t, uint](hasher, eqer);
|
auto tag_sizes = map::mk_hashmap[ty::t, uint](hasher, eqer);
|
||||||
auto tydescs = map::mk_hashmap[ty::t, @tydesc_info](hasher, eqer);
|
auto tydescs = map::mk_hashmap[ty::t, @tydesc_info](hasher, eqer);
|
||||||
auto lltypes = map::mk_hashmap[ty::t, TypeRef](hasher, eqer);
|
auto lltypes = map::mk_hashmap[ty::t, TypeRef](hasher, eqer);
|
||||||
|
auto sha1s = map::mk_hashmap[ty::t, str](hasher, eqer);
|
||||||
auto short_names = map::mk_hashmap[ty::t, str](hasher, eqer);
|
auto short_names = map::mk_hashmap[ty::t, str](hasher, eqer);
|
||||||
auto sha = std::sha1::mk_sha1();
|
auto sha = std::sha1::mk_sha1();
|
||||||
auto link_meta = link::build_link_meta(sess, *crate, output, sha);
|
|
||||||
auto ccx =
|
auto ccx =
|
||||||
@rec(sess=sess,
|
@rec(sess=sess,
|
||||||
llmod=llmod,
|
llmod=llmod,
|
||||||
@ -8615,8 +8615,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
|
|||||||
ast_map=amap,
|
ast_map=amap,
|
||||||
item_symbols=new_int_hash[str](),
|
item_symbols=new_int_hash[str](),
|
||||||
mutable main_fn=none[ValueRef],
|
mutable main_fn=none[ValueRef],
|
||||||
link_meta=link_meta,
|
link_meta=link::build_link_meta(sess, *crate, output, sha),
|
||||||
link_meta_hash=link::hash_link_meta(sha, link_meta),
|
|
||||||
tag_sizes=tag_sizes,
|
tag_sizes=tag_sizes,
|
||||||
discrims=new_int_hash[ValueRef](),
|
discrims=new_int_hash[ValueRef](),
|
||||||
discrim_symbols=new_int_hash[str](),
|
discrim_symbols=new_int_hash[str](),
|
||||||
@ -8629,6 +8628,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
|
|||||||
glues=glues,
|
glues=glues,
|
||||||
names=namegen(0),
|
names=namegen(0),
|
||||||
sha=sha,
|
sha=sha,
|
||||||
|
type_sha1s=sha1s,
|
||||||
type_short_names=short_names,
|
type_short_names=short_names,
|
||||||
tcx=tcx,
|
tcx=tcx,
|
||||||
stats=rec(mutable n_static_tydescs=0u,
|
stats=rec(mutable n_static_tydescs=0u,
|
||||||
|
Loading…
Reference in New Issue
Block a user