Skip to content

Commit

Permalink
rename HashesMap to IncrementalHashesMap
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Aug 23, 2016
1 parent 226e1e5 commit 484da37
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 43 deletions.
30 changes: 15 additions & 15 deletions src/librustc_driver/driver.rs
Expand Up @@ -26,7 +26,7 @@ use rustc::util::common::time;
use rustc::util::nodemap::NodeSet;
use rustc_back::sha2::{Sha256, Digest};
use rustc_borrowck as borrowck;
use rustc_incremental::{self, HashesMap};
use rustc_incremental::{self, IncrementalHashesMap};
use rustc_resolve::{MakeGlobMap, Resolver};
use rustc_metadata::macro_import;
use rustc_metadata::creader::read_local_crates;
Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn compile_input(sess: &Session,
resolutions,
&arenas,
&crate_name,
|tcx, mir_map, analysis, hashes_map, result| {
|tcx, mir_map, analysis, incremental_hashes_map, result| {
{
// Eventually, we will want to track plugins.
let _ignore = tcx.dep_graph.in_ignore();
Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn compile_input(sess: &Session,
let trans = phase_4_translate_to_llvm(tcx,
mir_map.unwrap(),
analysis,
&hashes_map);
&incremental_hashes_map);

if log_enabled!(::log::INFO) {
println!("Post-trans");
Expand Down Expand Up @@ -798,7 +798,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
where F: for<'a> FnOnce(TyCtxt<'a, 'tcx, 'tcx>,
Option<MirMap<'tcx>>,
ty::CrateAnalysis,
HashesMap,
IncrementalHashesMap,
CompileResult) -> R
{
macro_rules! try_with_f {
Expand Down Expand Up @@ -862,16 +862,16 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
index,
name,
|tcx| {
let hashes_map =
let incremental_hashes_map =
time(time_passes,
"compute_hashes_map",
|| rustc_incremental::compute_hashes_map(tcx));
"compute_incremental_hashes_map",
|| rustc_incremental::compute_incremental_hashes_map(tcx));
time(time_passes,
"load_dep_graph",
|| rustc_incremental::load_dep_graph(tcx, &hashes_map));
|| rustc_incremental::load_dep_graph(tcx, &incremental_hashes_map));

// passes are timed inside typeck
try_with_f!(typeck::check_crate(tcx), (tcx, None, analysis, hashes_map));
try_with_f!(typeck::check_crate(tcx), (tcx, None, analysis, incremental_hashes_map));

time(time_passes,
"const checking",
Expand Down Expand Up @@ -941,7 +941,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
// lint warnings and so on -- kindck used to do this abort, but
// kindck is gone now). -nmatsakis
if sess.err_count() > 0 {
return Ok(f(tcx, Some(mir_map), analysis, hashes_map, Err(sess.err_count())));
return Ok(f(tcx, Some(mir_map), analysis, incremental_hashes_map, Err(sess.err_count())));
}

analysis.reachable =
Expand Down Expand Up @@ -969,18 +969,18 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,

// The above three passes generate errors w/o aborting
if sess.err_count() > 0 {
return Ok(f(tcx, Some(mir_map), analysis, hashes_map, Err(sess.err_count())));
return Ok(f(tcx, Some(mir_map), analysis, incremental_hashes_map, Err(sess.err_count())));
}

Ok(f(tcx, Some(mir_map), analysis, hashes_map, Ok(())))
Ok(f(tcx, Some(mir_map), analysis, incremental_hashes_map, Ok(())))
})
}

/// Run the translation phase to LLVM, after which the AST and analysis can
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
mut mir_map: MirMap<'tcx>,
analysis: ty::CrateAnalysis,
hashes_map: &HashesMap)
incremental_hashes_map: &IncrementalHashesMap)
-> trans::CrateTranslation {
let time_passes = tcx.sess.time_passes();

Expand Down Expand Up @@ -1014,15 +1014,15 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let translation =
time(time_passes,
"translation",
move || trans::trans_crate(tcx, &mir_map, analysis, &hashes_map));
move || trans::trans_crate(tcx, &mir_map, analysis, &incremental_hashes_map));

time(time_passes,
"assert dep graph",
move || rustc_incremental::assert_dep_graph(tcx));

time(time_passes,
"serialize dep graph",
move || rustc_incremental::save_dep_graph(tcx, &hashes_map));
move || rustc_incremental::save_dep_graph(tcx, &incremental_hashes_map));

