|
1 | | -use crate::ty::query::config::QueryContext; |
2 | | -use crate::ty::query::plumbing::CycleError; |
3 | | -#[cfg(parallel_compiler)] |
4 | | -use crate::ty::tls; |
| 1 | +use crate::dep_graph::{DepKind, DepContext}; |
| 2 | +use crate::query::config::QueryContext; |
| 3 | +use crate::query::plumbing::CycleError; |
5 | 4 |
|
6 | 5 | use rustc_data_structures::fx::FxHashMap; |
7 | | -use rustc_query_system::dep_graph::DepContext; |
8 | 6 | use rustc_span::Span; |
9 | 7 |
|
10 | 8 | use std::convert::TryFrom; |
|
22 | 20 | rustc_rayon_core as rayon_core, |
23 | 21 | rustc_span::DUMMY_SP, |
24 | 22 | std::iter::FromIterator, |
25 | | - std::{mem, process, thread}, |
| 23 | + std::{mem, process}, |
26 | 24 | }; |
27 | 25 |
|
28 | 26 | /// Represents a span and a query key. |
@@ -52,7 +50,7 @@ pub struct QueryJobId<K> { |
52 | 50 | pub kind: K, |
53 | 51 | } |
54 | 52 |
|
55 | | -impl<K: rustc_query_system::dep_graph::DepKind> QueryJobId<K> { |
| 53 | +impl<K: DepKind> QueryJobId<K> { |
56 | 54 | pub fn new(job: QueryShardJobId, shard: usize, kind: K) -> Self { |
57 | 55 | QueryJobId { job, shard: u16::try_from(shard).unwrap(), kind } |
58 | 56 | } |
@@ -529,38 +527,13 @@ fn remove_cycle<CTX: QueryContext>( |
529 | 527 | } |
530 | 528 | } |
531 | 529 |
|
532 | | -/// Creates a new thread and forwards information in thread locals to it. |
533 | | -/// The new thread runs the deadlock handler. |
534 | | -/// Must only be called when a deadlock is about to happen. |
535 | | -#[cfg(parallel_compiler)] |
536 | | -pub unsafe fn handle_deadlock() { |
537 | | - let registry = rayon_core::Registry::current(); |
538 | | - |
539 | | - let gcx_ptr = tls::GCX_PTR.with(|gcx_ptr| gcx_ptr as *const _); |
540 | | - let gcx_ptr = &*gcx_ptr; |
541 | | - |
542 | | - let rustc_span_globals = |
543 | | - rustc_span::GLOBALS.with(|rustc_span_globals| rustc_span_globals as *const _); |
544 | | - let rustc_span_globals = &*rustc_span_globals; |
545 | | - let syntax_globals = rustc_ast::attr::GLOBALS.with(|syntax_globals| syntax_globals as *const _); |
546 | | - let syntax_globals = &*syntax_globals; |
547 | | - thread::spawn(move || { |
548 | | - tls::GCX_PTR.set(gcx_ptr, || { |
549 | | - rustc_ast::attr::GLOBALS.set(syntax_globals, || { |
550 | | - rustc_span::GLOBALS |
551 | | - .set(rustc_span_globals, || tls::with_global(|tcx| deadlock(tcx, ®istry))) |
552 | | - }); |
553 | | - }) |
554 | | - }); |
555 | | -} |
556 | | - |
557 | 530 | /// Detects query cycles by using depth first search over all active query jobs. |
558 | 531 | /// If a query cycle is found it will break the cycle by finding an edge which |
559 | 532 | /// uses a query latch and then resuming that waiter. |
560 | 533 | /// There may be multiple cycles involved in a deadlock, so this searches |
561 | 534 | /// all active queries for cycles before finally resuming all the waiters at once. |
562 | 535 | #[cfg(parallel_compiler)] |
563 | | -fn deadlock<CTX: QueryContext>(tcx: CTX, registry: &rayon_core::Registry) { |
| 536 | +pub fn deadlock<CTX: QueryContext>(tcx: CTX, registry: &rayon_core::Registry) { |
564 | 537 | let on_panic = OnDrop(|| { |
565 | 538 | eprintln!("deadlock handler panicked, aborting process"); |
566 | 539 | process::abort(); |
|
0 commit comments