Skip to content

Commit d7e73e4

Browse files
committed
Auto merge of #44901 - michaelwoerister:on-demand-eval, r=nikomatsakis
incr.comp.: Switch to red/green change tracking, remove legacy system. This PR finally switches incremental compilation to [red/green tracking](#42293) and completely removes the legacy dependency graph implementation -- which includes a few quite costly passes that are simply not needed with the new system anymore. There's still some documentation to be done and there's certainly still lots of optimizing and tuning ahead -- but the foundation for red/green is in place with this PR. This has been in the making for a long time `:)` r? @nikomatsakis cc @alexcrichton, @rust-lang/compiler
2 parents 417ffc9 + 0454a41 commit d7e73e4

File tree

55 files changed

+1088
-2371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1088
-2371
lines changed

src/librustc/dep_graph/dep_node.rs

+15-64
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ use hir::map::DefPathHash;
6565
use hir::{HirId, ItemLocalId};
6666

6767
use ich::Fingerprint;
68-
use ty::{TyCtxt, Instance, InstanceDef};
69-
use ty::fast_reject::SimplifiedType;
68+
use ty::{TyCtxt, Instance, InstanceDef, ParamEnvAnd, Ty};
69+
use ty::subst::Substs;
7070
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
7171
use ich::StableHashingContext;
7272
use std::fmt;
@@ -347,7 +347,7 @@ impl fmt::Debug for DepNode {
347347
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
348348
write!(f, "{:?}", self.kind)?;
349349

350-
if !self.kind.has_params() {
350+
if !self.kind.has_params() && !self.kind.is_anon() {
351351
return Ok(());
352352
}
353353

@@ -356,14 +356,14 @@ impl fmt::Debug for DepNode {
356356
::ty::tls::with_opt(|opt_tcx| {
357357
if let Some(tcx) = opt_tcx {
358358
if let Some(def_id) = self.extract_def_id(tcx) {
359-
write!(f, "{}", tcx.item_path_str(def_id))?;
359+
write!(f, "{}", tcx.def_path(def_id).to_string(tcx))?;
360360
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) {
361361
write!(f, "{}", s)?;
362362
} else {
363-
write!(f, "{:?}", self.hash)?;
363+
write!(f, "{}", self.hash)?;
364364
}
365365
} else {
366-
write!(f, "{:?}", self.hash)?;
366+
write!(f, "{}", self.hash)?;
367367
}
368368
Ok(())
369369
})?;
@@ -430,7 +430,6 @@ define_dep_nodes!( <'tcx>
430430
[] RegionScopeTree(DefId),
431431
[] Coherence,
432432
[] CoherenceInherentImplOverlapCheck,
433-
[] Resolve,
434433
[] CoherenceCheckTrait(DefId),
435434
[] PrivacyAccessLevels(CrateNum),
436435

@@ -447,10 +446,8 @@ define_dep_nodes!( <'tcx>
447446
[] MirBorrowCheck(DefId),
448447
[] UnsafetyViolations(DefId),
449448

450-
[] RvalueCheck(DefId),
451449
[] Reachability,
452450
[] MirKeys,
453-
[] TransWriteMetadata,
454451
[] CrateVariances,
455452

456453
// Nodes representing bits of computed IR in the tcx. Each shared
@@ -484,32 +481,23 @@ define_dep_nodes!( <'tcx>
484481
[] TypeckBodiesKrate,
485482
[] TypeckTables(DefId),
486483
[] HasTypeckTables(DefId),
487-
[anon] ConstEval,
484+
[] ConstEval { param_env: ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)> },
488485
[] SymbolName(DefId),
489486
[] InstanceSymbolName { instance: Instance<'tcx> },
490487
[] SpecializationGraph(DefId),
491488
[] ObjectSafety(DefId),
492489

493-
[anon] IsCopy,
494-
[anon] IsSized,
495-
[anon] IsFreeze,
496-
[anon] NeedsDrop,
497-
[anon] Layout,
490+
[] IsCopy { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
491+
[] IsSized { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
492+
[] IsFreeze { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
493+
[] NeedsDrop { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
494+
[] Layout { param_env: ParamEnvAnd<'tcx, Ty<'tcx>> },
498495

499496
// The set of impls for a given trait.
500497
[] TraitImpls(DefId),
501-
[] RelevantTraitImpls(DefId, SimplifiedType),
502498

503499
[] AllLocalTraitImpls,
504500

505-
// Nodes representing caches. To properly handle a true cache, we
506-
// don't use a DepTrackingMap, but rather we push a task node.
507-
// Otherwise the write into the map would be incorrectly
508-
// attributed to the first task that happened to fill the cache,
509-
// which would yield an overly conservative dep-graph.
510-
[] TraitItems(DefId),
511-
[] ReprHints(DefId),
512-
513501
// Trait selection cache is a little funny. Given a trait
514502
// reference like `Foo: SomeTrait<Bar>`, there could be
515503
// arbitrarily many def-ids to map on in there (e.g., `Foo`,
@@ -537,10 +525,6 @@ define_dep_nodes!( <'tcx>
537525
// trait-select node.
538526
[anon] TraitSelect,
539527

540-
// For proj. cache, we just keep a list of all def-ids, since it is
541-
// not a hotspot.
542-
[] ProjectionCache { def_ids: DefIdList },
543-
544528
[] ParamEnv(DefId),
545529
[] DescribeDef(DefId),
546530
[] DefSpan(DefId),
@@ -598,7 +582,6 @@ define_dep_nodes!( <'tcx>
598582
[] MissingLangItems(CrateNum),
599583
[] ExternConstBody(DefId),
600584
[] VisibleParentMap,
601-
[] IsDirectExternCrate(CrateNum),
602585
[] MissingExternCrateItem(CrateNum),
603586
[] UsedCrateSource(CrateNum),
604587
[] PostorderCnums,
@@ -618,6 +601,9 @@ define_dep_nodes!( <'tcx>
618601
[] CodegenUnit(InternedString),
619602
[] CompileCodegenUnit(InternedString),
620603
[] OutputFilenames,
604+
605+
// We use this for most things when incr. comp. is turned off.
606+
[] Null,
621607
);
622608

623609
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
@@ -719,40 +705,6 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, De
719705
}
720706
}
721707

722-
723-
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIdList,) {
724-
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
725-
726-
// We actually would not need to specialize the implementation of this
727-
// method but it's faster to combine the hashes than to instantiate a full
728-
// hashing context and stable-hashing state.
729-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
730-
let mut fingerprint = Fingerprint::zero();
731-
732-
for &def_id in self.0.iter() {
733-
let def_path_hash = tcx.def_path_hash(def_id);
734-
fingerprint = fingerprint.combine(def_path_hash.0);
735-
}
736-
737-
fingerprint
738-
}
739-
740-
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
741-
use std::fmt::Write;
742-
743-
let mut s = String::new();
744-
write!(&mut s, "[").unwrap();
745-
746-
for &def_id in self.0.iter() {
747-
write!(&mut s, "{}", tcx.def_path(def_id).to_string(tcx)).unwrap();
748-
}
749-
750-
write!(&mut s, "]").unwrap();
751-
752-
s
753-
}
754-
}
755-
756708
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (HirId,) {
757709
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
758710

@@ -811,4 +763,3 @@ impl_stable_hash_for!(struct ::dep_graph::WorkProductId {
811763
hash
812764
});
813765

814-
type DefIdList = Vec<DefId>;

0 commit comments

Comments
 (0)