@@ -15,6 +15,7 @@ use rustc_data_structures::fx::FxHashMap;
15
15
use rustc_data_structures:: profiling:: TimingGuard ;
16
16
#[ cfg( parallel_compiler) ]
17
17
use rustc_data_structures:: sharded:: Sharded ;
18
+ use rustc_data_structures:: stack:: ensure_sufficient_stack;
18
19
use rustc_data_structures:: sync:: Lock ;
19
20
use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
20
21
use rustc_session:: Session ;
@@ -348,8 +349,6 @@ where
348
349
349
350
fn try_execute_query < Q , Qcx > (
350
351
qcx : Qcx ,
351
- state : & QueryState < Q :: Key , Qcx :: DepKind > ,
352
- cache : & Q :: Cache ,
353
352
span : Span ,
354
353
key : Q :: Key ,
355
354
dep_node : Option < DepNode < Qcx :: DepKind > > ,
@@ -358,9 +357,11 @@ where
358
357
Q : QueryConfig < Qcx > ,
359
358
Qcx : QueryContext ,
360
359
{
360
+ let state = Q :: query_state ( qcx) ;
361
361
match JobOwner :: < ' _ , Q :: Key , Qcx :: DepKind > :: try_start ( & qcx, state, span, key) {
362
362
TryGetJob :: NotYetStarted ( job) => {
363
363
let ( result, dep_node_index) = execute_job :: < Q , Qcx > ( qcx, key, dep_node, job. id ) ;
364
+ let cache = Q :: query_cache ( qcx) ;
364
365
if Q :: FEEDABLE {
365
366
// We should not compute queries that also got a value via feeding.
366
367
// This can't happen, as query feeding adds the very dependencies to the fed query
@@ -381,7 +382,7 @@ where
381
382
}
382
383
#[ cfg( parallel_compiler) ]
383
384
TryGetJob :: JobCompleted ( query_blocked_prof_timer) => {
384
- let Some ( ( v, index) ) = cache . lookup ( & key) else {
385
+ let Some ( ( v, index) ) = Q :: query_cache ( qcx ) . lookup ( & key) else {
385
386
panic ! ( "value must be in cache after waiting" )
386
387
} ;
387
388
@@ -739,14 +740,8 @@ where
739
740
None
740
741
} ;
741
742
742
- let ( result, dep_node_index) = try_execute_query :: < Q , Qcx > (
743
- qcx,
744
- Q :: query_state ( qcx) ,
745
- Q :: query_cache ( qcx) ,
746
- span,
747
- key,
748
- dep_node,
749
- ) ;
743
+ let ( result, dep_node_index) =
744
+ ensure_sufficient_stack ( || try_execute_query :: < Q , Qcx > ( qcx, span, key, dep_node) ) ;
750
745
if let Some ( dep_node_index) = dep_node_index {
751
746
qcx. dep_context ( ) . dep_graph ( ) . read_index ( dep_node_index)
752
747
}
@@ -762,14 +757,12 @@ where
762
757
{
763
758
// We may be concurrently trying both execute and force a query.
764
759
// Ensure that only one of them runs the query.
765
- let cache = Q :: query_cache ( qcx) ;
766
- if let Some ( ( _, index) ) = cache. lookup ( & key) {
760
+ if let Some ( ( _, index) ) = Q :: query_cache ( qcx) . lookup ( & key) {
767
761
qcx. dep_context ( ) . profiler ( ) . query_cache_hit ( index. into ( ) ) ;
768
762
return ;
769
763
}
770
764
771
- let state = Q :: query_state ( qcx) ;
772
765
debug_assert ! ( !Q :: ANON ) ;
773
766
774
- try_execute_query :: < Q , _ > ( qcx, state , cache , DUMMY_SP , key, Some ( dep_node) ) ;
767
+ ensure_sufficient_stack ( || try_execute_query :: < Q , _ > ( qcx, DUMMY_SP , key, Some ( dep_node) ) ) ;
775
768
}
0 commit comments