Skip to content

Commit 4669905

Browse files
authored
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 rust-lang/measureme#209 https://github.com/rust-lang/rust/blob/fcf3006e0133365ecd26894689c086387edcbecb/compiler/rustc_data_structures/src/sync.rs#L18-L34
2 parents 23e86f6 + e370095 commit 4669905

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

Diff for: Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,7 @@ dependencies = [
34163416
"libc",
34173417
"measureme",
34183418
"memmap2",
3419-
"parking_lot 0.11.2",
3419+
"parking_lot 0.12.1",
34203420
"rustc-hash",
34213421
"rustc-rayon",
34223422
"rustc-rayon-core",
@@ -4135,7 +4135,7 @@ dependencies = [
41354135
name = "rustc_query_system"
41364136
version = "0.0.0"
41374137
dependencies = [
4138-
"parking_lot 0.11.2",
4138+
"parking_lot 0.12.1",
41394139
"rustc-rayon-core",
41404140
"rustc_ast",
41414141
"rustc_data_structures",

Diff for: compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ elsa = "=1.7.1"
3535
itertools = "0.10.1"
3636

3737
[dependencies.parking_lot]
38-
version = "0.11"
38+
version = "0.12"
3939

4040
[target.'cfg(windows)'.dependencies.windows]
4141
version = "0.48.0"

Diff for: compiler/rustc_query_system/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[lib]
77

88
[dependencies]
9-
parking_lot = "0.11"
9+
parking_lot = "0.12"
1010
rustc_ast = { path = "../rustc_ast" }
1111
rustc_data_structures = { path = "../rustc_data_structures" }
1212
rustc_errors = { path = "../rustc_errors" }

Diff for: compiler/rustc_query_system/src/dep_graph/graph.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use parking_lot::Mutex;
21
use rustc_data_structures::fingerprint::Fingerprint;
32
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
43
use rustc_data_structures::profiling::{EventId, QueryInvocationId, SelfProfilerRef};
@@ -88,7 +87,7 @@ pub struct DepGraphData<K: DepKind> {
8887

8988
colors: DepNodeColorMap,
9089

91-
processed_side_effects: Mutex<FxHashSet<DepNodeIndex>>,
90+
processed_side_effects: Lock<FxHashSet<DepNodeIndex>>,
9291

9392
/// When we load, there may be `.o` files, cached MIR, or other such
9493
/// things available to us. If we find that they are not dirty, we

Diff for: compiler/rustc_query_system/src/query/job.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ use {
2121
parking_lot::{Condvar, Mutex},
2222
rayon_core,
2323
rustc_data_structures::fx::FxHashSet,
24-
rustc_data_structures::sync::Lock,
25-
rustc_data_structures::sync::Lrc,
2624
rustc_data_structures::{defer, jobserver},
2725
rustc_span::DUMMY_SP,
2826
std::iter,
2927
std::process,
28+
std::sync::Arc,
3029
};
3130

3231
/// Represents a span and a query key.
@@ -191,7 +190,7 @@ struct QueryWaiter<D: DepKind> {
191190
query: Option<QueryJobId>,
192191
condvar: Condvar,
193192
span: Span,
194-
cycle: Lock<Option<CycleError<D>>>,
193+
cycle: Mutex<Option<CycleError<D>>>,
195194
}
196195

197196
#[cfg(parallel_compiler)]
@@ -205,20 +204,20 @@ impl<D: DepKind> QueryWaiter<D> {
205204
#[cfg(parallel_compiler)]
206205
struct QueryLatchInfo<D: DepKind> {
207206
complete: bool,
208-
waiters: Vec<Lrc<QueryWaiter<D>>>,
207+
waiters: Vec<Arc<QueryWaiter<D>>>,
209208
}
210209

211210
#[cfg(parallel_compiler)]
212211
#[derive(Clone)]
213212
pub(super) struct QueryLatch<D: DepKind> {
214-
info: Lrc<Mutex<QueryLatchInfo<D>>>,
213+
info: Arc<Mutex<QueryLatchInfo<D>>>,
215214
}
216215

217216
#[cfg(parallel_compiler)]
218217
impl<D: DepKind> QueryLatch<D> {
219218
fn new() -> Self {
220219
QueryLatch {
221-
info: Lrc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })),
220+
info: Arc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })),
222221
}
223222
}
224223

@@ -229,11 +228,11 @@ impl<D: DepKind> QueryLatch<D> {
229228
span: Span,
230229
) -> Result<(), CycleError<D>> {
231230
let waiter =
232-
Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() });
231+
Arc::new(QueryWaiter { query, span, cycle: Mutex::new(None), condvar: Condvar::new() });
233232
self.wait_on_inner(&waiter);
234233
// FIXME: Get rid of this lock. We have ownership of the QueryWaiter
235-
// although another thread may still have a Lrc reference so we cannot
236-
// use Lrc::get_mut
234+
// although another thread may still have a Arc reference so we cannot
235+
// use Arc::get_mut
237236
let mut cycle = waiter.cycle.lock();
238237
match cycle.take() {
239238
None => Ok(()),
@@ -242,7 +241,7 @@ impl<D: DepKind> QueryLatch<D> {
242241
}
243242

244243
/// Awaits the caller on this latch by blocking the current thread.
245-
fn wait_on_inner(&self, waiter: &Lrc<QueryWaiter<D>>) {
244+
fn wait_on_inner(&self, waiter: &Arc<QueryWaiter<D>>) {
246245
let mut info = self.info.lock();
247246
if !info.complete {
248247
// We push the waiter on to the `waiters` list. It can be accessed inside
@@ -276,7 +275,7 @@ impl<D: DepKind> QueryLatch<D> {
276275

277276
/// Removes a single waiter from the list of waiters.
278277
/// This is used to break query cycles.
279-
fn extract_waiter(&self, waiter: usize) -> Lrc<QueryWaiter<D>> {
278+
fn extract_waiter(&self, waiter: usize) -> Arc<QueryWaiter<D>> {
280279
let mut info = self.info.lock();
281280
debug_assert!(!info.complete);
282281
// Remove the waiter from the list of waiters
@@ -428,7 +427,7 @@ where
428427
fn remove_cycle<D: DepKind>(
429428
query_map: &QueryMap<D>,
430429
jobs: &mut Vec<QueryJobId>,
431-
wakelist: &mut Vec<Lrc<QueryWaiter<D>>>,
430+
wakelist: &mut Vec<Arc<QueryWaiter<D>>>,
432431
) -> bool {
433432
let mut visited = FxHashSet::default();
434433
let mut stack = Vec::new();

0 commit comments

Comments
 (0)