Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_middle/src/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub struct OnDiskCache {
// we try to map an `ExpnHash` to its value in the current
// compilation session.
foreign_expn_data: UnhashMap<ExpnHash, u32>,

fresh: bool,
}

// This type is used only for serialization and deserialization.
Expand Down Expand Up @@ -175,6 +177,7 @@ impl OnDiskCache {
expn_data: footer.expn_data,
foreign_expn_data: footer.foreign_expn_data,
hygiene_context: Default::default(),
fresh: false,
})
}

Expand All @@ -190,9 +193,14 @@ impl OnDiskCache {
expn_data: UnhashMap::default(),
foreign_expn_data: UnhashMap::default(),
hygiene_context: Default::default(),
fresh: true,
}
}

pub fn is_fresh(&self) -> bool {
self.fresh
}

/// Release the serialized backing `Mmap`.
pub fn close_serialized_data_mmap(&self) {
// Obtain a write lock, and replace the mmap with None to drop it.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_query_impl/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tracing::warn;
use crate::dep_graph::{DepNode, DepNodeIndex};
use crate::handle_cycle_error;
use crate::job::{QueryJobInfo, QueryJobMap, create_cycle_error, find_cycle_in_stack};
use crate::plumbing::{current_query_job, loadable_from_disk, next_job_id, start_query};
use crate::plumbing::{current_query_job, loadable_from_disk_incr, next_job_id, start_query};
use crate::query_impl::for_each_query_vtable;

#[inline]
Expand Down Expand Up @@ -604,7 +604,7 @@ fn ensure_can_skip_execution<'tcx, C: QueryCache>(
// for this key.
EnsureMode::Done => {
(query.will_cache_on_disk_for_key_fn)(key)
&& loadable_from_disk(tcx, serialized_dep_node_index)
&& loadable_from_disk_incr(tcx, serialized_dep_node_index)
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ pub(crate) fn promote_from_disk_inner<'tcx, C: QueryCache>(
}
}

pub(crate) fn loadable_from_disk<'tcx>(tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex) -> bool {
if let Some(cache) = tcx.query_system.on_disk_cache.as_ref() {
cache.loadable_from_disk(id)
pub(crate) fn loadable_from_disk_incr<'tcx>(tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex) -> bool {
let cache = tcx.query_system.on_disk_cache.as_ref().unwrap();
if !cache.is_fresh() {
assert!(cache.loadable_from_disk(id));
true
} else {
false
}
Expand Down
Loading