Auto merge of #87044 - cjgillot:expnhash, r=petrochenkov
Cache expansion hash globally ... instead of computing it multiple times. Split from #86676 r? `@petrochenkov`
This commit is contained in:
commit
c7d6bcc788
12 changed files with 285 additions and 240 deletions
|
@ -16,7 +16,6 @@ use rustc_span::{BytePos, CachingSourceMapView, SourceFile, SpanData};
|
|||
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp::Ord;
|
||||
use std::thread::LocalKey;
|
||||
|
||||
fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
|
||||
debug_assert!(!ich::IGNORED_ATTRIBUTES.is_empty());
|
||||
|
@ -230,13 +229,6 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
|||
self.def_path_hash(def_id)
|
||||
}
|
||||
|
||||
fn expn_id_cache() -> &'static LocalKey<rustc_span::ExpnIdCache> {
|
||||
thread_local! {
|
||||
static CACHE: rustc_span::ExpnIdCache = Default::default();
|
||||
}
|
||||
&CACHE
|
||||
}
|
||||
|
||||
fn span_data_to_lines_and_cols(
|
||||
&mut self,
|
||||
span: &SpanData,
|
||||
|
|
|
@ -25,7 +25,7 @@ use rustc_span::hygiene::{
|
|||
};
|
||||
use rustc_span::source_map::{SourceMap, StableSourceFileId};
|
||||
use rustc_span::CachingSourceMapView;
|
||||
use rustc_span::{BytePos, ExpnData, SourceFile, Span, DUMMY_SP};
|
||||
use rustc_span::{BytePos, ExpnData, ExpnHash, SourceFile, Span, DUMMY_SP};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::mem;
|
||||
|
||||
|
@ -364,9 +364,9 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
syntax_contexts.insert(index, pos);
|
||||
Ok(())
|
||||
},
|
||||
|encoder, index, expn_data| -> FileEncodeResult {
|
||||
|encoder, index, expn_data, hash| -> FileEncodeResult {
|
||||
let pos = AbsoluteBytePos::new(encoder.position());
|
||||
encoder.encode_tagged(TAG_EXPN_DATA, expn_data)?;
|
||||
encoder.encode_tagged(TAG_EXPN_DATA, &(expn_data, hash))?;
|
||||
expn_ids.insert(index, pos);
|
||||
Ok(())
|
||||
},
|
||||
|
@ -804,7 +804,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
|
|||
.unwrap_or_else(|| panic!("Bad index {:?} (map {:?})", index, expn_data));
|
||||
|
||||
this.with_position(pos.to_usize(), |decoder| {
|
||||
let data: ExpnData = decode_tagged(decoder, TAG_EXPN_DATA)?;
|
||||
let data: (ExpnData, ExpnHash) = decode_tagged(decoder, TAG_EXPN_DATA)?;
|
||||
Ok(data)
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue