Skip to content

Commit f696b21

Browse files
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).
1 parent 5dda3ee commit f696b21

File tree

12 files changed

+35
-21
lines changed

12 files changed

+35
-21
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
@@ -126,7 +126,6 @@ pub mod util {
126126
pub mod captures;
127127
pub mod common;
128128
pub mod nodemap;
129-
pub mod profiling;
130129
pub mod bug;
131130
}
132131

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ use syntax::source_map;
2929
use syntax::sess::{ParseSess, ProcessCfgMod};
3030
use syntax::symbol::Symbol;
3131
use syntax_pos::{MultiSpan, Span};
32-
use crate::util::profiling::{SelfProfiler, SelfProfilerRef};
3332

3433
use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
3534
use rustc_data_structures::flock;
3635
use rustc_data_structures::jobserver;
36+
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
3737
use ::jobserver::Client;
3838

3939
use std;

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: 12 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,18 @@ 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(profiler: &rustc_data_structures::profiling::SelfProfiler) {
821831
$(profiler.register_query_name(QueryName::$name);)*
822832
}
823833

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)