Auto merge of #108167 - Zoxc:query-config-instance-slim, r=cjgillot
Make `rustc_query_system` take `QueryConfig` by instance. This allows for easy switching between virtual tables and specialized instances for queries. It also has the benefit of less turbofish. `QueryStorage` has also been merged with `QueryCache`. Split out from https://github.com/rust-lang/rust/pull/107937. r? `@cjgillot`
This commit is contained in:
commit
e3dfeeaa45
7 changed files with 185 additions and 125 deletions
|
@ -13,7 +13,7 @@ use rustc_middle::mir::{self, interpret};
|
|||
use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_query_system::dep_graph::DepContext;
|
||||
use rustc_query_system::query::{QueryCache, QueryContext, QuerySideEffects};
|
||||
use rustc_query_system::query::{QueryCache, QuerySideEffects};
|
||||
use rustc_serialize::{
|
||||
opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder},
|
||||
Decodable, Decoder, Encodable, Encoder,
|
||||
|
@ -1056,24 +1056,24 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for [u8] {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn encode_query_results<'a, 'tcx, CTX, Q>(
|
||||
tcx: CTX,
|
||||
pub fn encode_query_results<'a, 'tcx, Q>(
|
||||
query: Q,
|
||||
qcx: QueryCtxt<'tcx>,
|
||||
encoder: &mut CacheEncoder<'a, 'tcx>,
|
||||
query_result_index: &mut EncodedDepNodeIndex,
|
||||
) where
|
||||
CTX: QueryContext + 'tcx,
|
||||
Q: super::QueryConfig<CTX>,
|
||||
Q: super::QueryConfig<QueryCtxt<'tcx>>,
|
||||
Q::Value: Encodable<CacheEncoder<'a, 'tcx>>,
|
||||
{
|
||||
let _timer = tcx
|
||||
.dep_context()
|
||||
let _timer = qcx
|
||||
.tcx
|
||||
.profiler()
|
||||
.verbose_generic_activity_with_arg("encode_query_results_for", std::any::type_name::<Q>());
|
||||
.verbose_generic_activity_with_arg("encode_query_results_for", query.name());
|
||||
|
||||
assert!(Q::query_state(tcx).all_inactive());
|
||||
let cache = Q::query_cache(tcx);
|
||||
assert!(query.query_state(qcx).all_inactive());
|
||||
let cache = query.query_cache(qcx);
|
||||
cache.iter(&mut |key, value, dep_node| {
|
||||
if Q::cache_on_disk(*tcx.dep_context(), &key) {
|
||||
if query.cache_on_disk(qcx.tcx, &key) {
|
||||
let dep_node = SerializedDepNodeIndex::new(dep_node.index());
|
||||
|
||||
// Record position of the cache entry.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue