Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #65199

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e85089b
Remove -Zprofile-queries
Mark-Simulacrum Oct 4, 2019
6c9f218
Disable stack probe when thread sanitizer is enabled
tmiasko Oct 4, 2019
fda0359
Add tests for libsyntax JSON format
Rantanen Oct 3, 2019
dbdfa6e
Fix byte offsets after normalization
Rantanen Oct 3, 2019
ce57648
Move relative pos calculation to SourceFile
Rantanen Oct 4, 2019
e492ca8
Add integration test
Rantanen Oct 4, 2019
4414068
Correctly estimate required space for string
AnthonyMikh Oct 5, 2019
b27089d
Fix format
Rantanen Oct 5, 2019
dfc008f
Remove useless cast
Rantanen Oct 5, 2019
5497ba1
When suggesting assoc function with type params, include turbofish
estebank Oct 5, 2019
3166ce8
Account for derefs when suggesting assoc function
estebank Oct 5, 2019
bbf262d
Tweak test output on failure
Rantanen Oct 6, 2019
4c32d47
Remove loaded_from_cache map from DepGraph
Mark-Simulacrum Oct 6, 2019
90c456e
Remove `force!`.
nnethercote Oct 2, 2019
8f707c3
Remove `krate!`.
nnethercote Oct 2, 2019
1183d60
Remove `def_id!`.
nnethercote Oct 2, 2019
9267d9f
Remove `force_ex!`.
nnethercote Oct 7, 2019
9568911
Rollup merge of #65074 - Rantanen:json-byte-pos, r=matklad
Centril Oct 8, 2019
a56cb76
Rollup merge of #65081 - Mark-Simulacrum:remove-profile-queries, r=mi…
Centril Oct 8, 2019
53af7b3
Rollup merge of #65102 - tmiasko:tsan-probe-stack, r=alexcrichton
Centril Oct 8, 2019
4999b29
Rollup merge of #65120 - AnthonyMikh:fix_65119, r=estebank
Centril Oct 8, 2019
6f88087
Rollup merge of #65145 - estebank:turbofish-assoc-fn-call, r=varkor
Centril Oct 8, 2019
dba40d8
Rollup merge of #65162 - Mark-Simulacrum:no-cache-loading-map, r=mich…
Centril Oct 8, 2019
8c2e726
Rollup merge of #65176 - nnethercote:rm-query-macros, r=michaelwoerister
Centril Oct 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::hash::Hash;
use std::collections::hash_map::Entry;
use std::mem;
use crate::ty::{self, TyCtxt};
use crate::util::common::{ProfileQueriesMsg, profq_msg};
use parking_lot::{Mutex, Condvar};

use crate::ich::{StableHashingContext, StableHashingContextProvider, Fingerprint};
Expand Down Expand Up @@ -75,9 +74,6 @@ struct DepGraphData {
previous_work_products: FxHashMap<WorkProductId, WorkProduct>,

dep_node_debug: Lock<FxHashMap<DepNode, String>>,

// Used for testing, only populated when -Zquery-dep-graph is specified.
loaded_from_cache: Lock<FxHashMap<DepNodeIndex, bool>>,
}

pub fn hash_result<R>(hcx: &mut StableHashingContext<'_>, result: &R) -> Option<Fingerprint>
Expand All @@ -104,7 +100,6 @@ impl DepGraph {
emitting_diagnostics_cond_var: Condvar::new(),
previous: prev_graph,
colors: DepNodeColorMap::new(prev_graph_node_count),
loaded_from_cache: Default::default(),
})),
}
}
Expand Down Expand Up @@ -260,10 +255,6 @@ impl DepGraph {
// - we can get an idea of the runtime cost.
let mut hcx = cx.get_stable_hashing_context();

if cfg!(debug_assertions) {
profq_msg(hcx.sess(), ProfileQueriesMsg::TaskBegin(key.clone()))
};

let result = if no_tcx {
task(cx, arg)
} else {
Expand All @@ -279,10 +270,6 @@ impl DepGraph {
})
};

if cfg!(debug_assertions) {
profq_msg(hcx.sess(), ProfileQueriesMsg::TaskEnd)
};

let current_fingerprint = hash_result(&mut hcx, &result);

let dep_node_index = finish_task_and_alloc_depnode(
Expand Down Expand Up @@ -874,25 +861,6 @@ impl DepGraph {
}
}
}

pub fn mark_loaded_from_cache(&self, dep_node_index: DepNodeIndex, state: bool) {
debug!("mark_loaded_from_cache({:?}, {})",
self.data.as_ref().unwrap().current.borrow().data[dep_node_index].node,
state);

self.data
.as_ref()
.unwrap()
.loaded_from_cache
.borrow_mut()
.insert(dep_node_index, state);
}

pub fn was_loaded_from_cache(&self, dep_node: &DepNode) -> Option<bool> {
let data = self.data.as_ref().unwrap();
let dep_node_index = data.current.borrow().node_to_node_index[dep_node];
data.loaded_from_cache.borrow().get(&dep_node_index).cloned()
}
}

/// A "work product" is an intermediate result that we save into the
Expand Down
19 changes: 19 additions & 0 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
ref lines,
ref multibyte_chars,
ref non_narrow_chars,
ref normalized_pos,
} = *self;

(name_hash as u64).hash_stable(hcx, hasher);
Expand Down Expand Up @@ -452,6 +453,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
for &char_pos in non_narrow_chars.iter() {
stable_non_narrow_char(char_pos, start_pos).hash_stable(hcx, hasher);
}

normalized_pos.len().hash_stable(hcx, hasher);
for &char_pos in normalized_pos.iter() {
stable_normalized_pos(char_pos, start_pos).hash_stable(hcx, hasher);
}

}
}

Expand Down Expand Up @@ -481,6 +488,18 @@ fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar,
(pos.0 - source_file_start.0, width as u32)
}

fn stable_normalized_pos(np: ::syntax_pos::NormalizedPos,
source_file_start: ::syntax_pos::BytePos)
-> (u32, u32) {
let ::syntax_pos::NormalizedPos {
pos,
diff
} = np;

(pos.0 - source_file_start.0, diff)
}


impl<'tcx> HashStable<StableHashingContext<'tcx>> for feature_gate::Features {
fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
// Unfortunately we cannot exhaustively list fields here, since the
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,10 +1316,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"enable queries of the dependency graph for regression testing"),
profile_queries: bool = (false, parse_bool, [UNTRACKED],
"trace and profile the queries of the incremental compilation framework"),
profile_queries_and_keys: bool = (false, parse_bool, [UNTRACKED],
"trace and profile the queries and keys of the incremental compilation framework"),
no_analysis: bool = (false, parse_bool, [UNTRACKED],
"parse and expand the source, but run no analysis"),
extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
Expand Down
14 changes: 1 addition & 13 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
use crate::session::search_paths::{PathKind, SearchPath};
use crate::util::nodemap::{FxHashMap, FxHashSet};
use crate::util::common::{duration_to_secs_str, ErrorReported};
use crate::util::common::ProfileQueriesMsg;

use rustc_data_structures::base_n;
use rustc_data_structures::sync::{
Expand Down Expand Up @@ -46,7 +45,7 @@ use std::fmt;
use std::io::Write;
use std::path::PathBuf;
use std::time::Duration;
use std::sync::{Arc, mpsc};
use std::sync::Arc;

mod code_stats;
pub mod config;
Expand Down Expand Up @@ -125,9 +124,6 @@ pub struct Session {
/// `-Zquery-dep-graph` is specified.
pub cgu_reuse_tracker: CguReuseTracker,

/// Used by `-Z profile-queries` in `util::common`.
pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,

/// Used by `-Z self-profile`.
pub prof: SelfProfilerRef,

Expand Down Expand Up @@ -509,13 +505,6 @@ impl Session {
pub fn time_extended(&self) -> bool {
self.opts.debugging_opts.time_passes
}
pub fn profile_queries(&self) -> bool {
self.opts.debugging_opts.profile_queries
|| self.opts.debugging_opts.profile_queries_and_keys
}
pub fn profile_queries_and_keys(&self) -> bool {
self.opts.debugging_opts.profile_queries_and_keys
}
pub fn instrument_mcount(&self) -> bool {
self.opts.debugging_opts.instrument_mcount
}
Expand Down Expand Up @@ -1234,7 +1223,6 @@ fn build_session_(
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
cgu_reuse_tracker,
prof: SelfProfilerRef::new(self_profiler),
profile_channel: Lock::new(None),
perf_stats: PerfStats {
symbol_hash_time: Lock::new(Duration::from_secs(0)),
decode_def_path_tables_time: Lock::new(Duration::from_secs(0)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ where
let desc = &format!("encode_query_results for {}",
::std::any::type_name::<Q>());

time_ext(tcx.sess.time_extended(), Some(tcx.sess), desc, || {
time_ext(tcx.sess.time_extended(), desc, || {
let shards = Q::query_cache(tcx).lock_shards();
assert!(shards.iter().all(|shard| shard.active.is_empty()));
for (key, entry) in shards.iter().flat_map(|shard| shard.results.iter()) {
Expand Down
102 changes: 13 additions & 89 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use crate::ty::query::Query;
use crate::ty::query::config::{QueryConfig, QueryDescription};
use crate::ty::query::job::{QueryJob, QueryResult, QueryInfo};

use crate::util::common::{profq_msg, ProfileQueriesMsg, QueryMsg};

use errors::DiagnosticBuilder;
use errors::Level;
use errors::Diagnostic;
Expand Down Expand Up @@ -62,33 +60,6 @@ impl<'tcx, M: QueryConfig<'tcx>> Default for QueryCache<'tcx, M> {
}
}

// If enabled, sends a message to the profile-queries thread.
macro_rules! profq_msg {
($tcx:expr, $msg:expr) => {
if cfg!(debug_assertions) {
if $tcx.sess.profile_queries() {
profq_msg($tcx.sess, $msg)
}
}
}
}

// If enabled, formats a key using its debug string, which can be
// expensive to compute (in terms of time).
macro_rules! profq_query_msg {
($query:expr, $tcx:expr, $key:expr) => {{
let msg = if cfg!(debug_assertions) {
if $tcx.sess.profile_queries_and_keys() {
Some(format!("{:?}", $key))
} else { None }
} else { None };
QueryMsg {
query: $query,
msg,
}
}}
}

/// A type representing the responsibility to execute the job in the `job` field.
/// This will poison the relevant query if dropped.
pub(super) struct JobOwner<'a, 'tcx, Q: QueryDescription<'tcx>> {
Expand All @@ -111,7 +82,6 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
loop {
let mut lock = cache.get_shard_by_value(key).lock();
if let Some(value) = lock.results.get(key) {
profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
tcx.prof.query_cache_hit(Q::NAME);
let result = (value.value.clone(), value.index);
#[cfg(debug_assertions)]
Expand Down Expand Up @@ -358,13 +328,6 @@ impl<'tcx> TyCtxt<'tcx> {
key,
span);

profq_msg!(self,
ProfileQueriesMsg::QueryBegin(
span.data(),
profq_query_msg!(Q::NAME.as_str(), self, key),
)
);

let job = match JobOwner::try_get(self, span, &key) {
TryGetJob::NotYetStarted(job) => job,
TryGetJob::Cycle(result) => return result,
Expand All @@ -383,7 +346,6 @@ impl<'tcx> TyCtxt<'tcx> {

if Q::ANON {

profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
let prof_timer = self.prof.query_provider(Q::NAME);

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
Expand All @@ -395,7 +357,6 @@ impl<'tcx> TyCtxt<'tcx> {
});

drop(prof_timer);
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);

self.dep_graph.read_index(dep_node_index);

Expand Down Expand Up @@ -468,7 +429,6 @@ impl<'tcx> TyCtxt<'tcx> {
};

let result = if let Some(result) = result {
profq_msg!(self, ProfileQueriesMsg::CacheHit);
result
} else {
// We could not load a result from the on-disk cache, so
Expand All @@ -489,10 +449,6 @@ impl<'tcx> TyCtxt<'tcx> {
self.incremental_verify_ich::<Q>(&result, dep_node, dep_node_index);
}

if unlikely!(self.sess.opts.debugging_opts.query_dep_graph) {
self.dep_graph.mark_loaded_from_cache(dep_node_index, true);
}

result
}

Expand Down Expand Up @@ -546,7 +502,6 @@ impl<'tcx> TyCtxt<'tcx> {
- dep-node: {:?}",
key, dep_node);

profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
let prof_timer = self.prof.query_provider(Q::NAME);

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
Expand All @@ -568,11 +523,6 @@ impl<'tcx> TyCtxt<'tcx> {
});

drop(prof_timer);
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);

if unlikely!(self.sess.opts.debugging_opts.query_dep_graph) {
self.dep_graph.mark_loaded_from_cache(dep_node_index, false);
}

if unlikely!(!diagnostics.is_empty()) {
if dep_node.kind != crate::dep_graph::DepKind::Null {
Expand Down Expand Up @@ -614,19 +564,12 @@ impl<'tcx> TyCtxt<'tcx> {

let _ = self.get_query::<Q>(DUMMY_SP, key);
} else {
profq_msg!(self, ProfileQueriesMsg::CacheHit);
self.prof.query_cache_hit(Q::NAME);
}
}

#[allow(dead_code)]
fn force_query<Q: QueryDescription<'tcx>>(self, key: Q::Key, span: Span, dep_node: DepNode) {
profq_msg!(
self,
ProfileQueriesMsg::QueryBegin(span.data(),
profq_query_msg!(Q::NAME.as_str(), self, key))
);

// We may be concurrently trying both execute and force a query.
// Ensure that only one of them runs the query.
let job = match JobOwner::try_get(self, span, &key) {
Expand Down Expand Up @@ -1191,37 +1134,6 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
return false
}

macro_rules! def_id {
() => {
if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
}
}
};

macro_rules! krate {
() => { (def_id!()).krate }
};

macro_rules! force_ex {
($tcx:expr, $query:ident, $key:expr) => {
{
$tcx.force_query::<crate::ty::query::queries::$query<'_>>(
$key,
DUMMY_SP,
*dep_node
);
}
}
};

macro_rules! force {
($query:ident, $key:expr) => { force_ex!(tcx, $query, $key) }
};

rustc_dep_node_force!([dep_node, tcx]
// These are inputs that are expected to be pre-allocated and that
// should therefore always be red or green already.
Expand All @@ -1240,7 +1152,19 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
bug!("force_from_dep_node: encountered {:?}", dep_node)
}

DepKind::Analysis => { force!(analysis, krate!()); }
DepKind::Analysis => {
let def_id = if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
};
tcx.force_query::<crate::ty::query::queries::analysis<'_>>(
def_id.krate,
DUMMY_SP,
*dep_node
);
}
);

true
Expand Down
Loading