about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorTyson Nottingham <tgnottingham@gmail.com>2020-11-03 22:23:08 -0800
committerTyson Nottingham <tgnottingham@gmail.com>2020-11-18 12:49:09 -0800
commitf09d474836d14811af1f9ebead4c1649c54e4e4c (patch)
treeddf66a7bde0377b6618015c6090a0818577f608d /compiler/rustc_middle
parent8d2d0014922e9f541694bfe87642749239990e0e (diff)
downloadrust-f09d474836d14811af1f9ebead4c1649c54e4e4c.tar.gz
rust-f09d474836d14811af1f9ebead4c1649c54e4e4c.zip
Use PackedFingerprint in DepNode to reduce memory consumption
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/dep_graph/dep_node.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs
index a61b9af9bac..9cd3689e897 100644
--- a/compiler/rustc_middle/src/dep_graph/dep_node.rs
+++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs
@@ -61,7 +61,7 @@ use crate::traits::query::{
 use crate::ty::subst::{GenericArg, SubstsRef};
 use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
 
-use rustc_data_structures::fingerprint::Fingerprint;
+use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
 use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
 use rustc_hir::definitions::DefPathHash;
 use rustc_hir::HirId;
@@ -193,6 +193,15 @@ macro_rules! define_dep_nodes {
 
         pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
 
+        // We keep a lot of `DepNode`s in memory during compilation. It's not
+        // required that their size stay the same, but we don't want to change
+        // it inadvertently. This assert just ensures we're aware of any change.
+        #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+        static_assert_size!(DepNode, 17);
+
+        #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
+        static_assert_size!(DepNode, 24);
+
         pub trait DepNodeExt: Sized {
             /// Construct a DepNode from the given DepKind and DefPathHash. This
             /// method will assert that the given DepKind actually requires a
@@ -227,7 +236,7 @@ macro_rules! define_dep_nodes {
                 debug_assert!(kind.can_reconstruct_query_key() && kind.has_params());
                 DepNode {
                     kind,
-                    hash: def_path_hash.0,
+                    hash: PackedFingerprint(def_path_hash.0),
                 }
             }
 
@@ -243,7 +252,7 @@ macro_rules! define_dep_nodes {
             /// has been removed.
             fn extract_def_id(&self, tcx: TyCtxt<'tcx>) -> Option<DefId> {
                 if self.kind.can_reconstruct_query_key() {
-                    let def_path_hash = DefPathHash(self.hash);
+                    let def_path_hash = DefPathHash(self.hash.0);
                     tcx.def_path_hash_to_def_id.as_ref()?.get(&def_path_hash).cloned()
                 } else {
                     None