introduce DynSend
and DynSync
auto trait
This commit is contained in:
parent
963e5c0eff
commit
b9746ce039
26 changed files with 558 additions and 115 deletions
|
@ -17,10 +17,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
|
|||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||
|
||||
use rustc_data_structures::sync::par_iter;
|
||||
#[cfg(parallel_compiler)]
|
||||
use rustc_data_structures::sync::ParallelIterator;
|
||||
use rustc_data_structures::sync::par_map;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
|
@ -689,7 +686,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
// This likely is a temporary measure. Once we don't have to support the
|
||||
// non-parallel compiler anymore, we can compile CGUs end-to-end in
|
||||
// parallel and get rid of the complicated scheduling logic.
|
||||
let mut pre_compiled_cgus = if cfg!(parallel_compiler) {
|
||||
let mut pre_compiled_cgus = if tcx.sess.threads() > 1 {
|
||||
tcx.sess.time("compile_first_CGU_batch", || {
|
||||
// Try to find one CGU to compile per thread.
|
||||
let cgus: Vec<_> = cgu_reuse
|
||||
|
@ -702,12 +699,10 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
// Compile the found CGUs in parallel.
|
||||
let start_time = Instant::now();
|
||||
|
||||
let pre_compiled_cgus = par_iter(cgus)
|
||||
.map(|(i, _)| {
|
||||
let module = backend.compile_codegen_unit(tcx, codegen_units[i].name());
|
||||
(i, module)
|
||||
})
|
||||
.collect();
|
||||
let pre_compiled_cgus = par_map(cgus, |(i, _)| {
|
||||
let module = backend.compile_codegen_unit(tcx, codegen_units[i].name());
|
||||
(i, module)
|
||||
});
|
||||
|
||||
total_codegen_time += start_time.elapsed();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ use rustc_target::spec::Target;
|
|||
|
||||
pub use rustc_data_structures::sync::MetadataRef;
|
||||
|
||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||
use std::any::Any;
|
||||
|
||||
pub trait BackendTypes {
|
||||
|
@ -117,7 +118,9 @@ pub trait CodegenBackend {
|
|||
) -> Result<(), ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
|
||||
pub trait ExtraBackendMethods:
|
||||
CodegenBackend + WriteBackendMethods + Sized + Send + Sync + DynSend + DynSync
|
||||
{
|
||||
fn codegen_allocator<'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue