Skip to content

Commit a4280b0

Browse files
committed
Swap Lru from std::sync::Arc to triomphe::Arc
1 parent 8f8bee4 commit a4280b0

File tree

18 files changed

+110
-68
lines changed

18 files changed

+110
-68
lines changed

Cargo.lock

+46-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically @generated by Cargo.
22
# It is not intended for manual editing.
3-
version = 3
3+
version = 4
44

55
[[package]]
66
name = "addr2line"
@@ -3545,6 +3545,8 @@ dependencies = [
35453545
"tempfile",
35463546
"thin-vec",
35473547
"tracing",
3548+
"triomphe",
3549+
"unsize",
35483550
"windows",
35493551
]
35503552

@@ -3908,6 +3910,7 @@ dependencies = [
39083910
"rustc_traits",
39093911
"rustc_ty_utils",
39103912
"tracing",
3913+
"unsize",
39113914
]
39123915

39133916
[[package]]
@@ -4359,6 +4362,7 @@ dependencies = [
43594362
"smallvec",
43604363
"tempfile",
43614364
"thin-vec",
4365+
"triomphe",
43624366
]
43634367

43644368
[[package]]
@@ -5465,6 +5469,16 @@ dependencies = [
54655469
"tracing-subscriber",
54665470
]
54675471

5472+
[[package]]
5473+
name = "triomphe"
5474+
version = "0.1.14"
5475+
source = "git+https://github.com/GnomedDev/triomphe?branch=dropck-eyepatch#a9614f96c0eb04818cea5f98416b05ca34d9e383"
5476+
dependencies = [
5477+
"serde",
5478+
"stable_deref_trait",
5479+
"unsize",
5480+
]
5481+
54685482
[[package]]
54695483
name = "twox-hash"
54705484
version = "1.6.3"
@@ -5661,6 +5675,15 @@ dependencies = [
56615675
"diff",
56625676
]
56635677

