Skip to content

Commit

Permalink
Rollup merge of rust-lang#101635 - jyn514:queries-new-derived, r=cjgi…
Browse files Browse the repository at this point in the history
…llot

Move `Queries::new` out of the macro

Split out from rust-lang#101178 to make sure it's not contributing to the perf impact.

r? `@cjgillot`
  • Loading branch information
Dylan-DPC authored Sep 10, 2022
2 parents 6afbe3e + d2c53ca commit b0455e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cfg_if! {
/// the native atomic types.
/// You should use this type through the `AtomicU64`, `AtomicUsize`, etc, type aliases
/// as it's not intended to be used separately.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Atomic<T: Copy>(Cell<T>);

impl<T: Copy> Atomic<T> {
Expand Down
35 changes: 20 additions & 15 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::keys::Key;
use crate::{on_disk_cache, Queries};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lock;
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_errors::{Diagnostic, Handler};
use rustc_middle::dep_graph::{
self, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex,
Expand Down Expand Up @@ -499,9 +499,28 @@ macro_rules! define_queries {
}
}

use crate::{ExternProviders, OnDiskCache, Providers};

impl<'tcx> Queries<'tcx> {
pub fn new(
local_providers: Providers,
extern_providers: ExternProviders,
on_disk_cache: Option<OnDiskCache<'tcx>>,
) -> Self {
Queries {
local_providers: Box::new(local_providers),
extern_providers: Box::new(extern_providers),
on_disk_cache,
jobs: AtomicU64::new(1),
..Queries::default()
}
}
}

macro_rules! define_queries_struct {
(
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
#[derive(Default)]
pub struct Queries<'tcx> {
local_providers: Box<Providers>,
extern_providers: Box<ExternProviders>,
Expand All @@ -514,20 +533,6 @@ macro_rules! define_queries_struct {
}

impl<'tcx> Queries<'tcx> {
pub fn new(
local_providers: Providers,
extern_providers: ExternProviders,
on_disk_cache: Option<OnDiskCache<'tcx>>,
) -> Self {
Queries {
local_providers: Box::new(local_providers),
extern_providers: Box::new(extern_providers),
on_disk_cache,
jobs: AtomicU64::new(1),
$($name: Default::default()),*
}
}

pub(crate) fn try_collect_active_jobs(
&'tcx self,
tcx: TyCtxt<'tcx>,
Expand Down

0 comments on commit b0455e9

Please sign in to comment.