Skip to content

Commit dd28794

Browse files
committed
---
yaml --- r: 4039 b: refs/heads/master c: a44fb04 h: refs/heads/master i: 4037: 28c6084 4035: e74fdf1 4031: d9f6ed9 v: v3
1 parent 85f882e commit dd28794

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b49bdad4994ad555fcfbb523ad79096c46a0ed48
2+
refs/heads/master: a44fb04d57400f70ad58c1e35fc9dd9a7c43de07

trunk/src/comp/back/link.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,38 @@ fn truncated_sha1_result(sha1 sha) -> str {
399399
ret str::substr(sha.result_str(), 0u, 16u);
400400
}
401401

402-
fn hash_link_meta(sha1 sha, &link_meta link_meta) -> str {
402+
403+
// This calculates STH for a symbol, as defined above
404+
fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
405+
&link_meta link_meta) -> str {
406+
// NB: do *not* use abbrevs here as we want the symbol names
407+
// to be independent of one another in the crate.
408+
403409
sha.reset();
404410
sha.input_str(link_meta.name);
405411
sha.input_str("-");
406-
sha.input_str(link_meta.vers);
412+
// FIXME: This wants to be link_meta.meta_hash
413+
sha.input_str(link_meta.name);
407414
sha.input_str("-");
408-
sha.input_str(link_meta.extras_hash);
409-
ret truncated_sha1_result(sha);
415+
sha.input_str(encoder::encoded_ty(tcx, t));
416+
auto hash = truncated_sha1_result(sha);
417+
// Prefix with _ so that it never blends into adjacent digits
418+
419+
ret "_" + hash;
410420
}
411421

412422
fn get_symbol_hash(&@crate_ctxt ccx, &ty::t t) -> str {
413-
ret #fmt("_%s_%u", ccx.link_meta_hash, t);
423+
auto hash = "";
424+
alt (ccx.type_sha1s.find(t)) {
425+
case (some(?h)) { hash = h; }
426+
case (none) {
427+
hash =
428+
symbol_hash(ccx.tcx, ccx.sha, t,
429+
ccx.link_meta);
430+
ccx.type_sha1s.insert(t, hash);
431+
}
432+
}
433+
ret hash;
414434
}
415435

416436
fn mangle(&str[] ss) -> str {

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ type crate_ctxt =
136136
hashmap[ast::node_id, str] item_symbols,
137137
mutable option::t[ValueRef] main_fn,
138138
link::link_meta link_meta,
139-
str link_meta_hash,
140139

141140
// TODO: hashmap[tup(tag_id,subtys), @tag_info]
142141
hashmap[ty::t, uint] tag_sizes,
@@ -151,6 +150,7 @@ type crate_ctxt =
151150
@glue_fns glues,
152151
namegen names,
153152
std::sha1::sha1 sha,
153+
hashmap[ty::t, str] type_sha1s,
154154
hashmap[ty::t, str] type_short_names,
155155
ty::ctxt tcx,
156156
stats stats,
@@ -8601,9 +8601,9 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
86018601
auto tag_sizes = map::mk_hashmap[ty::t, uint](hasher, eqer);
86028602
auto tydescs = map::mk_hashmap[ty::t, @tydesc_info](hasher, eqer);
86038603
auto lltypes = map::mk_hashmap[ty::t, TypeRef](hasher, eqer);
8604+
auto sha1s = map::mk_hashmap[ty::t, str](hasher, eqer);
86048605
auto short_names = map::mk_hashmap[ty::t, str](hasher, eqer);
86058606
auto sha = std::sha1::mk_sha1();
8606-
auto link_meta = link::build_link_meta(sess, *crate, output, sha);
86078607
auto ccx =
86088608
@rec(sess=sess,
86098609
llmod=llmod,
@@ -8615,8 +8615,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
86158615
ast_map=amap,
86168616
item_symbols=new_int_hash[str](),
86178617
mutable main_fn=none[ValueRef],
8618-
link_meta=link_meta,
8619-
link_meta_hash=link::hash_link_meta(sha, link_meta),
8618+
link_meta=link::build_link_meta(sess, *crate, output, sha),
86208619
tag_sizes=tag_sizes,
86218620
discrims=new_int_hash[ValueRef](),
86228621
discrim_symbols=new_int_hash[str](),
@@ -8629,6 +8628,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
86298628
glues=glues,
86308629
names=namegen(0),
86318630
sha=sha,
8631+
type_sha1s=sha1s,
86328632
type_short_names=short_names,
86338633
tcx=tcx,
86348634
stats=rec(mutable n_static_tydescs=0u,

0 commit comments

Comments
 (0)