@@ -951,10 +951,13 @@ pub enum Message<B: WriteBackendMethods> {
951
951
work_product: WorkProduct,
952
952
},
953
953
CodegenComplete,
954
- CodegenItem,
955
954
CodegenAborted,
956
955
}
957
956
957
+ /// A message sent from the coordinator thread to the main thread telling it to
958
+ /// process another codegen unit.
959
+ pub struct CguMessage;
960
+
958
961
type DiagnosticArgName<'source> = Cow<'source, str>;
959
962
960
963
struct Diagnostic {
@@ -976,7 +979,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
976
979
tcx: TyCtxt<'_>,
977
980
crate_info: &CrateInfo,
978
981
shared_emitter: SharedEmitter,
979
- codegen_worker_send: Sender<Message<B> >,
982
+ codegen_worker_send: Sender<CguMessage >,
980
983
coordinator_receive: Receiver<Box<dyn Any + Send>>,
981
984
total_cgus: usize,
982
985
jobserver: Client,
@@ -1284,9 +1287,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
1284
1287
let anticipated_running = running + additional_running + 1;
1285
1288
1286
1289
if !queue_full_enough(work_items.len(), anticipated_running) {
1287
- // The queue is not full enough, codegen more items :
1288
- if codegen_worker_send.send(Message::CodegenItem ).is_err() {
1289
- panic!("Could not send Message::CodegenItem to main thread")
1290
+ // The queue is not full enough, process more codegen units :
1291
+ if codegen_worker_send.send(CguMessage ).is_err() {
1292
+ panic!("Could not send CguMessage to main thread")
1290
1293
}
1291
1294
main_thread_worker_state = MainThreadWorkerState::Codegenning;
1292
1295
} else {
@@ -1522,7 +1525,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1522
1525
codegen_done = true;
1523
1526
codegen_aborted = true;
1524
1527
}
1525
- Message::CodegenItem => bug!("the coordinator should not receive codegen requests"),
1526
1528
}
1527
1529
}
1528
1530
@@ -1879,7 +1881,7 @@ pub struct OngoingCodegen<B: ExtraBackendMethods> {
1879
1881
pub metadata: EncodedMetadata,
1880
1882
pub metadata_module: Option<CompiledModule>,
1881
1883
pub crate_info: CrateInfo,
1882
- pub codegen_worker_receive: Receiver<Message<B> >,
1884
+ pub codegen_worker_receive: Receiver<CguMessage >,
1883
1885
pub shared_emitter_main: SharedEmitterMain,
1884
1886
pub output_filenames: Arc<OutputFilenames>,
1885
1887
pub coordinator: Coordinator<B>,
@@ -1953,10 +1955,9 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
1953
1955
1954
1956
pub fn wait_for_signal_to_codegen_item(&self) {
1955
1957
match self.codegen_worker_receive.recv() {
1956
- Ok(Message::CodegenItem ) => {
1957
- // Nothing to do
1958
+ Ok(CguMessage ) => {
1959
+ // Ok to proceed.
1958
1960
}
1959
- Ok(_) => panic!("unexpected message"),
1960
1961
Err(_) => {
1961
1962
// One of the LLVM threads must have panicked, fall through so
1962
1963
// error handling can be reached.
0 commit comments