提交 74d6b850 编写于 作者: M Michael Woerister

incr.comp.: Fix rebase fallout.

上级 d5b1fee6
......@@ -15,7 +15,7 @@
use ich::{self, CachingCodemapView};
use middle::cstore::CrateStore;
use session::config::DebugInfoLevel::NoDebugInfo;
use ty::{self, TyCtxt, fast_reject};
use ty::{TyCtxt, fast_reject};
use session::Session;
use std::cmp::Ord;
......@@ -252,7 +252,7 @@ pub fn unop_can_panic_at_runtime(&self, unop: hir::UnOp) -> bool
}
}
impl<'a, 'gcx, 'lcx> StableHashingContextProvider for ty::TyCtxt<'a, 'gcx, 'lcx> {
impl<'a, 'gcx, 'lcx> StableHashingContextProvider for TyCtxt<'a, 'gcx, 'lcx> {
type ContextType = StableHashingContext<'gcx>;
fn create_stable_hashing_context(&self) -> Self::ContextType {
(*self).create_stable_hashing_context()
......
......@@ -332,10 +332,8 @@ fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
debug!("EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
def_id={:?}",
self.infcx.tcx.hir.local_def_id(id),
def_id);
if self.infcx.tcx.hir.local_def_id(id) == def_id {
def_id={:?}", id, def_id);
if id == def_id {
self.found_it = true;
return; // we can stop visiting now
}
......@@ -344,11 +342,9 @@ fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
(Some(rl::Region::LateBound(debruijn_index, id)), ty::BrNamed(def_id, _)) => {
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
debruijn_index.depth);
debug!("self.infcx.tcx.hir.local_def_id(id)={:?}",
self.infcx.tcx.hir.local_def_id(id));
debug!("id={:?}", id);
debug!("def_id={:?}", def_id);
if debruijn_index.depth == self.depth &&
self.infcx.tcx.hir.local_def_id(id) == def_id {
if debruijn_index.depth == self.depth && id == def_id {
self.found_it = true;
return; // we can stop visiting now
}
......
......@@ -19,6 +19,11 @@ pub enum SymbolExportLevel {
Rust,
}
impl_stable_hash_for!(enum self::SymbolExportLevel {
C,
Rust
});
impl SymbolExportLevel {
pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool {
if threshold == SymbolExportLevel::Rust {
......
......@@ -12,6 +12,9 @@
use syntax::symbol::InternedString;
use ty::Instance;
use util::nodemap::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasherResult,
StableHasher};
use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode};
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
pub enum TransItem<'tcx> {
......@@ -20,6 +23,26 @@ pub enum TransItem<'tcx> {
GlobalAsm(NodeId),
}
impl<'tcx> HashStable<StableHashingContext<'tcx>> for TransItem<'tcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
::std::mem::discriminant(self).hash_stable(hcx, hasher);
match *self {
TransItem::Fn(ref instance) => {
instance.hash_stable(hcx, hasher);
}
TransItem::Static(node_id) |
TransItem::GlobalAsm(node_id) => {
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
node_id.hash_stable(hcx, hasher);
})
}
}
}
}
pub struct CodegenUnit<'tcx> {
/// A name for this CGU. Incremental compilation requires that
/// name be unique amongst **all** crates. Therefore, it should
......@@ -44,6 +67,20 @@ pub enum Linkage {
Common,
}
impl_stable_hash_for!(enum self::Linkage {
External,
AvailableExternally,
LinkOnceAny,
LinkOnceODR,
WeakAny,
WeakODR,
Appending,
Internal,
Private,
ExternalWeak,
Common
});
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum Visibility {
Default,
......@@ -51,6 +88,12 @@ pub enum Visibility {
Protected,
}
impl_stable_hash_for!(enum self::Visibility {
Default,
Hidden,
Protected
});
impl<'tcx> CodegenUnit<'tcx> {
pub fn new(name: InternedString) -> CodegenUnit<'tcx> {
CodegenUnit {
......@@ -78,6 +121,29 @@ pub fn items_mut(&mut self)
}
}
impl<'tcx> HashStable<StableHashingContext<'tcx>> for CodegenUnit<'tcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) {
let CodegenUnit {
ref items,
name,
} = *self;
name.hash_stable(hcx, hasher);
let mut items: Vec<(Fingerprint, _)> = items.iter().map(|(trans_item, &attrs)| {
let mut hasher = StableHasher::new();
trans_item.hash_stable(hcx, &mut hasher);
let trans_item_fingerprint = hasher.finish();
(trans_item_fingerprint, attrs)
}).collect();
items.sort_unstable_by_key(|i| i.0);
items.hash_stable(hcx, hasher);
}
}
#[derive(Clone, Default)]
pub struct Stats {
pub n_glues_created: usize,
......@@ -92,6 +158,18 @@ pub struct Stats {
pub fn_stats: Vec<(String, usize)>,
}
impl_stable_hash_for!(struct self::Stats {
n_glues_created,
n_null_glues,
n_real_glues,
n_fns,
n_inlines,
n_closures,
n_llvm_insns,
llvm_insns,
fn_stats
});
impl Stats {
pub fn extend(&mut self, stats: Stats) {
self.n_glues_created += stats.n_glues_created;
......@@ -108,3 +186,4 @@ pub fn extend(&mut self, stats: Stats) {
self.fn_stats.extend(stats.fn_stats);
}
}
......@@ -19,8 +19,10 @@
use session::{early_error, early_warn, Session};
use session::search_paths::SearchPaths;
use ich::StableHashingContext;
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::Target;
use rustc_data_structures::stable_hasher::ToStableHashKey;
use lint;
use middle::cstore;
......@@ -90,6 +92,25 @@ pub enum OutputType {
DepInfo,
}
impl_stable_hash_for!(enum self::OutputType {
Bitcode,
Assembly,
LlvmAssembly,
Mir,
Metadata,
Object,
Exe,
DepInfo
});
impl<'tcx> ToStableHashKey<StableHashingContext<'tcx>> for OutputType {
type KeyType = OutputType;
#[inline]
fn to_stable_hash_key(&self, _: &StableHashingContext<'tcx>) -> Self::KeyType {
*self
}
}
impl OutputType {
fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
match *self {
......@@ -149,6 +170,10 @@ fn default() -> ErrorOutputType {
#[derive(Clone, Hash)]
pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
impl_stable_hash_for!(tuple_struct self::OutputTypes {
map
});
impl OutputTypes {
pub fn new(entries: &[(OutputType, Option<PathBuf>)]) -> OutputTypes {
OutputTypes(BTreeMap::from_iter(entries.iter()
......@@ -373,6 +398,14 @@ pub struct OutputFilenames {
pub outputs: OutputTypes,
}
impl_stable_hash_for!(struct self::OutputFilenames {
out_directory,
out_filestem,
single_output_file,
extra,
outputs
});
/// Codegen unit names generated by the numbered naming scheme will contain this
/// marker right before the index of the codegen unit.
pub const NUMBERED_CODEGEN_UNIT_MARKER: &'static str = ".cgu-";
......
......@@ -386,6 +386,14 @@ fn hash_stable<W: StableHasherResult>(&self,
}
}
impl<HCX> ToStableHashKey<HCX> for String {
type KeyType = String;
#[inline]
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
self.clone()
}
}
impl<CTX> HashStable<CTX> for bool {
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
......
......@@ -41,7 +41,6 @@
use rustc::middle::cstore::{EncodedMetadata, EncodedMetadataHashes};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::dep_graph::AssertDepGraphSafe;
use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
use rustc::hir::map as hir_map;
use rustc::util::common::{time, print_time_passes_entry};
......@@ -894,7 +893,7 @@ fn iter_globals(llmod: llvm::ModuleRef) -> ValueIter {
/// This list is later used by linkers to determine the set of symbols needed to
/// be exposed from a dynamic library and it's also encoded into the metadata.
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
tcx.reachable_set(LOCAL_CRATE).iter().cloned().filter(|&id| {
tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| {
// Next, we want to ignore some FFI functions that are not exposed from
// this crate. Reachable FFI functions can be lumped into two
// categories:
......@@ -1370,8 +1369,8 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let dep_node = cgu.work_product_dep_node();
let ((stats, module), _) =
tcx.dep_graph.with_task(dep_node,
AssertDepGraphSafe(tcx),
AssertDepGraphSafe(cgu),
tcx,
cgu,
module_translation);
let time_to_translate = start_time.elapsed();
......@@ -1392,14 +1391,10 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return stats;
fn module_translation<'a, 'tcx>(
tcx: AssertDepGraphSafe<TyCtxt<'a, 'tcx, 'tcx>>,
args: AssertDepGraphSafe<Arc<CodegenUnit<'tcx>>>)
tcx: TyCtxt<'a, 'tcx, 'tcx>,
cgu: Arc<CodegenUnit<'tcx>>)
-> (Stats, ModuleTranslation)
{
// FIXME(#40304): We ought to be using the id as a key and some queries, I think.
let AssertDepGraphSafe(tcx) = tcx;
let AssertDepGraphSafe(cgu) = args;
let cgu_name = cgu.name().to_string();
let cgu_id = cgu.work_product_id();
let symbol_name_hash = cgu.compute_symbol_name_hash(tcx);
......@@ -1564,6 +1559,7 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
Visibility::Default => llvm::Visibility::Default,
Visibility::Hidden => llvm::Visibility::Hidden,
Visibility::Protected => llvm::Visibility::Protected,
}
}
// FIXME(mw): Anything that is produced via DepGraph::with_task() must implement
......@@ -1577,17 +1573,8 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
mod temp_stable_hash_impls {
use rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher,
HashStable};
use context::Stats;
use ModuleTranslation;
impl<HCX> HashStable<HCX> for Stats {
fn hash_stable<W: StableHasherResult>(&self,
_: &mut HCX,
_: &mut StableHasher<W>) {
// do nothing
}
}
impl<HCX> HashStable<HCX> for ModuleTranslation {
fn hash_stable<W: StableHasherResult>(&self,
_: &mut HCX,
......
......@@ -27,9 +27,8 @@
use rustc_data_structures::base_n;
use rustc::middle::trans::Stats;
use rustc_data_structures::stable_hasher::StableHashingContextProvider;
use rustc::session::config::{self, NoDebugInfo, OutputFilenames};
use rustc::session::Session;
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::Session;
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::util::nodemap::FxHashMap;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册