diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-20 11:59:05 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-20 12:11:28 -0500 |
| commit | 8443816176199e3b552f26050aa67ea3c3a2173d (patch) | |
| tree | f72034fbde7dac466a51b5cd82ad7c8563774e31 /compiler/rustc_query_system/src/query | |
| parent | 75ef06892089e0cf53b4a86419c7ff3b3c1f3c4c (diff) | |
| download | rust-8443816176199e3b552f26050aa67ea3c3a2173d.tar.gz rust-8443816176199e3b552f26050aa67ea3c3a2173d.zip | |
Inline QueryStateShard into QueryState
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index d55afaa0cb0..aa79b5a64d7 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -33,18 +33,8 @@ fn hash_for_shard<K: Hash>(key: &K) -> u64 { hasher.finish() } -struct QueryStateShard<K> { - active: FxHashMap<K, QueryResult>, -} - -impl<K> Default for QueryStateShard<K> { - fn default() -> QueryStateShard<K> { - QueryStateShard { active: Default::default() } - } -} - pub struct QueryState<K> { - shards: Sharded<QueryStateShard<K>>, + shards: Sharded<FxHashMap<K, QueryResult>>, } /// Indicates the state of a query for a given key in a query map. @@ -63,7 +53,7 @@ where { pub fn all_inactive(&self) -> bool { let shards = self.shards.lock_shards(); - shards.iter().all(|shard| shard.active.is_empty()) + shards.iter().all(|shard| shard.is_empty()) } pub fn try_collect_active_jobs<CTX: Copy>( @@ -76,7 +66,7 @@ where // deadlock handler, and this shouldn't be locked. let shards = self.shards.try_lock_shards()?; for shard in shards.iter() { - for (k, v) in shard.active.iter() { + for (k, v) in shard.iter() { if let QueryResult::Started(ref job) = *v { let query = make_query(tcx, k.clone()); jobs.insert(job.id, QueryJobInfo { query, job: job.clone() }); @@ -148,7 +138,7 @@ where let mut state_lock = state.shards.get_shard_by_value(&key).lock(); let lock = &mut *state_lock; - match lock.active.entry(key) { + match lock.entry(key) { Entry::Vacant(entry) => { let id = tcx.next_job_id(); let job = tcx.current_query_job(); @@ -220,7 +210,7 @@ where let shard = get_shard_index_by_hash(key_hash); let job = { let mut lock = state.shards.get_shard_by_index(shard).lock(); - match lock.active.remove(&key).unwrap() { + match lock.remove(&key).unwrap() { QueryResult::Started(job) => job, QueryResult::Poisoned => panic!(), } @@ -246,11 +236,11 @@ where let shard = state.shards.get_shard_by_value(&self.key); let job = { let mut shard = shard.lock(); - let job = match shard.active.remove(&self.key).unwrap() { + let job = match shard.remove(&self.key).unwrap() { QueryResult::Started(job) => job, QueryResult::Poisoned => panic!(), }; - shard.active.insert(self.key.clone(), QueryResult::Poisoned); + shard.insert(self.key.clone(), QueryResult::Poisoned); job }; // Also signal the completion of the job, so waiters |
