Skip to content

Commit 49e024e

Browse files
committed
Monomorphise the interface.
1 parent e15383c commit 49e024e

File tree

1 file changed

+72
-29
lines changed

1 file changed

+72
-29
lines changed

src/librustc_query_system/query/plumbing.rs

+72-29
Original file line numberDiff line numberDiff line change
@@ -613,23 +613,28 @@ where
613613
}
614614

615615
#[inline(never)]
616-
pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key) -> Q::Stored
616+
fn get_query_impl<CTX, C>(
617+
tcx: CTX,
618+
state: &QueryState<CTX, C>,
619+
span: Span,
620+
key: C::Key,
621+
query: &QueryVtable<CTX, C::Key, C::Value>,
622+
) -> C::Stored
617623
where
618-
Q: QueryDescription<CTX>,
619-
Q::Key: crate::dep_graph::DepNodeParams<CTX>,
620624
CTX: QueryContext,
625+
C: QueryCache,
626+
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
627+
C::Stored: Clone,
621628
{
622-
debug!("ty::query::get_query<{}>(key={:?}, span={:?})", Q::NAME, key, span);
623-
624629
try_get_cached(
625630
tcx,
626-
Q::query_state(tcx),
631+
state,
627632
key,
628633
|value, index| {
629634
tcx.dep_graph().read_index(index);
630635
value.clone()
631636
},
632-
|key, lookup| try_execute_query(tcx, Q::query_state(tcx), span, key, lookup, &Q::VTABLE),
637+
|key, lookup| try_execute_query(tcx, state, span, key, lookup, query),
633638
)
634639
}
635640

@@ -640,21 +645,25 @@ where
640645
/// side-effects -- e.g., in order to report errors for erroneous programs.
641646
///
642647
/// Note: The optimization is only available during incr. comp.
643-
pub fn ensure_query<Q, CTX>(tcx: CTX, key: Q::Key)
644-
where
645-
Q: QueryDescription<CTX>,
646-
Q::Key: crate::dep_graph::DepNodeParams<CTX>,
648+
fn ensure_query_impl<CTX, C>(
649+
tcx: CTX,
650+
state: &QueryState<CTX, C>,
651+
key: C::Key,
652+
query: &QueryVtable<CTX, C::Key, C::Value>,
653+
) where
654+
C: QueryCache,
655+
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
647656
CTX: QueryContext,
648657
{
649-
if Q::EVAL_ALWAYS {
650-
let _ = get_query::<Q, _>(tcx, DUMMY_SP, key);
658+
if query.eval_always {
659+
let _ = get_query_impl(tcx, state, DUMMY_SP, key, query);
651660
return;
652661
}
653662

654663
// Ensuring an anonymous query makes no sense
655-
assert!(!Q::ANON);
664+
assert!(!query.anon);
656665

657-
let dep_node = Q::to_dep_node(tcx, &key);
666+
let dep_node = query.to_dep_node(tcx, &key);
658667

659668
match tcx.dep_graph().try_mark_green_and_read(tcx, &dep_node) {
660669
None => {
@@ -664,39 +673,73 @@ where
664673
// DepNodeIndex. We must invoke the query itself. The performance cost
665674
// this introduces should be negligible as we'll immediately hit the
666675
// in-memory cache, or another query down the line will.
667-
let _ = get_query::<Q, _>(tcx, DUMMY_SP, key);
676+
let _ = get_query_impl(tcx, state, DUMMY_SP, key, query);
668677
}
669678
Some((_, dep_node_index)) => {
670679
tcx.profiler().query_cache_hit(dep_node_index.into());
671680
}
672681
}
673682
}
674683

675-
pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, span: Span, dep_node: DepNode<CTX::DepKind>)
676-
where
677-
Q: QueryDescription<CTX>,
684+
fn force_query_impl<C, CTX>(
685+
tcx: CTX,
686+
state: &QueryState<CTX, C>,
687+
key: C::Key,
688+
span: Span,
689+
dep_node: DepNode<CTX::DepKind>,
690+
query: &QueryVtable<CTX, C::Key, C::Value>,
691+
) where
692+
C: QueryCache,
693+
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
678694
CTX: QueryContext,
679695
{
680696
// We may be concurrently trying both execute and force a query.
681697
// Ensure that only one of them runs the query.
682698

683699
try_get_cached(
684700
tcx,
685-
Q::query_state(tcx),
701+
state,
686702
key,
687703
|_, _| {
688704
// Cache hit, do nothing
689705
},
690706
|key, lookup| {
691-
let job =
692-
match JobOwner::try_start(tcx, Q::query_state(tcx), span, &key, lookup, &Q::VTABLE)
693-
{
694-
TryGetJob::NotYetStarted(job) => job,
695-
TryGetJob::Cycle(_) => return,
696-
#[cfg(parallel_compiler)]
697-
TryGetJob::JobCompleted(_) => return,
698-
};
699-
force_query_with_job(tcx, key, job, dep_node, &Q::VTABLE);
707+
let job = match JobOwner::try_start(tcx, state, span, &key, lookup, query) {
708+
TryGetJob::NotYetStarted(job) => job,
709+
TryGetJob::Cycle(_) => return,
710+
#[cfg(parallel_compiler)]
711+
TryGetJob::JobCompleted(_) => return,
712+
};
713+
force_query_with_job(tcx, key, job, dep_node, query);
700714
},
701715
);
702716
}
717+
718+
pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key) -> Q::Stored
719+
where
720+
Q: QueryDescription<CTX>,
721+
Q::Key: crate::dep_graph::DepNodeParams<CTX>,
722+
CTX: QueryContext,
723+
{
724+
debug!("ty::query::get_query<{}>(key={:?}, span={:?})", Q::NAME, key, span);
725+
726+
get_query_impl(tcx, Q::query_state(tcx), span, key, &Q::VTABLE)
727+
}
728+
729+
pub fn ensure_query<Q, CTX>(tcx: CTX, key: Q::Key)
730+
where
731+
Q: QueryDescription<CTX>,
732+
Q::Key: crate::dep_graph::DepNodeParams<CTX>,
733+
CTX: QueryContext,
734+
{
735+
ensure_query_impl(tcx, Q::query_state(tcx), key, &Q::VTABLE)
736+
}
737+
738+
pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, span: Span, dep_node: DepNode<CTX::DepKind>)
739+
where
740+
Q: QueryDescription<CTX>,
741+
Q::Key: crate::dep_graph::DepNodeParams<CTX>,
742+
CTX: QueryContext,
743+
{
744+
force_query_impl(tcx, Q::query_state(tcx), key, span, dep_node, &Q::VTABLE)
745+
}

0 commit comments

Comments
 (0)