@@ -997,7 +997,7 @@ struct Diagnostic {
997
997
}
998
998
999
999
#[ derive( PartialEq , Clone , Copy , Debug ) ]
1000
- enum MainThreadWorkerState {
1000
+ enum MainThreadState {
1001
1001
/// Doing nothing.
1002
1002
Idle ,
1003
1003
@@ -1300,13 +1300,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
1300
1300
// the implicit Token the compiler process owns no matter what.
1301
1301
let mut tokens = Vec :: new ( ) ;
1302
1302
1303
- let mut main_thread_worker_state = MainThreadWorkerState :: Idle ;
1303
+ let mut main_thread_state = MainThreadState :: Idle ;
1304
1304
1305
1305
// How many LLVM worker threads are running while holding a Token. This
1306
1306
// *excludes* the LLVM worker thread that the main thread is lending a
1307
1307
// Token to (when the main thread is in the `Lending` state).
1308
1308
// 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 }`.
1310
1310
let mut running_with_own_token = 0 ;
1311
1311
1312
1312
let prof = & cgcx. prof ;
@@ -1319,19 +1319,19 @@ fn start_executing_work<B: ExtraBackendMethods>(
1319
1319
// work to be done.
1320
1320
while codegen_state == Ongoing
1321
1321
|| running_with_own_token > 0
1322
- || main_thread_worker_state == MainThreadWorkerState :: Lending
1322
+ || main_thread_state == MainThreadState :: Lending
1323
1323
|| ( codegen_state == Completed
1324
1324
&& !( work_items. is_empty ( )
1325
1325
&& needs_fat_lto. is_empty ( )
1326
1326
&& needs_thin_lto. is_empty ( )
1327
1327
&& lto_import_only_modules. is_empty ( )
1328
- && main_thread_worker_state == MainThreadWorkerState :: Idle ) )
1328
+ && main_thread_state == MainThreadState :: Idle ) )
1329
1329
{
1330
1330
// While there are still CGUs to be codegened, the coordinator has
1331
1331
// to decide how to utilize the compiler processes implicit Token:
1332
1332
// For codegenning more CGU or for running them through LLVM.
1333
1333
if codegen_state == Ongoing {
1334
- if main_thread_worker_state == MainThreadWorkerState :: Idle {
1334
+ if main_thread_state == MainThreadState :: Idle {
1335
1335
// Compute the number of workers that will be running once we've taken as many
1336
1336
// items from the work queue as we can, plus one for the main thread. It's not
1337
1337
// critically important that we use this instead of just
@@ -1348,7 +1348,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1348
1348
if codegen_worker_send. send ( CguMessage ) . is_err ( ) {
1349
1349
panic ! ( "Could not send CguMessage to main thread" )
1350
1350
}
1351
- main_thread_worker_state = MainThreadWorkerState :: Codegenning ;
1351
+ main_thread_state = MainThreadState :: Codegenning ;
1352
1352
} else {
1353
1353
// The queue is full enough to not let the worker
1354
1354
// threads starve. Use the implicit Token to do some
@@ -1364,7 +1364,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1364
1364
cgcx. config ( item. module_kind ( ) ) ,
1365
1365
& mut llvm_start_time,
1366
1366
) ;
1367
- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1367
+ main_thread_state = MainThreadState :: Lending ;
1368
1368
spawn_work ( cgcx, item) ;
1369
1369
}
1370
1370
}
@@ -1376,7 +1376,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1376
1376
// queue to do LTO
1377
1377
if work_items. is_empty ( )
1378
1378
&& running_with_own_token == 0
1379
- && main_thread_worker_state == MainThreadWorkerState :: Idle
1379
+ && main_thread_state == MainThreadState :: Idle
1380
1380
{
1381
1381
assert ! ( !started_lto) ;
1382
1382
started_lto = true ;
@@ -1401,8 +1401,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
1401
1401
// In this branch, we know that everything has been codegened,
1402
1402
// so it's just a matter of determining whether the implicit
1403
1403
// 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 => {
1406
1406
if let Some ( ( item, _) ) = work_items. pop ( ) {
1407
1407
let cgcx = CodegenContext {
1408
1408
worker : get_worker_id ( & mut free_worker_ids) ,
@@ -1413,7 +1413,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1413
1413
cgcx. config ( item. module_kind ( ) ) ,
1414
1414
& mut llvm_start_time,
1415
1415
) ;
1416
- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1416
+ main_thread_state = MainThreadState :: Lending ;
1417
1417
spawn_work ( cgcx, item) ;
1418
1418
} else {
1419
1419
// There is no unstarted work, so let the main thread
@@ -1424,14 +1424,14 @@ fn start_executing_work<B: ExtraBackendMethods>(
1424
1424
// giving the Token back.
1425
1425
debug_assert ! ( running_with_own_token > 0 ) ;
1426
1426
running_with_own_token -= 1 ;
1427
- main_thread_worker_state = MainThreadWorkerState :: Lending ;
1427
+ main_thread_state = MainThreadState :: Lending ;
1428
1428
}
1429
1429
}
1430
- MainThreadWorkerState :: Codegenning => bug ! (
1430
+ MainThreadState :: Codegenning => bug ! (
1431
1431
"codegen worker should not be codegenning after \
1432
1432
codegen was already completed"
1433
1433
) ,
1434
- MainThreadWorkerState :: Lending => {
1434
+ MainThreadState :: Lending => {
1435
1435
// Already making good use of that token
1436
1436
}
1437
1437
}
@@ -1467,8 +1467,8 @@ fn start_executing_work<B: ExtraBackendMethods>(
1467
1467
// We may also not actually drop a token here if the worker was
1468
1468
// running with an "ephemeral token".
1469
1469
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 ;
1472
1472
} else {
1473
1473
running_with_own_token -= 1 ;
1474
1474
}
@@ -1486,12 +1486,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
1486
1486
Ok ( token) => {
1487
1487
tokens. push ( token) ;
1488
1488
1489
- if main_thread_worker_state == MainThreadWorkerState :: Lending {
1489
+ if main_thread_state == MainThreadState :: Lending {
1490
1490
// If the main thread token is used for LLVM work
1491
1491
// at the moment, we turn that thread into a regular
1492
1492
// LLVM worker thread, so the main thread is free
1493
1493
// to react to codegen demand.
1494
- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1494
+ main_thread_state = MainThreadState :: Idle ;
1495
1495
running_with_own_token += 1 ;
1496
1496
}
1497
1497
}
@@ -1521,16 +1521,16 @@ fn start_executing_work<B: ExtraBackendMethods>(
1521
1521
if !cgcx. opts . unstable_opts . no_parallel_llvm {
1522
1522
helper. request_token ( ) ;
1523
1523
}
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 ;
1526
1526
}
1527
1527
1528
1528
Message :: CodegenComplete => {
1529
1529
if codegen_state != Aborted {
1530
1530
codegen_state = Completed ;
1531
1531
}
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 ;
1534
1534
}
1535
1535
1536
1536
// If codegen is aborted that means translation was aborted due
@@ -1590,9 +1590,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
1590
1590
Message :: AddImportOnlyModule { module_data, work_product } => {
1591
1591
assert ! ( !started_lto) ;
1592
1592
assert_eq ! ( codegen_state, Ongoing ) ;
1593
- assert_eq ! ( main_thread_worker_state , MainThreadWorkerState :: Codegenning ) ;
1593
+ assert_eq ! ( main_thread_state , MainThreadState :: Codegenning ) ;
1594
1594
lto_import_only_modules. push ( ( module_data, work_product) ) ;
1595
- main_thread_worker_state = MainThreadWorkerState :: Idle ;
1595
+ main_thread_state = MainThreadState :: Idle ;
1596
1596
}
1597
1597
}
1598
1598
}
0 commit comments