mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 e7aca89598
			
		
	
	
		e7aca89598
		
	
	
	
	
		
			
			Refactor query system to maintain a global job id counter This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Support for serializing the dep-graph and reloading it.
 | |
| 
 | |
| #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
 | |
| #![feature(crate_visibility_modifier)]
 | |
| #![feature(nll)]
 | |
| #![feature(min_specialization)]
 | |
| #![feature(once_cell)]
 | |
| #![feature(rustc_attrs)]
 | |
| #![recursion_limit = "256"]
 | |
| #![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
 | |
| 
 | |
| #[macro_use]
 | |
| extern crate rustc_macros;
 | |
| #[macro_use]
 | |
| extern crate rustc_middle;
 | |
| 
 | |
| use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 | |
| use rustc_data_structures::sync::AtomicU64;
 | |
| use rustc_middle::arena::Arena;
 | |
| use rustc_middle::dep_graph::{self, DepKindStruct, SerializedDepNodeIndex};
 | |
| use rustc_middle::ty::query::{query_keys, query_storage, query_stored, query_values};
 | |
| use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine};
 | |
| use rustc_middle::ty::{self, TyCtxt};
 | |
| use rustc_span::def_id::LocalDefId;
 | |
| use rustc_span::Span;
 | |
| 
 | |
| #[macro_use]
 | |
| mod plumbing;
 | |
| pub use plumbing::QueryCtxt;
 | |
| use rustc_query_system::query::*;
 | |
| 
 | |
| mod keys;
 | |
| use keys::Key;
 | |
| 
 | |
| mod values;
 | |
| use self::values::Value;
 | |
| 
 | |
| pub use rustc_query_system::query::QueryConfig;
 | |
| pub(crate) use rustc_query_system::query::{QueryDescription, QueryVtable};
 | |
| 
 | |
| mod on_disk_cache;
 | |
| pub use on_disk_cache::OnDiskCache;
 | |
| 
 | |
| mod profiling_support;
 | |
| pub use self::profiling_support::alloc_self_profile_query_strings;
 | |
| 
 | |
| mod util;
 | |
| 
 | |
| fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
 | |
|     if def_id.is_top_level_module() {
 | |
|         "top-level module".to_string()
 | |
|     } else {
 | |
|         format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
 | |
|     }
 | |
| }
 | |
| 
 | |
| rustc_query_append! { [define_queries!][<'tcx>] }
 | |
| 
 | |
| impl<'tcx> Queries<'tcx> {
 | |
|     // Force codegen in the dyn-trait transformation in this crate.
 | |
|     pub fn as_dyn(&'tcx self) -> &'tcx dyn QueryEngine<'tcx> {
 | |
|         self
 | |
|     }
 | |
| }
 |