]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #41056 - michaelwoerister:central-defpath-hashes, r=nikomatsakis
authorCorey Farwell <coreyf@rwell.org>
Fri, 7 Apr 2017 13:20:05 +0000 (09:20 -0400)
committerGitHub <noreply@github.com>
Fri, 7 Apr 2017 13:20:05 +0000 (09:20 -0400)
Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation)

In almost all cases where we construct a `DefPath`, we just hash it and throw it away again immediately.
With this PR, the compiler will immediately compute and store the hash for each `DefPath` as it is allocated. This way we
+ can get rid of any subsequent `DefPath` hash caching (e.g. the `DefPathHashes`),
+ don't need to allocate a transient `Vec` for holding the `DefPath` (although I'm always surprised how little these small, dynamic allocations seem to hurt performance), and
+ we don't hash `DefPath` prefixes over and over again.

That last part is because we construct the hash for `prefix::foo` by hashing `(hash(prefix), foo)` instead of hashing every component of prefix.

The last commit of this PR is pretty neat, I think:
```
The SVH (Strict Version Hash) of a crate is currently computed
by hashing the ICHes (Incremental Computation Hashes) of the
crate's HIR. This is fine, expect that for incr. comp. we compute
two ICH values for each HIR item, one for the complete item and
one that just includes the item's interface. The two hashes are
are needed for dependency tracking but if we are compiling
non-incrementally and just need the ICH values for the SVH,
one of them is enough, giving us the opportunity to save some
work in this case.
```

r? @nikomatsakis

This PR depends on https://github.com/rust-lang/rust/pull/40878 to be merged first (you can ignore the first commit for reviewing, that's just https://github.com/rust-lang/rust/pull/40878).

1  2 
src/librustc_driver/driver.rs

index 0fb386341a9f3e0b1f8ba70a0550777ef1f2efb6,4e6c919c7f5691ed1d05350c1bb15ef07f45c05f..bdb05d06b0b10646b8b75769abe776043d0d9b7e
@@@ -647,8 -647,12 +647,12 @@@ pub fn phase_2_configure_and_expand<F>(
      let mut crate_loader = CrateLoader::new(sess, &cstore, crate_name);
      crate_loader.preprocess(&krate);
      let resolver_arenas = Resolver::arenas();
-     let mut resolver =
-         Resolver::new(sess, &krate, make_glob_map, &mut crate_loader, &resolver_arenas);
+     let mut resolver = Resolver::new(sess,
+                                      &krate,
+                                      crate_name,
+                                      make_glob_map,
+                                      &mut crate_loader,
+                                      &resolver_arenas);
      resolver.whitelisted_legacy_custom_derives = whitelisted_legacy_custom_derives;
      syntax_ext::register_builtins(&mut resolver, syntax_exts, sess.features.borrow().quote);
  
@@@ -889,7 -893,6 +893,7 @@@ pub fn phase_3_run_analysis_passes<'tcx
      rustc_privacy::provide(&mut local_providers);
      typeck::provide(&mut local_providers);
      ty::provide(&mut local_providers);
 +    reachable::provide(&mut local_providers);
  
      let mut extern_providers = ty::maps::Providers::default();
      cstore::provide(&mut extern_providers);