diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-08-23 07:56:34 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-08-23 10:33:56 -0400 |
| commit | f9230833084118e31b6dd40cccdd7a8b42c8f236 (patch) | |
| tree | a4a9c26f86ea9cef0ae068200cc8cb1170617579 | |
| parent | 484da378452ed123919ee6d4d5a7e4e98c5d4060 (diff) | |
| download | rust-f9230833084118e31b6dd40cccdd7a8b42c8f236.tar.gz rust-f9230833084118e31b6dd40cccdd7a8b42c8f236.zip | |
cache def-path hashes across all items
This seems like approx a 2x win on syntex_syntax.
| -rw-r--r-- | src/librustc_incremental/calculate_svh/mod.rs | 10 | ||||
| -rw-r--r-- | src/librustc_incremental/calculate_svh/svh_visitor.rs | 17 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/librustc_incremental/calculate_svh/mod.rs b/src/librustc_incremental/calculate_svh/mod.rs index d41d718be63..066d6dd05a3 100644 --- a/src/librustc_incremental/calculate_svh/mod.rs +++ b/src/librustc_incremental/calculate_svh/mod.rs @@ -35,6 +35,7 @@ use rustc::hir; use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::hir::intravisit as visit; use rustc::ty::TyCtxt; +use rustc::util::nodemap::DefIdMap; use rustc_data_structures::fnv::FnvHashMap; use self::svh_visitor::StrictVersionHashVisitor; @@ -47,7 +48,9 @@ pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> IncrementalHashesMap { let _ignore = tcx.dep_graph.in_ignore(); let krate = tcx.map.krate(); - let mut visitor = HashItemsVisitor { tcx: tcx, hashes: FnvHashMap() }; + let mut visitor = HashItemsVisitor { tcx: tcx, + hashes: FnvHashMap(), + def_path_hashes: DefIdMap() }; visitor.calculate_def_id(DefId::local(CRATE_DEF_INDEX), |v| visit::walk_crate(v, krate)); krate.visit_all_items(&mut visitor); visitor.compute_crate_hash(); @@ -56,6 +59,7 @@ pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) struct HashItemsVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_path_hashes: DefIdMap<u64>, hashes: IncrementalHashesMap, } @@ -75,7 +79,9 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> { // FIXME: this should use SHA1, not SipHash. SipHash is not // built to avoid collisions. let mut state = SipHasher::new(); - walk_op(&mut StrictVersionHashVisitor::new(&mut state, self.tcx)); + walk_op(&mut StrictVersionHashVisitor::new(&mut state, + self.tcx, + &mut self.def_path_hashes)); let item_hash = state.finish(); self.hashes.insert(DepNode::Hir(def_id), item_hash); debug!("calculate_item_hash: def_id={:?} hash={:?}", def_id, item_hash); diff --git a/src/librustc_incremental/calculate_svh/svh_visitor.rs b/src/librustc_incremental/calculate_svh/svh_visitor.rs index 1e00e0fc562..30c7a04fd7f 100644 --- a/src/librustc_incremental/calculate_svh/svh_visitor.rs +++ b/src/librustc_incremental/calculate_svh/svh_visitor.rs @@ -35,23 +35,24 @@ pub struct StrictVersionHashVisitor<'a, 'tcx: 'a> { pub st: &'a mut SipHasher, // collect a deterministic hash of def-ids that we have seen - def_id_hashes: DefIdMap<u64>, + def_path_hashes: &'a mut DefIdMap<u64>, } impl<'a, 'tcx> StrictVersionHashVisitor<'a, 'tcx> { pub fn new(st: &'a mut SipHasher, - tcx: TyCtxt<'a, 'tcx, 'tcx>) + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_path_hashes: &'a mut DefIdMap<u64>) -> Self { - StrictVersionHashVisitor { st: st, tcx: tcx, def_id_hashes: DefIdMap() } + StrictVersionHashVisitor { st: st, tcx: tcx, def_path_hashes: def_path_hashes } } fn compute_def_id_hash(&mut self, def_id: DefId) -> u64 { let tcx = self.tcx; - *self.def_id_hashes.entry(def_id) - .or_insert_with(|| { - let def_path = tcx.def_path(def_id); - def_path.deterministic_hash(tcx) - }) + *self.def_path_hashes.entry(def_id) + .or_insert_with(|| { + let def_path = tcx.def_path(def_id); + def_path.deterministic_hash(tcx) + }) } } |
