Skip to content

Commit d25bc6c

Browse files
authored
Rollup merge of #66335 - Mark-Simulacrum:self-profile-to-data, r=michaelwoerister
Move self-profile infrastructure to data structures The single dependency on queries (QueryName) can be fairly easily abstracted via a trait and this further decouples Session from librustc (the primary goal). This is intended as a precursor to moving Session out of librustc, but since that involves lots of smaller steps that move around code I'm splitting it up into separate PRs.
2 parents a36fdf8 + 2fd5454 commit d25bc6c

File tree

13 files changed

+47
-22
lines changed

13 files changed

+47
-22
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,6 @@ dependencies = [
31203120
"graphviz",
31213121
"jobserver",
31223122
"log",
3123-
"measureme",
31243123
"num_cpus",
31253124
"parking_lot 0.9.0",
31263125
"polonius-engine",
@@ -3470,6 +3469,7 @@ dependencies = [
34703469
name = "rustc_data_structures"
34713470
version = "0.0.0"
34723471
dependencies = [
3472+
"bitflags",
34733473
"cfg-if",
34743474
"crossbeam-utils 0.6.5",
34753475
"ena",
@@ -3478,6 +3478,7 @@ dependencies = [
34783478
"jobserver",
34793479
"lazy_static 1.3.0",
34803480
"log",
3481+
"measureme",
34813482
"parking_lot 0.9.0",
34823483
"rustc-hash",
34833484
"rustc-rayon 0.3.0",

src/librustc/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ byteorder = { version = "1.3" }
4040
chalk-engine = { version = "0.9.0", default-features=false }
4141
rustc_fs_util = { path = "../librustc_fs_util" }
4242
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
43-
measureme = "0.4"

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ pub mod util {
124124
pub mod captures;
125125
pub mod common;
126126
pub mod nodemap;
127-
pub mod profiling;
128127
pub mod bug;
129128
}
130129

src/librustc/session/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ use syntax::source_map;
2727
use syntax::sess::{ParseSess, ProcessCfgMod};
2828
use syntax::symbol::Symbol;
2929
use syntax_pos::{MultiSpan, Span};
30-
use crate::util::profiling::{SelfProfiler, SelfProfilerRef};
3130

3231
use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
3332
use rustc_data_structures::flock;
3433
use rustc_data_structures::jobserver;
34+
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
3535
use ::jobserver::Client;
3636

3737
use std;
@@ -1091,7 +1091,6 @@ fn build_session_(
10911091
);
10921092
match profiler {
10931093
Ok(profiler) => {
1094-
crate::ty::query::QueryName::register_with_profiler(&profiler);
10951094
Some(Arc::new(profiler))
10961095
},
10971096
Err(e) => {

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ use crate::ty::CanonicalPolyFnSig;
4646
use crate::util::common::ErrorReported;
4747
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet, NodeMap};
4848
use crate::util::nodemap::{FxHashMap, FxHashSet};
49-
use crate::util::profiling::SelfProfilerRef;
5049

5150
use errors::DiagnosticBuilder;
5251
use arena::SyncDroplessArena;
5352
use smallvec::SmallVec;
53+
use rustc_data_structures::profiling::SelfProfilerRef;
5454
use rustc_data_structures::stable_hasher::{
5555
HashStable, StableHasher, StableVec, hash_stable_hashmap,
5656
};

src/librustc/ty/query/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ty::query::queries;
66
use crate::ty::query::{Query, QueryName};
77
use crate::ty::query::QueryCache;
88
use crate::ty::query::plumbing::CycleError;
9-
use crate::util::profiling::ProfileCategory;
9+
use rustc_data_structures::profiling::ProfileCategory;
1010

1111
use std::borrow::Cow;
1212
use std::hash::Hash;

src/librustc/ty/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::ty::util::NeedsDrop;
3939
use crate::ty::subst::SubstsRef;
4040
use crate::util::nodemap::{DefIdSet, DefIdMap};
4141
use crate::util::common::ErrorReported;
42-
use crate::util::profiling::ProfileCategory::*;
42+
use rustc_data_structures::profiling::ProfileCategory::*;
4343

4444
use rustc_data_structures::svh::Svh;
4545
use rustc_index::vec::IndexVec;

src/librustc/ty/query/plumbing.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ macro_rules! define_queries_inner {
672672
rustc_data_structures::stable_hasher::StableHasher,
673673
ich::StableHashingContext
674674
};
675-
use crate::util::profiling::ProfileCategory;
675+
use rustc_data_structures::profiling::ProfileCategory;
676676

677677
define_queries_struct! {
678678
tcx: $tcx,
@@ -816,8 +816,20 @@ macro_rules! define_queries_inner {
816816
$($name),*
817817
}
818818

819+
impl rustc_data_structures::profiling::QueryName for QueryName {
820+
fn discriminant(self) -> std::mem::Discriminant<QueryName> {
821+
std::mem::discriminant(&self)
822+
}
823+
824+
fn as_str(self) -> &'static str {
825+
QueryName::as_str(&self)
826+
}
827+
}
828+
819829
impl QueryName {
820-
pub fn register_with_profiler(profiler: &crate::util::profiling::SelfProfiler) {
830+
pub fn register_with_profiler(
831+
profiler: &rustc_data_structures::profiling::SelfProfiler,
832+
) {
821833
$(profiler.register_query_name(QueryName::$name);)*
822834
}
823835

src/librustc_codegen_ssa/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::util::nodemap::FxHashMap;
1919
use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
2020
use rustc::ty::TyCtxt;
2121
use rustc::util::common::{time_depth, set_time_depth, print_time_passes_entry};
22-
use rustc::util::profiling::SelfProfilerRef;
22+
use rustc_data_structures::profiling::SelfProfilerRef;
2323
use rustc_fs_util::link_or_copy;
2424
use rustc_data_structures::svh::Svh;
2525
use rustc_data_structures::sync::Lrc;

src/librustc_data_structures/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ rayon-core = { version = "0.3.0", package = "rustc-rayon-core" }
2525
rustc-hash = "1.0.1"
2626
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2727
rustc_index = { path = "../librustc_index", package = "rustc_index" }
28+
bitflags = "1.2.1"
29+
measureme = "0.4"
2830

2931
[dependencies.parking_lot]
3032
version = "0.9"

0 commit comments

Comments
 (0)