@@ -848,6 +848,8 @@ const Job = union(enum) {
848
848
/// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that
849
849
/// all types are resolved before the linker task is queued.
850
850
/// If the backend does not support `Zcu.Feature.separate_thread`, codegen and linking happen immediately.
851
+ /// Before queueing this `Job`, increase the estimated total item count for both
852
+ /// `comp.zcu.?.codegen_prog_node` and `comp.link_prog_node`.
851
853
codegen_func : struct {
852
854
func : InternPool.Index ,
853
855
/// The AIR emitted from analyzing `func`; owned by this `Job` in `gpa`.
@@ -857,12 +859,15 @@ const Job = union(enum) {
857
859
/// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that
858
860
/// all types are resolved before the linker task is queued.
859
861
/// If the backend does not support `Zcu.Feature.separate_thread`, the task is run immediately.
862
+ /// Before queueing this `Job`, increase the estimated total item count for `comp.link_prog_node`.
860
863
link_nav : InternPool.Nav.Index ,
861
864
/// Queue a `link.ZcuTask` to emit debug information for this container type.
862
865
/// This `Job` exists (instead of the `link.ZcuTask` being directly queued) to ensure that
863
866
/// all types are resolved before the linker task is queued.
864
867
/// If the backend does not support `Zcu.Feature.separate_thread`, the task is run immediately.
868
+ /// Before queueing this `Job`, increase the estimated total item count for `comp.link_prog_node`.
865
869
link_type : InternPool.Index ,
870
+ /// Before queueing this `Job`, increase the estimated total item count for `comp.link_prog_node`.
866
871
update_line_number : InternPool.TrackedInst.Index ,
867
872
/// The `AnalUnit`, which is *not* a `func`, must be semantically analyzed.
868
873
/// This may be its first time being analyzed, or it may be outdated.
@@ -4592,11 +4597,17 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4592
4597
const zcu = comp .zcu .? ;
4593
4598
const gpa = zcu .gpa ;
4594
4599
var air = func .air ;
4595
- errdefer air .deinit (gpa );
4600
+ errdefer {
4601
+ zcu .codegen_prog_node .completeOne ();
4602
+ comp .link_prog_node .completeOne ();
4603
+ air .deinit (gpa );
4604
+ }
4596
4605
if (! air .typesFullyResolved (zcu )) {
4597
4606
// Type resolution failed in a way which affects this function. This is a transitive
4598
4607
// failure, but it doesn't need recording, because this function semantically depends
4599
4608
// on the failed type, so when it is changed the function is updated.
4609
+ zcu .codegen_prog_node .completeOne ();
4610
+ comp .link_prog_node .completeOne ();
4600
4611
air .deinit (gpa );
4601
4612
return ;
4602
4613
}
@@ -4606,7 +4617,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4606
4617
.value = undefined ,
4607
4618
};
4608
4619
assert (zcu .pending_codegen_jobs .rmw (.Add , 1 , .monotonic ) > 0 ); // the "Code Generation" node hasn't been ended
4609
- zcu .codegen_prog_node .increaseEstimatedTotalItems (1 );
4610
4620
// This value is used as a heuristic to avoid queueing too much AIR/MIR at once (hence
4611
4621
// using a lot of memory). If this would cause too many AIR bytes to be in-flight, we
4612
4622
// will block on the `dispatchZcuLinkTask` call below.
@@ -4640,6 +4650,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4640
4650
if (nav .analysis != null ) {
4641
4651
const unit : InternPool.AnalUnit = .wrap (.{ .nav_val = nav_index });
4642
4652
if (zcu .failed_analysis .contains (unit ) or zcu .transitive_failed_analysis .contains (unit )) {
4653
+ comp .link_prog_node .completeOne ();
4643
4654
return ;
4644
4655
}
4645
4656
}
@@ -4648,6 +4659,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4648
4659
// Type resolution failed in a way which affects this `Nav`. This is a transitive
4649
4660
// failure, but it doesn't need recording, because this `Nav` semantically depends
4650
4661
// on the failed type, so when it is changed the `Nav` will be updated.
4662
+ comp .link_prog_node .completeOne ();
4651
4663
return ;
4652
4664
}
4653
4665
comp .dispatchZcuLinkTask (tid , .{ .link_nav = nav_index });
@@ -4659,6 +4671,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
4659
4671
// Type resolution failed in a way which affects this type. This is a transitive
4660
4672
// failure, but it doesn't need recording, because this type semantically depends
4661
4673
// on the failed type, so when that is changed, this type will be updated.
4674
+ comp .link_prog_node .completeOne ();
4662
4675
return ;
4663
4676
}
4664
4677
comp .dispatchZcuLinkTask (tid , .{ .link_type = ty });
@@ -7460,7 +7473,6 @@ pub fn queuePrelinkTasks(comp: *Compilation, tasks: []const link.PrelinkTask) vo
7460
7473
/// The reason for the double-queue here is that the first queue ensures any
7461
7474
/// resolve_type_fully tasks are complete before this dispatch function is called.
7462
7475
fn dispatchZcuLinkTask (comp : * Compilation , tid : usize , task : link.ZcuTask ) void {
7463
- comp .link_prog_node .increaseEstimatedTotalItems (1 );
7464
7476
if (! comp .separateCodegenThreadOk ()) {
7465
7477
assert (tid == 0 );
7466
7478
if (task == .link_func ) {
0 commit comments