@@ -997,7 +997,7 @@ struct Diagnostic {
997997}
998998
999999#[ derive( PartialEq , Clone , Copy , Debug ) ]
1000- enum MainThreadWorkerState {
1000+ enum MainThreadState {
10011001 /// Doing nothing.
10021002 Idle ,
10031003
@@ -1300,13 +1300,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
13001300 // the implicit Token the compiler process owns no matter what.
13011301 let mut tokens = Vec :: new ( ) ;
13021302
1303- let mut main_thread_worker_state = MainThreadWorkerState :: Idle ;
1303+ let mut main_thread_state = MainThreadState :: Idle ;
13041304
13051305 // How many LLVM worker threads are running while holding a Token. This
13061306 // *excludes* the LLVM worker thread that the main thread is lending a
13071307 // Token to (when the main thread is in the `Lending` state).
13081308 // In other words, the number of LLVM threads is actually equal to
1309- // `running + if main_thread_worker_state == Lending { 1 } else { 0 }`.
1309+ // `running + if main_thread_state == Lending { 1 } else { 0 }`.
13101310 let mut running_with_own_token = 0 ;
13111311
13121312 let prof = & cgcx. prof ;
@@ -1319,19 +1319,19 @@ fn start_executing_work<B: ExtraBackendMethods>(
13191319 // work to be done.
13201320 while codegen_state == Ongoing
13211321 || running_with_own_token > 0
1322- || main_thread_worker_state == MainThreadWorkerState :: Lending
1322+ || main_thread_state == MainThreadState :: Lending
13231323 || ( codegen_state == Completed
13241324 && !( work_items. is_empty ( )
13251325 && needs_fat_lto. is_empty ( )
13261326 && needs_thin_lto. is_empty ( )
13271327 && lto_import_only_modules. is_empty ( )
1328- && main_thread_worker_state == MainThreadWorkerState :: Idle ) )
1328+ && main_thread_state == MainThreadState :: Idle ) )
13291329 {
13301330 // While there are still CGUs to be codegened, the coordinator has
13311331 // to decide how to utilize the compiler processes implicit Token:
13321332 // For codegenning more CGU or for running them through LLVM.
13331333 if codegen_state == Ongoing {
1334- if main_thread_worker_state == MainThreadWorkerState :: Idle {
1334+ if main_thread_state == MainThreadState :: Idle {
13351335 // Compute the number of workers that will be running once we've taken as many
13361336 // items from the work queue as we can, plus one for the main thread. It's not
13371337 // critically important that we use this instead of just
@@ -1348,7 +1348,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
13481348 if codegen_worker_send. send ( CguMessage ) . is_err ( ) {
13491349 panic ! ( "Could not send CguMessage to main thread" )
13501350 }
1351- main_thread_worker_state = MainThreadWorkerState :: Codegenning ;
1351+ main_thread_state = MainThreadState :: Codegenning ;
13521352 } else {
13531353 // The queue is full enough to not let the worker
13541354 // threads starve. Use the implicit Token to do some
@@ -1364,7 +1364,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
13641364 cgcx. config ( item. module_kind ( ) ) ,
13651365 & mut llvm_start_time,
13661366 ) ;
1367- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1367+ main_thread_state = MainThreadState :: Lending ;
13681368 spawn_work ( cgcx, item) ;
13691369 }
13701370 }
@@ -1376,7 +1376,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
13761376 // queue to do LTO
13771377 if work_items. is_empty ( )
13781378 && running_with_own_token == 0
1379- && main_thread_worker_state == MainThreadWorkerState :: Idle
1379+ && main_thread_state == MainThreadState :: Idle
13801380 {
13811381 assert ! ( !started_lto) ;
13821382 started_lto = true ;
@@ -1401,8 +1401,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
14011401 // In this branch, we know that everything has been codegened,
14021402 // so it's just a matter of determining whether the implicit
14031403 // Token is free to use for LLVM work.
1404- match main_thread_worker_state {
1405- MainThreadWorkerState :: Idle => {
1404+ match main_thread_state {
1405+ MainThreadState :: Idle => {
14061406 if let Some ( ( item, _) ) = work_items. pop ( ) {
14071407 let cgcx = CodegenContext {
14081408 worker : get_worker_id ( & mut free_worker_ids) ,
@@ -1413,7 +1413,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14131413 cgcx. config ( item. module_kind ( ) ) ,
14141414 & mut llvm_start_time,
14151415 ) ;
1416- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1416+ main_thread_state = MainThreadState :: Lending ;
14171417 spawn_work ( cgcx, item) ;
14181418 } else {
14191419 // There is no unstarted work, so let the main thread
@@ -1424,14 +1424,14 @@ fn start_executing_work<B: ExtraBackendMethods>(
14241424 // giving the Token back.
14251425 debug_assert ! ( running_with_own_token > 0 ) ;
14261426 running_with_own_token -= 1 ;
1427- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1427+ main_thread_state = MainThreadState :: Lending ;
14281428 }
14291429 }
1430- MainThreadWorkerState :: Codegenning => bug ! (
1430+ MainThreadState :: Codegenning => bug ! (
14311431 "codegen worker should not be codegenning after \
14321432 codegen was already completed"
14331433 ) ,
1434- MainThreadWorkerState :: Lending => {
1434+ MainThreadState :: Lending => {
14351435 // Already making good use of that token
14361436 }
14371437 }
@@ -1467,8 +1467,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
14671467 // We may also not actually drop a token here if the worker was
14681468 // running with an "ephemeral token".
14691469 let mut free_worker = |worker_id| {
1470- if main_thread_worker_state == MainThreadWorkerState :: Lending {
1471- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1470+ if main_thread_state == MainThreadState :: Lending {
1471+ main_thread_state = MainThreadState :: Idle ;
14721472 } else {
14731473 running_with_own_token -= 1 ;
14741474 }
@@ -1486,12 +1486,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
14861486 Ok ( token) => {
14871487 tokens. push ( token) ;
14881488
1489- if main_thread_worker_state == MainThreadWorkerState :: Lending {
1489+ if main_thread_state == MainThreadState :: Lending {
14901490 // If the main thread token is used for LLVM work
14911491 // at the moment, we turn that thread into a regular
14921492 // LLVM worker thread, so the main thread is free
14931493 // to react to codegen demand.
1494- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1494+ main_thread_state = MainThreadState :: Idle ;
14951495 running_with_own_token += 1 ;
14961496 }
14971497 }
@@ -1521,16 +1521,16 @@ fn start_executing_work<B: ExtraBackendMethods>(
15211521 if !cgcx. opts . unstable_opts . no_parallel_llvm {
15221522 helper. request_token ( ) ;
15231523 }
1524- assert_eq ! ( main_thread_worker_state , MainThreadWorkerState :: Codegenning ) ;
1525- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1524+ assert_eq ! ( main_thread_state , MainThreadState :: Codegenning ) ;
1525+ main_thread_state = MainThreadState :: Idle ;
15261526 }
15271527
15281528 Message :: CodegenComplete => {
15291529 if codegen_state != Aborted {
15301530 codegen_state = Completed ;
15311531 }
1532- assert_eq ! ( main_thread_worker_state , MainThreadWorkerState :: Codegenning ) ;
1533- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1532+ assert_eq ! ( main_thread_state , MainThreadState :: Codegenning ) ;
1533+ main_thread_state = MainThreadState :: Idle ;
15341534 }
15351535
15361536 // If codegen is aborted that means translation was aborted due
@@ -1590,9 +1590,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
15901590 Message :: AddImportOnlyModule { module_data, work_product } => {
15911591 assert ! ( !started_lto) ;
15921592 assert_eq ! ( codegen_state, Ongoing ) ;
1593- assert_eq ! ( main_thread_worker_state , MainThreadWorkerState :: Codegenning ) ;
1593+ assert_eq ! ( main_thread_state , MainThreadState :: Codegenning ) ;
15941594 lto_import_only_modules. push ( ( module_data, work_product) ) ;
1595- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1595+ main_thread_state = MainThreadState :: Idle ;
15961596 }
15971597 }
15981598 }
0 commit comments