about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/dep_graph/dep_node.rs17
-rw-r--r--src/librustc/dep_graph/graph.rs15
-rw-r--r--src/librustc_incremental/persist/data.rs3
-rw-r--r--src/librustc_incremental/persist/load.rs7
-rw-r--r--src/librustc_incremental/persist/work_product.rs3
-rw-r--r--src/librustc_trans/partitioning.rs5
6 files changed, 28 insertions, 22 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs
index 85a02953a91..1a0f89a1e53 100644
--- a/src/librustc/dep_graph/dep_node.rs
+++ b/src/librustc/dep_graph/dep_node.rs
@@ -9,8 +9,10 @@
 // except according to those terms.
 
 use hir::def_id::CrateNum;
+use ich::Fingerprint;
+use rustc_data_structures::stable_hasher::StableHasher;
 use std::fmt::Debug;
-use std::sync::Arc;
+use std::hash::Hash;
 
 macro_rules! try_opt {
     ($e:expr) => (
@@ -56,7 +58,7 @@ pub enum DepNode<D: Clone + Debug> {
 
     /// Represents some artifact that we save to disk. Note that these
     /// do not have a def-id as part of their identifier.
-    WorkProduct(Arc<WorkProductId>),
+    WorkProduct(WorkProductId),
 
     // Represents different phases in the compiler.
     RegionMaps(D),
@@ -318,7 +320,16 @@ impl<D: Clone + Debug> DepNode<D> {
 /// the need to be mapped or unmapped. (This ensures we can serialize
 /// them even in the absence of a tcx.)
 #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
-pub struct WorkProductId(pub String);
+pub struct WorkProductId(pub Fingerprint);
+
+impl WorkProductId {
+    pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
+        let mut hasher = StableHasher::new();
+        cgu_name.len().hash(&mut hasher);
+        cgu_name.hash(&mut hasher);
+        WorkProductId(hasher.finish())
+    }
+}
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
 pub enum GlobalMetaDataKind {
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs
index 18eb4e5d0ad..dc482b0d6ac 100644
--- a/src/librustc/dep_graph/graph.rs
+++ b/src/librustc/dep_graph/graph.rs
@@ -13,7 +13,6 @@ use rustc_data_structures::fx::FxHashMap;
 use session::config::OutputType;
 use std::cell::{Ref, RefCell};
 use std::rc::Rc;
-use std::sync::Arc;
 
 use super::dep_node::{DepNode, WorkProductId};
 use super::query::DepGraphQuery;
@@ -35,10 +34,10 @@ struct DepGraphData {
     /// things available to us. If we find that they are not dirty, we
     /// load the path to the file storing those work-products here into
     /// this map. We can later look for and extract that data.
-    previous_work_products: RefCell<FxHashMap<Arc<WorkProductId>, WorkProduct>>,
+    previous_work_products: RefCell<FxHashMap<WorkProductId, WorkProduct>>,
 
     /// Work-products that we generate in this run.
-    work_products: RefCell<FxHashMap<Arc<WorkProductId>, WorkProduct>>,
+    work_products: RefCell<FxHashMap<WorkProductId, WorkProduct>>,
 }
 
 impl DepGraph {
@@ -120,7 +119,7 @@ impl DepGraph {
     /// Indicates that a previous work product exists for `v`. This is
     /// invoked during initial start-up based on what nodes are clean
     /// (and what files exist in the incr. directory).
-    pub fn insert_previous_work_product(&self, v: &Arc<WorkProductId>, data: WorkProduct) {
+    pub fn insert_previous_work_product(&self, v: &WorkProductId, data: WorkProduct) {
         debug!("insert_previous_work_product({:?}, {:?})", v, data);
         self.data.previous_work_products.borrow_mut()
                                         .insert(v.clone(), data);
@@ -129,7 +128,7 @@ impl DepGraph {
     /// Indicates that we created the given work-product in this run
     /// for `v`. This record will be preserved and loaded in the next
     /// run.
-    pub fn insert_work_product(&self, v: &Arc<WorkProductId>, data: WorkProduct) {
+    pub fn insert_work_product(&self, v: &WorkProductId, data: WorkProduct) {
         debug!("insert_work_product({:?}, {:?})", v, data);
         self.data.work_products.borrow_mut()
                                .insert(v.clone(), data);
@@ -137,7 +136,7 @@ impl DepGraph {
 
     /// Check whether a previous work product exists for `v` and, if
     /// so, return the path that leads to it. Used to skip doing work.
-    pub fn previous_work_product(&self, v: &Arc<WorkProductId>) -> Option<WorkProduct> {
+    pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct> {
         self.data.previous_work_products.borrow()
                                         .get(v)
                                         .cloned()
@@ -145,13 +144,13 @@ impl DepGraph {
 
     /// Access the map of work-products created during this run. Only
     /// used during saving of the dep-graph.
-    pub fn work_products(&self) -> Ref<FxHashMap<Arc<WorkProductId>, WorkProduct>> {
+    pub fn work_products(&self) -> Ref<FxHashMap<WorkProductId, WorkProduct>> {
         self.data.work_products.borrow()
     }
 
     /// Access the map of work-products created during the cached run. Only
     /// used during saving of the dep-graph.
-    pub fn previous_work_products(&self) -> Ref<FxHashMap<Arc<WorkProductId>, WorkProduct>> {
+    pub fn previous_work_products(&self) -> Ref<FxHashMap<WorkProductId, WorkProduct>> {
         self.data.previous_work_products.borrow()
     }
 }
diff --git a/src/librustc_incremental/persist/data.rs b/src/librustc_incremental/persist/data.rs
index 682a7051a1e..4669bb866d4 100644
--- a/src/librustc_incremental/persist/data.rs
+++ b/src/librustc_incremental/persist/data.rs
@@ -15,7 +15,6 @@ use rustc::hir::def_id::DefIndex;
 use rustc::hir::map::DefPathHash;
 use rustc::ich::Fingerprint;
 use rustc::middle::cstore::EncodedMetadataHash;
-use std::sync::Arc;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
 
@@ -98,7 +97,7 @@ pub struct SerializedHash {
 #[derive(Debug, RustcEncodable, RustcDecodable)]
 pub struct SerializedWorkProduct {
     /// node that produced the work-product
-    pub id: Arc<WorkProductId>,
+    pub id: WorkProductId,
 
     /// work-product data itself
     pub work_product: WorkProduct,
diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs
index b30a1f4d325..f2ecf4c74e7 100644
--- a/src/librustc_incremental/persist/load.rs
+++ b/src/librustc_incremental/persist/load.rs
@@ -22,7 +22,6 @@ use rustc_serialize::Decodable as RustcDecodable;
 use rustc_serialize::opaque::Decoder;
 use std::default::Default;
 use std::path::{Path};
-use std::sync::Arc;
 
 use IncrementalHashesMap;
 use super::data::*;
@@ -327,7 +326,7 @@ fn transitive_dirty_nodes(edge_map: &FxHashMap<DepNode<DefPathHash>, Vec<DepNode
 /// otherwise no longer applicable.
 fn reconcile_work_products<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                      work_products: Vec<SerializedWorkProduct>,
-                                     clean_work_products: &FxHashSet<Arc<WorkProductId>>) {
+                                     clean_work_products: &FxHashSet<WorkProductId>) {
     debug!("reconcile_work_products({:?})", work_products);
     for swp in work_products {
         if !clean_work_products.contains(&swp.id) {
@@ -424,8 +423,8 @@ fn process_edges<'a, 'tcx, 'edges>(
     target: &'edges DepNode<DefPathHash>,
     edges: &'edges FxHashMap<DepNode<DefPathHash>, Vec<DepNode<DefPathHash>>>,
     dirty_raw_nodes: &DirtyNodes,
-    clean_work_products: &mut FxHashSet<Arc<WorkProductId>>,
-    dirty_work_products: &mut FxHashSet<Arc<WorkProductId>>,
+    clean_work_products: &mut FxHashSet<WorkProductId>,
+    dirty_work_products: &mut FxHashSet<WorkProductId>,
     extra_edges: &mut Vec<(&'edges DepNode<DefPathHash>, &'edges DepNode<DefPathHash>)>)
 {
     // If the target is dirty, skip the edge. If this is an edge
diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs
index 0e9f9061540..16ab10ab4bb 100644
--- a/src/librustc_incremental/persist/work_product.rs
+++ b/src/librustc_incremental/persist/work_product.rs
@@ -16,7 +16,6 @@ use rustc::session::Session;
 use rustc::session::config::OutputType;
 use rustc::util::fs::link_or_copy;
 use std::path::PathBuf;
-use std::sync::Arc;
 use std::fs as std_fs;
 
 pub fn save_trans_partition(sess: &Session,
@@ -30,7 +29,7 @@ pub fn save_trans_partition(sess: &Session,
     if sess.opts.incremental.is_none() {
         return;
     }
-    let work_product_id = Arc::new(WorkProductId(cgu_name.to_string()));
+    let work_product_id = WorkProductId::from_cgu_name(cgu_name);
 
     let saved_files: Option<Vec<_>> =
         files.iter()
diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs
index 2fe463e92a8..df8984e6d24 100644
--- a/src/librustc_trans/partitioning.rs
+++ b/src/librustc_trans/partitioning.rs
@@ -114,7 +114,6 @@ use rustc::ty::{self, TyCtxt};
 use rustc::ty::item_path::characteristic_def_id_of_type;
 use rustc_incremental::IchHasher;
 use std::hash::Hash;
-use std::sync::Arc;
 use syntax::ast::NodeId;
 use syntax::symbol::{Symbol, InternedString};
 use trans_item::{TransItem, InstantiationMode};
@@ -164,8 +163,8 @@ impl<'tcx> CodegenUnit<'tcx> {
         &self.items
     }
 
-    pub fn work_product_id(&self) -> Arc<WorkProductId> {
-        Arc::new(WorkProductId(self.name().to_string()))
+    pub fn work_product_id(&self) -> WorkProductId {
+        WorkProductId::from_cgu_name(self.name())
     }
 
     pub fn work_product_dep_node(&self) -> DepNode<DefId> {