From 302935ff2a169d57cdde78f17591e13e8aa47f9e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 21 Jun 2017 11:34:33 -0700 Subject: [PATCH] Revert a few changes --- src/librustc/hir/map/definitions.rs | 27 ++++++++-------- src/librustc_metadata/creader.rs | 48 +++++------------------------ 2 files changed, 19 insertions(+), 56 deletions(-) diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 5322d24e389..c969aef675f 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -55,19 +55,12 @@ fn clone(&self) -> Self { } impl DefPathTable { - pub fn new() -> Self { - DefPathTable { - index_to_key: [vec![], vec![]], - key_to_index: FxHashMap(), - def_path_hashes: [vec![], vec![]], - } - } - pub fn allocate(&mut self, - key: DefKey, - def_path_hash: DefPathHash, - address_space: DefIndexAddressSpace) - -> DefIndex { + fn allocate(&mut self, + key: DefKey, + def_path_hash: DefPathHash, + address_space: DefIndexAddressSpace) + -> DefIndex { let index = { let index_to_key = &mut self.index_to_key[address_space.index()]; let index = DefIndex::new(index_to_key.len() + address_space.start()); @@ -248,7 +241,7 @@ pub struct DefKey { } impl DefKey { - pub fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash { + fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash { let mut hasher = StableHasher::new(); // We hash a 0u8 here to disambiguate between regular DefPath hashes, @@ -291,7 +284,7 @@ pub fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash { DefPathHash(hasher.finish()) } - pub fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash { + fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash { let mut hasher = StableHasher::new(); // Disambiguate this from a regular DefPath hash, // see compute_stable_hash() above. @@ -453,7 +446,11 @@ impl Definitions { /// Create new empty definition map. pub fn new() -> Definitions { Definitions { - table: DefPathTable::new(), + table: DefPathTable { + index_to_key: [vec![], vec![]], + key_to_index: FxHashMap(), + def_path_hashes: [vec![], vec![]], + }, node_to_def_index: NodeMap(), def_index_to_node: [vec![], vec![]], node_to_hir_id: IndexVec::new(), diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index e008a5cd9ea..27c2d22168c 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -14,7 +14,7 @@ use locator::{self, CratePaths}; use schema::{CrateRoot, Tracked}; -use rustc::hir::def_id::{CrateNum, DefIndex, CRATE_DEF_INDEX}; +use rustc::hir::def_id::{CrateNum, DefIndex}; use rustc::hir::svh::Svh; use rustc::middle::cstore::DepKind; use rustc::session::Session; @@ -26,8 +26,7 @@ use rustc::util::common::record_time; use rustc::util::nodemap::FxHashSet; use rustc::middle::cstore::NativeLibrary; -use rustc::hir::map::{Definitions, DefKey, DefPathData, DisambiguatedDefPathData, ITEM_LIKE_SPACE}; -use rustc::hir::map::definitions::DefPathTable; +use rustc::hir::map::Definitions; use std::cell::{RefCell, Cell}; use std::ops::Deref; @@ -308,16 +307,9 @@ fn register_crate(&mut self, let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind); - let proc_macros = crate_root.macro_derive_registrar.map(|_| { - self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span) + let def_path_table = record_time(&self.sess.perf_stats.decode_def_path_tables_time, || { + crate_root.def_path_table.decode(&metadata) }); - let def_path_table = if let Some(ref proc_macros) = proc_macros { - proc_macro_def_path_table(proc_macros) - } else { - record_time(&self.sess.perf_stats.decode_def_path_tables_time, || { - crate_root.def_path_table.decode(&metadata) - }) - }; let exported_symbols = crate_root.exported_symbols .map(|x| x.decode(&metadata).collect()); @@ -336,7 +328,9 @@ fn register_crate(&mut self, def_path_table: Rc::new(def_path_table), exported_symbols: exported_symbols, trait_impls: trait_impls, - proc_macros: proc_macros, + proc_macros: crate_root.macro_derive_registrar.map(|_| { + self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span) + }), root: crate_root, blob: metadata, cnum_map: RefCell::new(cnum_map), @@ -1219,31 +1213,3 @@ fn process_item(&mut self, item: &ast::Item, definitions: &Definitions) { } } } - -fn proc_macro_def_path_table(proc_macros: &[(ast::Name, Rc)]) -> DefPathTable { - let mut table = DefPathTable::new(); - let root = DefKey { - parent: None, - disambiguated_data: DisambiguatedDefPathData { - data: DefPathData::CrateRoot, - disambiguator: 0, - }, - }; - - let initial_hash = DefKey::root_parent_stable_hash("", ""); - let root_hash = root.compute_stable_hash(initial_hash); - let root_id = table.allocate(root, root_hash, ITEM_LIKE_SPACE); - let root_path_hash = table.def_path_hash(root_id); - for proc_macro in proc_macros { - let key = DefKey { - parent: Some(CRATE_DEF_INDEX), - disambiguated_data: DisambiguatedDefPathData { - data: DefPathData::MacroDef(proc_macro.0), - disambiguator: 0, - }, - }; - let def_path_hash = key.compute_stable_hash(root_path_hash); - table.allocate(key, def_path_hash, ITEM_LIKE_SPACE); - } - table -} -- 2.44.0