@@ -15,6 +15,7 @@ use rustc_data_structures::fx::FxHashMap;
1515use rustc_data_structures:: profiling:: TimingGuard ;
1616#[ cfg( parallel_compiler) ]
1717use rustc_data_structures:: sharded:: Sharded ;
18+ use rustc_data_structures:: stack:: ensure_sufficient_stack;
1819use rustc_data_structures:: sync:: Lock ;
1920use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
2021use rustc_session:: Session ;
@@ -348,8 +349,6 @@ where
348349
349350fn try_execute_query < Q , Qcx > (
350351 qcx : Qcx ,
351- state : & QueryState < Q :: Key , Qcx :: DepKind > ,
352- cache : & Q :: Cache ,
353352 span : Span ,
354353 key : Q :: Key ,
355354 dep_node : Option < DepNode < Qcx :: DepKind > > ,
@@ -358,9 +357,11 @@ where
358357 Q : QueryConfig < Qcx > ,
359358 Qcx : QueryContext ,
360359{
360+ let state = Q :: query_state ( qcx) ;
361361 match JobOwner :: < ' _ , Q :: Key , Qcx :: DepKind > :: try_start ( & qcx, state, span, key) {
362362 TryGetJob :: NotYetStarted ( job) => {
363363 let ( result, dep_node_index) = execute_job :: < Q , Qcx > ( qcx, key, dep_node, job. id ) ;
364+ let cache = Q :: query_cache ( qcx) ;
364365 if Q :: FEEDABLE {
365366 // We should not compute queries that also got a value via feeding.
366367 // This can't happen, as query feeding adds the very dependencies to the fed query
@@ -381,7 +382,7 @@ where
381382 }
382383 #[ cfg( parallel_compiler) ]
383384 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 {
385386 panic ! ( "value must be in cache after waiting" )
386387 } ;
387388
@@ -739,14 +740,8 @@ where
739740 None
740741 } ;
741742
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) ) ;
750745 if let Some ( dep_node_index) = dep_node_index {
751746 qcx. dep_context ( ) . dep_graph ( ) . read_index ( dep_node_index)
752747 }
@@ -762,14 +757,12 @@ where
762757{
763758 // We may be concurrently trying both execute and force a query.
764759 // 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) {
767761 qcx. dep_context ( ) . profiler ( ) . query_cache_hit ( index. into ( ) ) ;
768762 return ;
769763 }
770764
771- let state = Q :: query_state ( qcx) ;
772765 debug_assert ! ( !Q :: ANON ) ;
773766
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) ) ) ;
775768}
0 commit comments