Rollup merge of #114418 - klensy:parking_lot, r=oli-obk

bump parking_lot to 0.12

Bumps parking_lot to 0.12, replaces few explicit uses of parking_lot with rustc_data_structures::sync ones.

<strike>cc `@oli-obk` this touches recent https://github.com/rust-lang/rust/pull/114283</strike>
cc `@SparrowLii` i've checked that this builds with parallel-compiler

measureme's bump https://github.com/rust-lang/measureme/pull/209
fcf3006e01/compiler/rustc_data_structures/src/sync.rs (L18-L34)
This commit is contained in:
Matthias Krüger 2023-08-04 21:31:56 +02:00 committed by GitHub
commit 4669905ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 18 deletions

View File

@ -3416,7 +3416,7 @@ dependencies = [
"libc", "libc",
"measureme", "measureme",
"memmap2", "memmap2",
"parking_lot 0.11.2", "parking_lot 0.12.1",
"rustc-hash", "rustc-hash",
"rustc-rayon", "rustc-rayon",
"rustc-rayon-core", "rustc-rayon-core",
@ -4135,7 +4135,7 @@ dependencies = [
name = "rustc_query_system" name = "rustc_query_system"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"parking_lot 0.11.2", "parking_lot 0.12.1",
"rustc-rayon-core", "rustc-rayon-core",
"rustc_ast", "rustc_ast",
"rustc_data_structures", "rustc_data_structures",

View File

@ -35,7 +35,7 @@ elsa = "=1.7.1"
itertools = "0.10.1" itertools = "0.10.1"
[dependencies.parking_lot] [dependencies.parking_lot]
version = "0.11" version = "0.12"
[target.'cfg(windows)'.dependencies.windows] [target.'cfg(windows)'.dependencies.windows]
version = "0.48.0" version = "0.48.0"

View File

@ -6,7 +6,7 @@ edition = "2021"
[lib] [lib]
[dependencies] [dependencies]
parking_lot = "0.11" parking_lot = "0.12"
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }

View File

@ -1,4 +1,3 @@
use parking_lot::Mutex;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::profiling::{EventId, QueryInvocationId, SelfProfilerRef}; use rustc_data_structures::profiling::{EventId, QueryInvocationId, SelfProfilerRef};
@ -88,7 +87,7 @@ pub struct DepGraphData<K: DepKind> {
colors: DepNodeColorMap, colors: DepNodeColorMap,
processed_side_effects: Mutex<FxHashSet<DepNodeIndex>>, processed_side_effects: Lock<FxHashSet<DepNodeIndex>>,
/// When we load, there may be `.o` files, cached MIR, or other such /// When we load, there may be `.o` files, cached MIR, or other such
/// things available to us. If we find that they are not dirty, we /// things available to us. If we find that they are not dirty, we

View File

@ -21,12 +21,11 @@ use {
parking_lot::{Condvar, Mutex}, parking_lot::{Condvar, Mutex},
rayon_core, rayon_core,
rustc_data_structures::fx::FxHashSet, rustc_data_structures::fx::FxHashSet,
rustc_data_structures::sync::Lock,
rustc_data_structures::sync::Lrc,
rustc_data_structures::{defer, jobserver}, rustc_data_structures::{defer, jobserver},
rustc_span::DUMMY_SP, rustc_span::DUMMY_SP,
std::iter, std::iter,
std::process, std::process,
std::sync::Arc,
}; };
/// Represents a span and a query key. /// Represents a span and a query key.
@ -191,7 +190,7 @@ struct QueryWaiter<D: DepKind> {
query: Option<QueryJobId>, query: Option<QueryJobId>,
condvar: Condvar, condvar: Condvar,
span: Span, span: Span,
cycle: Lock<Option<CycleError<D>>>, cycle: Mutex<Option<CycleError<D>>>,
} }
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
@ -205,20 +204,20 @@ impl<D: DepKind> QueryWaiter<D> {
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
struct QueryLatchInfo<D: DepKind> { struct QueryLatchInfo<D: DepKind> {
complete: bool, complete: bool,
waiters: Vec<Lrc<QueryWaiter<D>>>, waiters: Vec<Arc<QueryWaiter<D>>>,
} }
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
#[derive(Clone)] #[derive(Clone)]
pub(super) struct QueryLatch<D: DepKind> { pub(super) struct QueryLatch<D: DepKind> {
info: Lrc<Mutex<QueryLatchInfo<D>>>, info: Arc<Mutex<QueryLatchInfo<D>>>,
} }
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
impl<D: DepKind> QueryLatch<D> { impl<D: DepKind> QueryLatch<D> {
fn new() -> Self { fn new() -> Self {
QueryLatch { QueryLatch {
info: Lrc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })), info: Arc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })),
} }
} }
@ -229,11 +228,11 @@ impl<D: DepKind> QueryLatch<D> {
span: Span, span: Span,
) -> Result<(), CycleError<D>> { ) -> Result<(), CycleError<D>> {
let waiter = let waiter =
Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() }); Arc::new(QueryWaiter { query, span, cycle: Mutex::new(None), condvar: Condvar::new() });
self.wait_on_inner(&waiter); self.wait_on_inner(&waiter);
// FIXME: Get rid of this lock. We have ownership of the QueryWaiter // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
// although another thread may still have a Lrc reference so we cannot // although another thread may still have a Arc reference so we cannot
// use Lrc::get_mut // use Arc::get_mut
let mut cycle = waiter.cycle.lock(); let mut cycle = waiter.cycle.lock();
match cycle.take() { match cycle.take() {
None => Ok(()), None => Ok(()),
@ -242,7 +241,7 @@ impl<D: DepKind> QueryLatch<D> {
} }
/// Awaits the caller on this latch by blocking the current thread. /// Awaits the caller on this latch by blocking the current thread.
fn wait_on_inner(&self, waiter: &Lrc<QueryWaiter<D>>) { fn wait_on_inner(&self, waiter: &Arc<QueryWaiter<D>>) {
let mut info = self.info.lock(); let mut info = self.info.lock();
if !info.complete { if !info.complete {
// We push the waiter on to the `waiters` list. It can be accessed inside // We push the waiter on to the `waiters` list. It can be accessed inside
@ -276,7 +275,7 @@ impl<D: DepKind> QueryLatch<D> {
/// Removes a single waiter from the list of waiters. /// Removes a single waiter from the list of waiters.
/// This is used to break query cycles. /// This is used to break query cycles.
fn extract_waiter(&self, waiter: usize) -> Lrc<QueryWaiter<D>> { fn extract_waiter(&self, waiter: usize) -> Arc<QueryWaiter<D>> {
let mut info = self.info.lock(); let mut info = self.info.lock();
debug_assert!(!info.complete); debug_assert!(!info.complete);
// Remove the waiter from the list of waiters // Remove the waiter from the list of waiters
@ -428,7 +427,7 @@ where
fn remove_cycle<D: DepKind>( fn remove_cycle<D: DepKind>(
query_map: &QueryMap<D>, query_map: &QueryMap<D>,
jobs: &mut Vec<QueryJobId>, jobs: &mut Vec<QueryJobId>,
wakelist: &mut Vec<Lrc<QueryWaiter<D>>>, wakelist: &mut Vec<Arc<QueryWaiter<D>>>,
) -> bool { ) -> bool {
let mut visited = FxHashSet::default(); let mut visited = FxHashSet::default();
let mut stack = Vec::new(); let mut stack = Vec::new();