Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillot
Introduce `DynSend` and `DynSync` auto trait for parallel compiler part of parallel-rustc #101566 This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency. r? `@cjgillot`
This commit is contained in:
commit
dd8ec9c88d
26 changed files with 557 additions and 110 deletions
|
@ -14,7 +14,9 @@ pub use crate::*;
|
|||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher};
|
||||
use rustc_data_structures::sync::{AtomicU32, Lrc, MappedReadGuard, ReadGuard, RwLock};
|
||||
use rustc_data_structures::sync::{
|
||||
AtomicU32, IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock,
|
||||
};
|
||||
use std::cmp;
|
||||
use std::hash::Hash;
|
||||
use std::path::{self, Path, PathBuf};
|
||||
|
@ -176,7 +178,7 @@ pub struct SourceMap {
|
|||
used_address_space: AtomicU32,
|
||||
|
||||
files: RwLock<SourceMapFiles>,
|
||||
file_loader: Box<dyn FileLoader + Sync + Send>,
|
||||
file_loader: IntoDynSyncSend<Box<dyn FileLoader + Sync + Send>>,
|
||||
// This is used to apply the file path remapping as specified via
|
||||
// `--remap-path-prefix` to all `SourceFile`s allocated within this `SourceMap`.
|
||||
path_mapping: FilePathMapping,
|
||||
|
@ -202,7 +204,7 @@ impl SourceMap {
|
|||
SourceMap {
|
||||
used_address_space: AtomicU32::new(0),
|
||||
files: Default::default(),
|
||||
file_loader,
|
||||
file_loader: IntoDynSyncSend(file_loader),
|
||||
path_mapping,
|
||||
hash_kind,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue