Skip to content

Commit

Permalink
Remove deadlock virtual call.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jul 18, 2021
1 parent 81241cb commit 5b92150
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use rustc_errors::registry::Registry;
use rustc_metadata::dynamic_lib::DynamicLibrary;
#[cfg(parallel_compiler)]
use rustc_middle::ty::tls;
#[cfg(parallel_compiler)]
use rustc_query_impl::QueryCtxt;
use rustc_resolve::{self, Resolver};
use rustc_session as session;
use rustc_session::config::{self, CrateType};
Expand Down Expand Up @@ -176,7 +178,7 @@ unsafe fn handle_deadlock() {
thread::spawn(move || {
tls::enter_context(icx, |_| {
rustc_span::set_session_globals_then(session_globals, || {
tls::with(|tcx| tcx.queries.deadlock(tcx, &registry))
tls::with(|tcx| QueryCtxt::from_tcx(tcx).deadlock(&registry))
})
});
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use std::mem;
use std::ops::{Bound, Deref};
use std::sync::Arc;

pub trait OnDiskCache<'tcx> {
pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync {
/// Creates a new `OnDiskCache` instance from the serialized data in `data`.
fn new(sess: &'tcx Session, data: Vec<u8>, start_pos: usize) -> Self
where
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_middle/src/ty/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ macro_rules! define_callbacks {
pub trait QueryEngine<'tcx>: rustc_data_structures::sync::Sync {
fn as_any(&'tcx self) -> &'tcx dyn std::any::Any;

#[cfg(parallel_compiler)]
unsafe fn deadlock(&'tcx self, tcx: TyCtxt<'tcx>, registry: &rustc_rayon_core::Registry);

fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool;

$($(#[$attr])*
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ impl<'tcx> QueryCtxt<'tcx> {
self.queries.on_disk_cache.as_ref()
}

#[cfg(parallel_compiler)]
pub unsafe fn deadlock(self, registry: &rustc_rayon_core::Registry) {
rustc_query_system::query::deadlock(self, registry)
}

pub(super) fn encode_query_results(
self,
encoder: &mut on_disk_cache::CacheEncoder<'a, 'tcx, opaque::FileEncoder>,
Expand Down Expand Up @@ -537,12 +542,6 @@ macro_rules! define_queries_struct {
this as _
}

#[cfg(parallel_compiler)]
unsafe fn deadlock(&'tcx self, tcx: TyCtxt<'tcx>, registry: &rustc_rayon_core::Registry) {
let tcx = QueryCtxt { tcx, queries: self };
rustc_query_system::query::deadlock(tcx, registry)
}

fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool {
let qcx = QueryCtxt { tcx, queries: self };
tcx.dep_graph.try_mark_green(qcx, dep_node).is_some()
Expand Down

0 comments on commit 5b92150

Please sign in to comment.