use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
-use crate::errors::Diagnostic;
use crate::hir;
use crate::hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId, LOCAL_CRATE};
use crate::hir::map::definitions::DefPathHash;
use crate::ich::{CachingSourceMapView, Fingerprint};
use crate::mir::{self, interpret};
use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState};
-use rustc_data_structures::fx::FxHashMap;
-use rustc_data_structures::thin_vec::ThinVec;
-use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once};
-use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use crate::rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
SpecializedDecoder, SpecializedEncoder,
UseSpecializedDecodable, UseSpecializedEncodable};
use crate::session::{CrateDisambiguator, Session};
+use crate::ty;
+use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
+use crate::ty::context::TyCtxt;
+use crate::util::common::{time, time_ext};
+
+use errors::Diagnostic;
+use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::thin_vec::ThinVec;
+use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once};
+use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use std::mem;
use syntax::ast::NodeId;
use syntax::source_map::{SourceMap, StableSourceFileId};
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
-use crate::ty;
-use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
-use crate::ty::context::TyCtxt;
-use crate::util::common::time;
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
}
impl<'sess> OnDiskCache<'sess> {
- /// Create a new OnDiskCache instance from the serialized data in `data`.
+ /// Creates a new OnDiskCache instance from the serialized data in `data`.
pub fn new(sess: &'sess Session, data: Vec<u8>, start_pos: usize) -> OnDiskCache<'sess> {
debug_assert!(sess.opts.incremental.is_some());
})
}
- /// Load a diagnostic emitted during the previous compilation session.
+ /// Loads a diagnostic emitted during the previous compilation session.
pub fn load_diagnostics<'a, 'tcx>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex)
diagnostics.unwrap_or_default()
}
- /// Store a diagnostic emitted during the current compilation session.
+ /// Stores a diagnostic emitted during the current compilation session.
/// Anything stored like this will be available via `load_diagnostics` in
/// the next compilation session.
#[inline(never)]
}
/// Returns the cached query result if there is something in the cache for
- /// the given SerializedDepNodeIndex. Otherwise returns None.
+ /// the given `SerializedDepNodeIndex`; otherwise returns `None`.
pub fn try_load_query_result<'tcx, T>(&self,
tcx: TyCtxt<'_, 'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex)
"query result")
}
- /// Store a diagnostic emitted during computation of an anonymous query.
+ /// Stores a diagnostic emitted during computation of an anonymous query.
/// Since many anonymous queries can share the same `DepNode`, we aggregate
/// them -- as opposed to regular queries where we assume that there is a
/// 1:1 relationship between query-key and `DepNode`.
let desc = &format!("encode_query_results for {}",
unsafe { ::std::intrinsics::type_name::<Q>() });
- time(tcx.sess, desc, || {
+ time_ext(tcx.sess.time_extended(), Some(tcx.sess), desc, || {
+ let map = Q::query_cache(tcx).borrow();
+ assert!(map.active.is_empty());
+ for (key, entry) in map.results.iter() {
+ if Q::cache_on_disk(tcx, key.clone()) {
+ let dep_node = SerializedDepNodeIndex::new(entry.index.index());
- let map = Q::query_cache(tcx).borrow();
- assert!(map.active.is_empty());
- for (key, entry) in map.results.iter() {
- if Q::cache_on_disk(tcx, key.clone()) {
- let dep_node = SerializedDepNodeIndex::new(entry.index.index());
+ // Record position of the cache entry
+ query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
- // Record position of the cache entry
- query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
-
- // Encode the type check tables with the SerializedDepNodeIndex
- // as tag.
- encoder.encode_tagged(dep_node, &entry.value)?;
+ // Encode the type check tables with the SerializedDepNodeIndex
+ // as tag.
+ encoder.encode_tagged(dep_node, &entry.value)?;
+ }
}
- }
- Ok(())
+ Ok(())
})
}