translation
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_incremental/calculate_svh/mod.rs
Expand Up @@ -41,9 +41,10 @@ use self::svh_visitor::StrictVersionHashVisitor;

mod svh_visitor;

pub type HashesMap = FnvHashMap<DepNode<DefId>, u64>;
pub type IncrementalHashesMap = FnvHashMap<DepNode<DefId>, u64>;

pub fn compute_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> HashesMap {
pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> IncrementalHashesMap {
let _ignore = tcx.dep_graph.in_ignore();
let krate = tcx.map.krate();
let mut visitor = HashItemsVisitor { tcx: tcx, hashes: FnvHashMap() };
Expand All @@ -55,7 +56,7 @@ pub fn compute_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> HashesMa

struct HashItemsVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes: HashesMap,
hashes: IncrementalHashesMap,
}

impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_incremental/lib.rs
Expand Up @@ -38,8 +38,8 @@ mod calculate_svh;
mod persist;

pub use assert_dep_graph::assert_dep_graph;
pub use calculate_svh::compute_hashes_map;
pub use calculate_svh::HashesMap;
pub use calculate_svh::compute_incremental_hashes_map;
pub use calculate_svh::IncrementalHashesMap;
pub use persist::load_dep_graph;
pub use persist::save_dep_graph;
pub use persist::save_trans_partition;
Expand Down
12 changes: 7 additions & 5 deletions src/librustc_incremental/persist/hash.rs
Expand Up @@ -20,22 +20,24 @@ use std::io::{ErrorKind, Read};
use std::fs::File;
use syntax::ast;

use HashesMap;
use IncrementalHashesMap;
use super::data::*;
use super::util::*;

pub struct HashContext<'a, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes_map: &'a HashesMap,
incremental_hashes_map: &'a IncrementalHashesMap,
item_metadata_hashes: FnvHashMap<DefId, u64>,
crate_hashes: FnvHashMap<ast::CrateNum, Svh>,
}

impl<'a, 'tcx> HashContext<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, hashes_map: &'a HashesMap) -> Self {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
incremental_hashes_map: &'a IncrementalHashesMap)
-> Self {
HashContext {
tcx: tcx,
hashes_map: hashes_map,
incremental_hashes_map: incremental_hashes_map,
item_metadata_hashes: FnvHashMap(),
crate_hashes: FnvHashMap(),
}
Expand Down Expand Up @@ -63,7 +65,7 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
def_id,
self.tcx.item_path_str(def_id));

Some((def_id, self.hashes_map[dep_node]))
Some((def_id, self.incremental_hashes_map[dep_node]))
}

// MetaData from other crates is an *input* to us.
Expand Down
21 changes: 12 additions & 9 deletions src/librustc_incremental/persist/load.rs
Expand Up @@ -22,7 +22,7 @@ use std::io::Read;
use std::fs::{self, File};
use std::path::{Path};

use HashesMap;
use IncrementalHashesMap;
use super::data::*;
use super::directory::*;
use super::dirty_clean;
Expand All @@ -40,17 +40,17 @@ type CleanEdges = Vec<(DepNode<DefId>, DepNode<DefId>)>;
/// actually it doesn't matter all that much.) See `README.md` for
/// more general overview.
pub fn load_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes: &HashesMap) {
incremental_hashes_map: &IncrementalHashesMap) {
if tcx.sess.opts.incremental.is_none() {
return;
}

let _ignore = tcx.dep_graph.in_ignore();
load_dep_graph_if_exists(tcx, hashes);
load_dep_graph_if_exists(tcx, incremental_hashes_map);
}