5678+
[[package]]
5679+
name = "unsize"
5680+
version = "1.1.0"
5681+
source = "registry+https://github.com/rust-lang/crates.io-index"
5682+
checksum = "4fa7a7a734c1a5664a662ddcea0b6c9472a21da8888c957c7f1eaa09dba7a939"
5683+
dependencies = [
5684+
"autocfg",
5685+
]
5686+
56645687
[[package]]
56655688
name = "unstable-book-gen"
56665689
version = "0.1.0"
@@ -5813,7 +5836,7 @@ dependencies = [
58135836
"lexopt",
58145837
"tempfile",
58155838
"wasi-preview1-component-adapter-provider",
5816-
"wasmparser 0.219.0",
5839+
"wasmparser 0.219.1",
58175840
"wat",
58185841
"wit-component",
58195842
"wit-parser",
@@ -5837,28 +5860,28 @@ dependencies = [
58375860

58385861
[[package]]
58395862
name = "wasm-encoder"
5840-
version = "0.219.0"
5863+
version = "0.219.1"
58415864
source = "registry+https://github.com/rust-lang/crates.io-index"
5842-
checksum = "e2b1b95711b3ad655656a341e301cc64e33cbee94de9a99a1c5a2ab88efab79d"
5865+
checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54"
58435866
dependencies = [
58445867
"leb128",
5845-
"wasmparser 0.219.0",
5868+
"wasmparser 0.219.1",
58465869
]
58475870

58485871
[[package]]
58495872
name = "wasm-metadata"
5850-
version = "0.219.0"
5873+
version = "0.219.1"
58515874
source = "registry+https://github.com/rust-lang/crates.io-index"
5852-
checksum = "96132fe00dd17d092d2be289eeed5a0a68ad3cf30b68e8875bc953b96f55f0be"
5875+
checksum = "2af5a8e37a5e996861e1813f8de30911c47609c9ff51a7284f7dbd754dc3a9f3"
58535876
dependencies = [
58545877
"anyhow",
58555878
"indexmap",
58565879
"serde",
58575880
"serde_derive",
58585881
"serde_json",
58595882
"spdx",
5860-
"wasm-encoder 0.219.0",
5861-
"wasmparser 0.219.0",
5883+
"wasm-encoder 0.219.1",
5884+
"wasmparser 0.219.1",
58625885
]
58635886

58645887
[[package]]
@@ -5873,9 +5896,9 @@ dependencies = [
58735896

58745897
[[package]]
58755898
name = "wasmparser"
5876-
version = "0.219.0"
5899+
version = "0.219.1"
58775900
source = "registry+https://github.com/rust-lang/crates.io-index"
5878-
checksum = "324b4e56d24439495b88cd81439dad5e97f3c7b1eedc3c7e10455ed1e045e9a2"
5901+
checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5"
58795902
dependencies = [
58805903
"ahash",
58815904
"bitflags 2.6.0",
@@ -5887,22 +5910,22 @@ dependencies = [
58875910

58885911
[[package]]
58895912
name = "wast"
5890-
version = "219.0.0"
5913+
version = "219.0.1"
58915914
source = "registry+https://github.com/rust-lang/crates.io-index"
5892-
checksum = "06880ecb25662bc21db6a83f4fcc27c41f71fbcba4f1980b650c88ada92728e1"
5915+
checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1"
58935916
dependencies = [
58945917
"bumpalo",
58955918
"leb128",
58965919
"memchr",
58975920
"unicode-width",
5898-
"wasm-encoder 0.219.0",
5921+
"wasm-encoder 0.219.1",
58995922
]
59005923

59015924
[[package]]
59025925
name = "wat"
5903-
version = "1.219.0"
5926+
version = "1.219.1"
59045927
source = "registry+https://github.com/rust-lang/crates.io-index"
5905-
checksum = "11e56dbf9fc89111b0d97c91e683d7895b1a6e5633a729f2ccad2303724005b6"
5928+
checksum = "8bc3cf014fb336883a411cd662f987abf6a1d2a27f2f0008616a0070bbf6bd0d"
59065929
dependencies = [
59075930
"wast",
59085931
]
@@ -6179,9 +6202,9 @@ dependencies = [
61796202

61806203
[[package]]
61816204
name = "wit-component"
6182-
version = "0.219.0"
6205+
version = "0.219.1"
61836206
source = "registry+https://github.com/rust-lang/crates.io-index"
6184-
checksum = "99a76111c20444a814019de20499d30940ecd219b9512ee296f034a5edb18a2d"
6207+
checksum = "ad1673163c0cb14a6a19ddbf44dd4efe6f015ec1ebb8156710ac32501f19fba2"
61856208
dependencies = [
61866209
"anyhow",
61876210
"bitflags 2.6.0",
@@ -6190,17 +6213,17 @@ dependencies = [
61906213
"serde",
61916214
"serde_derive",
61926215
"serde_json",
6193-
"wasm-encoder 0.219.0",
6216+
"wasm-encoder 0.219.1",
61946217
"wasm-metadata",
6195-
"wasmparser 0.219.0",
6218+
"wasmparser 0.219.1",
61966219
"wit-parser",
61976220
]
61986221

61996222
[[package]]
62006223
name = "wit-parser"
6201-
version = "0.219.0"
6224+
version = "0.219.1"
62026225
source = "registry+https://github.com/rust-lang/crates.io-index"
6203-
checksum = "23102e180c0c464f36e293d31a27b524e3ece930d7b5527d2f33f9d2c963de64"
6226+
checksum = "4a86f669283257e8e424b9a4fc3518e3ade0b95deb9fbc0f93a1876be3eda598"
62046227
dependencies = [
62056228
"anyhow",
62066229
"id-arena",
@@ -6211,7 +6234,7 @@ dependencies = [
62116234
"serde_derive",
62126235
"serde_json",
62136236
"unicode-xid",
6214-
"wasmparser 0.219.0",
6237+
"wasmparser 0.219.1",
62156238
]
62166239

62176240
[[package]]

compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
192192
current_item: None,
193193
impl_trait_defs: Vec::new(),
194194
impl_trait_bounds: Vec::new(),
195-
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
195+
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].as_slice().into(),
196196
allow_gen_future: if tcx.features().async_fn_track_caller {
197-
[sym::gen_future, sym::closure_track_caller].into()
197+
[sym::gen_future, sym::closure_track_caller].as_slice().into()
198198
} else {
199-
[sym::gen_future].into()
199+
[sym::gen_future].as_slice().into()
200200
},
201-
allow_for_await: [sym::async_iterator].into(),
202-
allow_async_fn_traits: [sym::async_fn_traits].into(),
201+
allow_for_await: [sym::async_iterator].as_slice().into(),
202+
allow_async_fn_traits: [sym::async_fn_traits].as_slice().into(),
203203
// FIXME(gen_blocks): how does `closure_track_caller`/`async_fn_track_caller`
204204
// interact with `gen`/`async gen` blocks
205-
allow_async_iterator: [sym::gen_future, sym::async_iterator].into(),
205+
allow_async_iterator: [sym::gen_future, sym::async_iterator].as_slice().into(),
206206
generics_def_id_map: Default::default(),
207207
host_param_id: None,
208208
ast_index,

compiler/rustc_codegen_cranelift/src/global_asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
110110
pub(crate) struct GlobalAsmConfig {
111111
assembler: PathBuf,
112112
target: String,
113-
pub(crate) output_filenames: Arc<OutputFilenames>,
113+
pub(crate) output_filenames: Lrc<OutputFilenames>,
114114
}
115115

116116
impl GlobalAsmConfig {

compiler/rustc_codegen_cranelift/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
125125
/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
126126
struct CodegenCx {
127127
profiler: SelfProfilerRef,
128-
output_filenames: Arc<OutputFilenames>,
128+
output_filenames: Lrc<OutputFilenames>,
129129
should_write_ir: bool,
130130
global_asm: String,
131131
inline_asm_index: Cell<usize>,

compiler/rustc_codegen_ssa/src/back/write.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use super::symbol_export::symbol_name_for_instance_in_crate;
4444
use crate::errors::ErrorCreatingRemarkDir;
4545
use crate::traits::*;
4646
use crate::{
47-
CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
47+
CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, Lrc, ModuleCodegen, ModuleKind,
4848
errors,
4949
};
5050

@@ -349,7 +349,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
349349
pub opts: Arc<config::Options>,
350350
pub crate_types: Vec<CrateType>,
351351
pub each_linked_rlib_for_lto: Vec<(CrateNum, PathBuf)>,
352-
pub output_filenames: Arc<OutputFilenames>,
352+
pub output_filenames: Lrc<OutputFilenames>,
353353
pub regular_module_config: Arc<ModuleConfig>,
354354
pub metadata_module_config: Arc<ModuleConfig>,
355355
pub allocator_module_config: Arc<ModuleConfig>,
@@ -2037,7 +2037,7 @@ pub struct OngoingCodegen<B: ExtraBackendMethods> {
20372037
pub crate_info: CrateInfo,
20382038
pub codegen_worker_receive: Receiver<CguMessage>,
20392039
pub shared_emitter_main: SharedEmitterMain,
2040-
pub output_filenames: Arc<OutputFilenames>,
2040+
pub output_filenames: Lrc<OutputFilenames>,
20412041
pub coordinator: Coordinator<B>,
20422042
}
20432043

compiler/rustc_data_structures/Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ stacker = "0.1.17"
2626
tempfile = "3.2"
2727
thin-vec = "0.2.12"
2828
tracing = "0.1"
29+
unsize = { version = "1.1", optional = true }
2930
# tidy-alphabetical-end
3031

3132
[dependencies.parking_lot]
3233
version = "0.12"
3334

35+
[dependencies.triomphe]
36+
version = "0.1"
37+
optional = true
38+
features = ["unsize", "unstable_dropck_eyepatch"]
39+
git = "https://github.com/GnomedDev/triomphe"
40+
branch = "dropck-eyepatch"
41+
3442
[target.'cfg(windows)'.dependencies.windows]
3543
version = "0.57.0"
3644
features = [
@@ -56,5 +64,5 @@ portable-atomic = "1.5.1"
5664

5765
[features]
5866
# tidy-alphabetical-start
59-
rustc_use_parallel_compiler = ["indexmap/rustc-rayon", "dep:rustc-rayon"]
67+
rustc_use_parallel_compiler = ["indexmap/rustc-rayon", "dep:rustc-rayon", "dep:triomphe", "dep:unsize"]
6068
# tidy-alphabetical-end

compiler/rustc_data_structures/src/marker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ cfg_match! {
4242
[*mut T where T: ?Sized]
4343
[std::ptr::NonNull<T> where T: ?Sized]
4444
[std::rc::Rc<T> where T: ?Sized]
45-
[std::rc::Weak<T> where T: ?Sized]
4645
[std::sync::MutexGuard<'_, T> where T: ?Sized]
4746
[std::sync::RwLockReadGuard<'_, T> where T: ?Sized]
4847
[std::sync::RwLockWriteGuard<'_, T> where T: ?Sized]
@@ -92,6 +91,7 @@ cfg_match! {
9291
[Box<T, A> where T: ?Sized + DynSend, A: std::alloc::Allocator + DynSend]
9392
[crate::sync::RwLock<T> where T: DynSend]
9493
[crate::tagged_ptr::CopyTaggedPtr<P, T, CP> where P: Send + crate::tagged_ptr::Pointer, T: Send + crate::tagged_ptr::Tag, const CP: bool]
94+
[triomphe::Arc<T> where T: ?Sized + DynSync + DynSend]
9595
[rustc_arena::TypedArena<T> where T: DynSend]
9696
[indexmap::IndexSet<V, S> where V: DynSend, S: DynSend]
9797
[indexmap::IndexMap<K, V, S> where K: DynSend, V: DynSend, S: DynSend]
@@ -116,7 +116,6 @@ cfg_match! {
116116
[std::cell::UnsafeCell<T> where T: ?Sized]
117117
[std::ptr::NonNull<T> where T: ?Sized]
118118
[std::rc::Rc<T> where T: ?Sized]
119-
[std::rc::Weak<T> where T: ?Sized]
120119
[std::cell::OnceCell<T> where T]
121120
[std::sync::mpsc::Receiver<T> where T]
122121
[std::sync::mpsc::Sender<T> where T]
@@ -179,6 +178,7 @@ cfg_match! {
179178
[crate::sync::WorkerLocal<T> where T: DynSend]
180179
[crate::intern::Interned<'a, T> where 'a, T: DynSync]
181180
[crate::tagged_ptr::CopyTaggedPtr<P, T, CP> where P: Sync + crate::tagged_ptr::Pointer, T: Sync + crate::tagged_ptr::Tag, const CP: bool]
181+
[triomphe::Arc<T> where T: ?Sized + DynSync + DynSend]
182182
[parking_lot::lock_api::Mutex<R, T> where R: DynSync, T: ?Sized + DynSend]
183183
[parking_lot::lock_api::RwLock<R, T> where R: DynSync, T: ?Sized + DynSend + DynSync]
184184
[indexmap::IndexSet<V, S> where V: DynSync, S: DynSync]

compiler/rustc_data_structures/src/owned_slice.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::borrow::Borrow;
22
use std::ops::Deref;
33

4+
use unsize::{CoerceUnsize, Coercion};
5+
46
// Use our fake Send/Sync traits when on not parallel compiler,
57
// so that `OwnedSlice` only implements/requires Send/Sync
68
// for parallel compiler builds.
@@ -89,7 +91,8 @@ where
8991
let owner = Lrc::new(owner);
9092
let bytes = slicer(&*owner)?;
9193

92-
Ok(OwnedSlice { bytes, owner })
94+
let owner_unsized = owner.clone().unsize(Coercion!(to dyn sync::Send + sync::Sync));
95+
Ok(OwnedSlice { bytes, owner: owner_unsized })
9396
}
9497

9598
impl OwnedSlice {

compiler/rustc_data_structures/src/stable_hasher.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,7 @@ impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T> {
381381
}
382382
}
383383

384-
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> {
385-
#[inline]
386-
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
387-
(**self).hash_stable(ctx, hasher);
388-
}
389-
}
390-
391-
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::sync::Arc<T> {
384+
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for crate::sync::Lrc<T> {
392385
#[inline]
393386
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
394387
(**self).hash_stable(ctx, hasher);

compiler/rustc_data_structures/src/sync.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ cfg_match! {
199199
pub type AtomicU64 = Atomic<u64>;
200200

201201
pub use std::rc::Rc as Lrc;
202-
pub use std::rc::Weak as Weak;
203202
#[doc(no_inline)]
204203
pub use std::cell::Ref as ReadGuard;
205204
#[doc(no_inline)]
@@ -277,8 +276,7 @@ cfg_match! {
277276
#[cfg(not(target_has_atomic = "64"))]
278277
pub use portable_atomic::AtomicU64;
279278

280-
pub use std::sync::Arc as Lrc;
281-
pub use std::sync::Weak as Weak;
279+
pub use triomphe::Arc as Lrc;
282280

283281
pub type LRef<'a, T> = &'a T;
284282

compiler/rustc_interface/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
4949
rustc_traits = { path = "../rustc_traits" }
5050
rustc_ty_utils = { path = "../rustc_ty_utils" }
5151
tracing = "0.1"
52+
unsize = "1.1"
5253
# tidy-alphabetical-end
5354

5455
[features]
@@ -58,6 +59,6 @@ rustc_use_parallel_compiler = [
5859
'dep:rustc-rayon',
5960
'dep:rustc-rayon-core',
6061
'rustc_query_impl/rustc_use_parallel_compiler',
61-
'rustc_errors/rustc_use_parallel_compiler'
62+
'rustc_errors/rustc_use_parallel_compiler',
6263
]
6364
# tidy-alphabetical-end

0 commit comments

Comments
 (0)