fn load_dep_graph_if_exists<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes: &HashesMap) {
incremental_hashes_map: &IncrementalHashesMap) {
let dep_graph_path = dep_graph_path(tcx).unwrap();
let dep_graph_data = match load_data(tcx.sess, &dep_graph_path) {
Some(p) => p,
Expand All @@ -63,7 +63,7 @@ fn load_dep_graph_if_exists<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
None => return // no file
};

match decode_dep_graph(tcx, hashes, &dep_graph_data, &work_products_data) {
match decode_dep_graph(tcx, incremental_hashes_map, &dep_graph_data, &work_products_data) {
Ok(dirty_nodes) => dirty_nodes,
Err(err) => {
tcx.sess.warn(
Expand Down Expand Up @@ -100,7 +100,7 @@ fn load_data(sess: &Session, path: &Path) -> Option<Vec<u8>> {
/// Decode the dep graph and load the edges/nodes that are still clean
/// into `tcx.dep_graph`.
pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes: &HashesMap,
incremental_hashes_map: &IncrementalHashesMap,
dep_graph_data: &[u8],
work_products_data: &[u8])
-> Result<(), Error>
Expand Down Expand Up @@ -137,7 +137,10 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// reason for this is that this way we can include nodes that have
// been removed (which no longer have a `DefId` in the current
// compilation).
let dirty_raw_source_nodes = dirty_nodes(tcx, hashes, &serialized_dep_graph.hashes, &retraced);
let dirty_raw_source_nodes = dirty_nodes(tcx,
incremental_hashes_map,
&serialized_dep_graph.hashes,
&retraced);

// Create a list of (raw-source-node ->
// retracted-target-node) edges. In the process of retracing the
Expand Down Expand Up @@ -210,11 +213,11 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// Computes which of the original set of def-ids are dirty. Stored in
/// a bit vector where the index is the DefPathIndex.
fn dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hashes: &HashesMap,
incremental_hashes_map: &IncrementalHashesMap,
serialized_hashes: &[SerializedHash],
retraced: &RetracedDefIdDirectory)
-> DirtyNodes {
let mut hcx = HashContext::new(tcx, hashes);
let mut hcx = HashContext::new(tcx, incremental_hashes_map);
let mut dirty_nodes = FnvHashSet();

for hash in serialized_hashes {
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_incremental/persist/save.rs
Expand Up @@ -21,21 +21,22 @@ use std::io::{self, Cursor, Write};
use std::fs::{self, File};
use std::path::PathBuf;

use HashesMap;
use IncrementalHashesMap;
use super::data::*;
use super::directory::*;
use super::hash::*;
use super::preds::*;
use super::util::*;

pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hashes_map: &HashesMap) {
pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
incremental_hashes_map: &IncrementalHashesMap) {
debug!("save_dep_graph()");
let _ignore = tcx.dep_graph.in_ignore();
let sess = tcx.sess;
if sess.opts.incremental.is_none() {
return;
}
let mut hcx = HashContext::new(tcx, hashes_map);
let mut hcx = HashContext::new(tcx, incremental_hashes_map);
let mut builder = DefIdDirectoryBuilder::new(tcx);
let query = tcx.dep_graph.query();
let preds = Predecessors::new(&query, &mut hcx);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/back/link.rs
Expand Up @@ -28,7 +28,7 @@ use util::fs::fix_windows_verbatim_for_gcc;
use rustc::dep_graph::DepNode;
use rustc::hir::svh::Svh;
use rustc_back::tempdir::TempDir;
use rustc_incremental::HashesMap;
use rustc_incremental::IncrementalHashesMap;

use std::ascii;
use std::char;
Expand Down Expand Up @@ -125,12 +125,12 @@ pub fn find_crate_name(sess: Option<&Session>,

}

pub fn build_link_meta(hashes_map: &HashesMap,
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
name: &str)
-> LinkMeta {
let r = LinkMeta {
crate_name: name.to_owned(),
crate_hash: Svh::new(hashes_map[&DepNode::Krate]),
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate]),
};
info!("{:?}", r);
return r;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/base.rs
Expand Up @@ -48,7 +48,7 @@ use rustc::hir::map as hir_map;
use rustc::util::common::time;
use rustc::mir::mir_map::MirMap;
use rustc_data_structures::graph::OUTGOING;
use rustc_incremental::HashesMap;
use rustc_incremental::IncrementalHashesMap;
use session::config::{self, NoDebugInfo, FullDebugInfo};
use session::Session;
use _match;
Expand Down Expand Up @@ -2483,7 +2483,7 @@ pub fn filter_reachable_ids(tcx: TyCtxt, reachable: NodeSet) -> NodeSet {
pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
mir_map: &MirMap<'tcx>,
analysis: ty::CrateAnalysis,
hashes_map: &HashesMap)
incremental_hashes_map: &IncrementalHashesMap)
-> CrateTranslation {
let _task = tcx.dep_graph.in_task(DepNode::TransCrate);

Expand All @@ -2508,7 +2508,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.sess.opts.debug_assertions
};

let link_meta = link::build_link_meta(hashes_map, name);
let link_meta = link::build_link_meta(incremental_hashes_map, name);

let shared_ccx = SharedCrateContext::new(tcx,
&mir_map,
Expand Down

0 comments on commit 484da37

Please sign in to comment.