authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-06-27 23:21:44+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-04 21:01:40+01:00
logbc8cd135987c7dc7419d034ba31178331d606cfa
treed87db0aced8e650dd50e997cacb0b7933715d130
parentd9f1a952b8b0e19aafcf568b35cc220adbb4a7b5
signaturelock-open Commit is signed but in an unrecognized format.

compiler: rename AnalSubject to AnalUnit

I meant to call it this originally, I just got mixed up -- sorry!

4 files changed, 54 insertions(+), 54 deletions(-)

src/Compilation.zig+1-1
...@@ -3494,7 +3494,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: std.Progress.Node) !vo...@@ -3494,7 +3494,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: std.Progress.Node) !vo
3494 .{@errorName(err)},3494 .{@errorName(err)},
3495 ));3495 ));
3496 decl.analysis = .codegen_failure;3496 decl.analysis = .codegen_failure;
3497 try module.retryable_failures.append(gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));3497 try module.retryable_failures.append(gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
3498 };3498 };
3499 },3499 },
3500 .analyze_mod => |pkg| {3500 .analyze_mod => |pkg| {
src/InternPool.zig+11-11
...@@ -81,7 +81,7 @@ namespace_name_deps: std.AutoArrayHashMapUnmanaged(NamespaceNameKey, DepEntry.In...@@ -81,7 +81,7 @@ namespace_name_deps: std.AutoArrayHashMapUnmanaged(NamespaceNameKey, DepEntry.In
81/// Given a `Depender`, points to an entry in `dep_entries` whose `depender`81/// Given a `Depender`, points to an entry in `dep_entries` whose `depender`
82/// matches. The `next_dependee` field can be used to iterate all such entries82/// matches. The `next_dependee` field can be used to iterate all such entries
83/// and remove them from the corresponding lists.83/// and remove them from the corresponding lists.
84first_dependency: std.AutoArrayHashMapUnmanaged(AnalSubject, DepEntry.Index) = .{},84first_dependency: std.AutoArrayHashMapUnmanaged(AnalUnit, DepEntry.Index) = .{},
8585
86/// Stores dependency information. The hashmaps declared above are used to look86/// Stores dependency information. The hashmaps declared above are used to look
87/// up entries in this list as required. This is not stored in `extra` so that87/// up entries in this list as required. This is not stored in `extra` so that
...@@ -132,36 +132,36 @@ pub fn trackZir(ip: *InternPool, gpa: Allocator, file: *Module.File, inst: Zir.I...@@ -132,36 +132,36 @@ pub fn trackZir(ip: *InternPool, gpa: Allocator, file: *Module.File, inst: Zir.I
132 return @enumFromInt(gop.index);132 return @enumFromInt(gop.index);
133}133}
134134
135/// Analysis Subject. Represents a single entity which undergoes semantic analysis.135/// Analysis Unit. Represents a single entity which undergoes semantic analysis.
136/// This is either a `Decl` (in future `Cau`) or a runtime function.136/// This is either a `Decl` (in future `Cau`) or a runtime function.
137/// The LSB is used as a tag bit.137/// The LSB is used as a tag bit.
138/// This is the "source" of an incremental dependency edge.138/// This is the "source" of an incremental dependency edge.
139pub const AnalSubject = packed struct(u32) {139pub const AnalUnit = packed struct(u32) {
140 kind: enum(u1) { decl, func },140 kind: enum(u1) { decl, func },
141 index: u31,141 index: u31,
142 pub const Unwrapped = union(enum) {142 pub const Unwrapped = union(enum) {
143 decl: DeclIndex,143 decl: DeclIndex,
144 func: InternPool.Index,144 func: InternPool.Index,
145 };145 };
146 pub fn unwrap(as: AnalSubject) Unwrapped {146 pub fn unwrap(as: AnalUnit) Unwrapped {
147 return switch (as.kind) {147 return switch (as.kind) {
148 .decl => .{ .decl = @enumFromInt(as.index) },148 .decl => .{ .decl = @enumFromInt(as.index) },
149 .func => .{ .func = @enumFromInt(as.index) },149 .func => .{ .func = @enumFromInt(as.index) },
150 };150 };
151 }151 }
152 pub fn wrap(raw: Unwrapped) AnalSubject {152 pub fn wrap(raw: Unwrapped) AnalUnit {
153 return switch (raw) {153 return switch (raw) {
154 .decl => |decl| .{ .kind = .decl, .index = @intCast(@intFromEnum(decl)) },154 .decl => |decl| .{ .kind = .decl, .index = @intCast(@intFromEnum(decl)) },
155 .func => |func| .{ .kind = .func, .index = @intCast(@intFromEnum(func)) },155 .func => |func| .{ .kind = .func, .index = @intCast(@intFromEnum(func)) },
156 };156 };
157 }157 }
158 pub fn toOptional(as: AnalSubject) Optional {158 pub fn toOptional(as: AnalUnit) Optional {
159 return @enumFromInt(@as(u32, @bitCast(as)));159 return @enumFromInt(@as(u32, @bitCast(as)));
160 }160 }
161 pub const Optional = enum(u32) {161 pub const Optional = enum(u32) {
162 none = std.math.maxInt(u32),162 none = std.math.maxInt(u32),
163 _,163 _,
164 pub fn unwrap(opt: Optional) ?AnalSubject {164 pub fn unwrap(opt: Optional) ?AnalUnit {
165 return switch (opt) {165 return switch (opt) {
166 .none => null,166 .none => null,
167 _ => @bitCast(@intFromEnum(opt)),167 _ => @bitCast(@intFromEnum(opt)),
...@@ -178,7 +178,7 @@ pub const Dependee = union(enum) {...@@ -178,7 +178,7 @@ pub const Dependee = union(enum) {
178 namespace_name: NamespaceNameKey,178 namespace_name: NamespaceNameKey,
179};179};
180180
181pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender: AnalSubject) void {181pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender: AnalUnit) void {
182 var opt_idx = (ip.first_dependency.fetchSwapRemove(depender) orelse return).value.toOptional();182 var opt_idx = (ip.first_dependency.fetchSwapRemove(depender) orelse return).value.toOptional();
183183
184 while (opt_idx.unwrap()) |idx| {184 while (opt_idx.unwrap()) |idx| {
...@@ -207,7 +207,7 @@ pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender:...@@ -207,7 +207,7 @@ pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender:
207pub const DependencyIterator = struct {207pub const DependencyIterator = struct {
208 ip: *const InternPool,208 ip: *const InternPool,
209 next_entry: DepEntry.Index.Optional,209 next_entry: DepEntry.Index.Optional,
210 pub fn next(it: *DependencyIterator) ?AnalSubject {210 pub fn next(it: *DependencyIterator) ?AnalUnit {
211 const idx = it.next_entry.unwrap() orelse return null;211 const idx = it.next_entry.unwrap() orelse return null;
212 const entry = it.ip.dep_entries.items[@intFromEnum(idx)];212 const entry = it.ip.dep_entries.items[@intFromEnum(idx)];
213 it.next_entry = entry.next;213 it.next_entry = entry.next;
...@@ -236,7 +236,7 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI...@@ -236,7 +236,7 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI
236 };236 };
237}237}
238238
239pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalSubject, dependee: Dependee) Allocator.Error!void {239pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, dependee: Dependee) Allocator.Error!void {
240 const first_depender_dep: DepEntry.Index.Optional = if (ip.first_dependency.get(depender)) |idx| dep: {240 const first_depender_dep: DepEntry.Index.Optional = if (ip.first_dependency.get(depender)) |idx| dep: {
241 // The entry already exists, so there is capacity to overwrite it later.241 // The entry already exists, so there is capacity to overwrite it later.
242 break :dep idx.toOptional();242 break :dep idx.toOptional();
...@@ -300,7 +300,7 @@ pub const DepEntry = extern struct {...@@ -300,7 +300,7 @@ pub const DepEntry = extern struct {
300 /// the first and only entry in one of `intern_pool.*_deps`, and does not300 /// the first and only entry in one of `intern_pool.*_deps`, and does not
301 /// appear in any list by `first_dependency`, but is not in301 /// appear in any list by `first_dependency`, but is not in
302 /// `free_dep_entries` since `*_deps` stores a reference to it.302 /// `free_dep_entries` since `*_deps` stores a reference to it.
303 depender: AnalSubject.Optional,303 depender: AnalUnit.Optional,
304 /// Index into `dep_entries` forming a doubly linked list of all dependencies on this dependee.304 /// Index into `dep_entries` forming a doubly linked list of all dependencies on this dependee.
305 /// Used to iterate all dependers for a given dependee during an update.305 /// Used to iterate all dependers for a given dependee during an update.
306 /// null if this is the end of the list.306 /// null if this is the end of the list.
src/Sema.zig+7-7
...@@ -2735,12 +2735,12 @@ fn maybeRemoveOutdatedType(sema: *Sema, ty: InternPool.Index) !bool {...@@ -2735,12 +2735,12 @@ fn maybeRemoveOutdatedType(sema: *Sema, ty: InternPool.Index) !bool {
2735 if (!zcu.comp.debug_incremental) return false;2735 if (!zcu.comp.debug_incremental) return false;
27362736
2737 const decl_index = Type.fromInterned(ty).getOwnerDecl(zcu);2737 const decl_index = Type.fromInterned(ty).getOwnerDecl(zcu);
2738 const decl_as_depender = InternPool.AnalSubject.wrap(.{ .decl = decl_index });2738 const decl_as_depender = InternPool.AnalUnit.wrap(.{ .decl = decl_index });
2739 const was_outdated = zcu.outdated.swapRemove(decl_as_depender) or2739 const was_outdated = zcu.outdated.swapRemove(decl_as_depender) or
2740 zcu.potentially_outdated.swapRemove(decl_as_depender);2740 zcu.potentially_outdated.swapRemove(decl_as_depender);
2741 if (!was_outdated) return false;2741 if (!was_outdated) return false;
2742 _ = zcu.outdated_ready.swapRemove(decl_as_depender);2742 _ = zcu.outdated_ready.swapRemove(decl_as_depender);
2743 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));2743 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
2744 zcu.intern_pool.remove(ty);2744 zcu.intern_pool.remove(ty);
2745 zcu.declPtr(decl_index).analysis = .dependency_failure;2745 zcu.declPtr(decl_index).analysis = .dependency_failure;
2746 try zcu.markDependeeOutdated(.{ .decl_val = decl_index });2746 try zcu.markDependeeOutdated(.{ .decl_val = decl_index });
...@@ -2834,7 +2834,7 @@ fn zirStructDecl(...@@ -2834,7 +2834,7 @@ fn zirStructDecl(
2834 if (sema.mod.comp.debug_incremental) {2834 if (sema.mod.comp.debug_incremental) {
2835 try ip.addDependency(2835 try ip.addDependency(
2836 sema.gpa,2836 sema.gpa,
2837 InternPool.AnalSubject.wrap(.{ .decl = new_decl_index }),2837 InternPool.AnalUnit.wrap(.{ .decl = new_decl_index }),
2838 .{ .src_hash = try ip.trackZir(sema.gpa, block.getFileScope(mod), inst) },2838 .{ .src_hash = try ip.trackZir(sema.gpa, block.getFileScope(mod), inst) },
2839 );2839 );
2840 }2840 }
...@@ -3068,7 +3068,7 @@ fn zirEnumDecl(...@@ -3068,7 +3068,7 @@ fn zirEnumDecl(
3068 if (sema.mod.comp.debug_incremental) {3068 if (sema.mod.comp.debug_incremental) {
3069 try mod.intern_pool.addDependency(3069 try mod.intern_pool.addDependency(
3070 sema.gpa,3070 sema.gpa,
3071 InternPool.AnalSubject.wrap(.{ .decl = new_decl_index }),3071 InternPool.AnalUnit.wrap(.{ .decl = new_decl_index }),
3072 .{ .src_hash = try mod.intern_pool.trackZir(sema.gpa, block.getFileScope(mod), inst) },3072 .{ .src_hash = try mod.intern_pool.trackZir(sema.gpa, block.getFileScope(mod), inst) },
3073 );3073 );
3074 }3074 }
...@@ -3334,7 +3334,7 @@ fn zirUnionDecl(...@@ -3334,7 +3334,7 @@ fn zirUnionDecl(
3334 if (sema.mod.comp.debug_incremental) {3334 if (sema.mod.comp.debug_incremental) {
3335 try mod.intern_pool.addDependency(3335 try mod.intern_pool.addDependency(
3336 sema.gpa,3336 sema.gpa,
3337 InternPool.AnalSubject.wrap(.{ .decl = new_decl_index }),3337 InternPool.AnalUnit.wrap(.{ .decl = new_decl_index }),
3338 .{ .src_hash = try mod.intern_pool.trackZir(sema.gpa, block.getFileScope(mod), inst) },3338 .{ .src_hash = try mod.intern_pool.trackZir(sema.gpa, block.getFileScope(mod), inst) },
3339 );3339 );
3340 }3340 }
...@@ -3422,7 +3422,7 @@ fn zirOpaqueDecl(...@@ -3422,7 +3422,7 @@ fn zirOpaqueDecl(
3422 if (sema.mod.comp.debug_incremental) {3422 if (sema.mod.comp.debug_incremental) {
3423 try ip.addDependency(3423 try ip.addDependency(
3424 gpa,3424 gpa,
3425 InternPool.AnalSubject.wrap(.{ .decl = new_decl_index }),3425 InternPool.AnalUnit.wrap(.{ .decl = new_decl_index }),
3426 .{ .src_hash = try ip.trackZir(gpa, block.getFileScope(mod), inst) },3426 .{ .src_hash = try ip.trackZir(gpa, block.getFileScope(mod), inst) },
3427 );3427 );
3428 }3428 }
...@@ -38362,7 +38362,7 @@ pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void {...@@ -38362,7 +38362,7 @@ pub fn declareDependency(sema: *Sema, dependee: InternPool.Dependee) !void {
38362 return;38362 return;
38363 }38363 }
3836438364
38365 const depender = InternPool.AnalSubject.wrap(38365 const depender = InternPool.AnalUnit.wrap(
38366 if (sema.owner_func_index != .none)38366 if (sema.owner_func_index != .none)
38367 .{ .func = sema.owner_func_index }38367 .{ .func = sema.owner_func_index }
38368 else38368 else
src/Zcu.zig+35-35
...@@ -139,26 +139,26 @@ global_error_set: GlobalErrorSet = .{},...@@ -139,26 +139,26 @@ global_error_set: GlobalErrorSet = .{},
139/// Maximum amount of distinct error values, set by --error-limit139/// Maximum amount of distinct error values, set by --error-limit
140error_limit: ErrorInt,140error_limit: ErrorInt,
141141
142/// Value is the number of PO or outdated Decls which this AnalSubject depends on.142/// Value is the number of PO or outdated Decls which this AnalUnit depends on.
143potentially_outdated: std.AutoArrayHashMapUnmanaged(InternPool.AnalSubject, u32) = .{},143potentially_outdated: std.AutoArrayHashMapUnmanaged(InternPool.AnalUnit, u32) = .{},
144/// Value is the number of PO or outdated Decls which this AnalSubject depends on.144/// Value is the number of PO or outdated Decls which this AnalUnit depends on.
145/// Once this value drops to 0, the AnalSubject is a candidate for re-analysis.145/// Once this value drops to 0, the AnalUnit is a candidate for re-analysis.
146outdated: std.AutoArrayHashMapUnmanaged(InternPool.AnalSubject, u32) = .{},146outdated: std.AutoArrayHashMapUnmanaged(InternPool.AnalUnit, u32) = .{},
147/// This contains all `AnalSubject`s in `outdated` whose PO dependency count is 0.147/// This contains all `AnalUnit`s in `outdated` whose PO dependency count is 0.
148/// Such `AnalSubject`s are ready for immediate re-analysis.148/// Such `AnalUnit`s are ready for immediate re-analysis.
149/// See `findOutdatedToAnalyze` for details.149/// See `findOutdatedToAnalyze` for details.
150outdated_ready: std.AutoArrayHashMapUnmanaged(InternPool.AnalSubject, void) = .{},150outdated_ready: std.AutoArrayHashMapUnmanaged(InternPool.AnalUnit, void) = .{},
151/// This contains a set of Decls which may not be in `outdated`, but are the151/// This contains a set of Decls which may not be in `outdated`, but are the
152/// root Decls of files which have updated source and thus must be re-analyzed.152/// root Decls of files which have updated source and thus must be re-analyzed.
153/// If such a Decl is only in this set, the struct type index may be preserved153/// If such a Decl is only in this set, the struct type index may be preserved
154/// (only the namespace might change). If such a Decl is also `outdated`, the154/// (only the namespace might change). If such a Decl is also `outdated`, the
155/// struct type index must be recreated.155/// struct type index must be recreated.
156outdated_file_root: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{},156outdated_file_root: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{},
157/// This contains a list of AnalSubject whose analysis or codegen failed, but the157/// This contains a list of AnalUnit whose analysis or codegen failed, but the
158/// failure was something like running out of disk space, and trying again may158/// failure was something like running out of disk space, and trying again may
159/// succeed. On the next update, we will flush this list, marking all members of159/// succeed. On the next update, we will flush this list, marking all members of
160/// it as outdated.160/// it as outdated.
161retryable_failures: std.ArrayListUnmanaged(InternPool.AnalSubject) = .{},161retryable_failures: std.ArrayListUnmanaged(InternPool.AnalUnit) = .{},
162162
163stage1_flags: packed struct {163stage1_flags: packed struct {
164 have_winmain: bool = false,164 have_winmain: bool = false,
...@@ -3137,9 +3137,9 @@ fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void {...@@ -3137,9 +3137,9 @@ fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void {
3137 }3137 }
3138}3138}
31393139
3140/// Given a AnalSubject which is newly outdated or PO, mark all AnalSubjects which may3140/// Given a AnalUnit which is newly outdated or PO, mark all AnalUnits which may
3141/// in turn be PO, due to a dependency on the original AnalSubject's tyval or IES.3141/// in turn be PO, due to a dependency on the original AnalUnit's tyval or IES.
3142fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: InternPool.AnalSubject) !void {3142fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: InternPool.AnalUnit) !void {
3143 var it = zcu.intern_pool.dependencyIterator(switch (maybe_outdated.unwrap()) {3143 var it = zcu.intern_pool.dependencyIterator(switch (maybe_outdated.unwrap()) {
3144 .decl => |decl_index| .{ .decl_val = decl_index }, // TODO: also `decl_ref` deps when introduced3144 .decl => |decl_index| .{ .decl_val = decl_index }, // TODO: also `decl_ref` deps when introduced
3145 .func => |func_index| .{ .func_ies = func_index },3145 .func => |func_index| .{ .func_ies = func_index },
...@@ -3161,12 +3161,12 @@ fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: InternP...@@ -3161,12 +3161,12 @@ fn markTransitiveDependersPotentiallyOutdated(zcu: *Zcu, maybe_outdated: InternP
3161 continue;3161 continue;
3162 }3162 }
3163 try zcu.potentially_outdated.putNoClobber(zcu.gpa, po, 1);3163 try zcu.potentially_outdated.putNoClobber(zcu.gpa, po, 1);
3164 // This AnalSubject was not already PO, so we must recursively mark its dependers as also PO.3164 // This AnalUnit was not already PO, so we must recursively mark its dependers as also PO.
3165 try zcu.markTransitiveDependersPotentiallyOutdated(po);3165 try zcu.markTransitiveDependersPotentiallyOutdated(po);
3166 }3166 }
3167}3167}
31683168
3169pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject {3169pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalUnit {
3170 if (!zcu.comp.debug_incremental) return null;3170 if (!zcu.comp.debug_incremental) return null;
31713171
3172 if (zcu.outdated.count() == 0 and zcu.potentially_outdated.count() == 0) {3172 if (zcu.outdated.count() == 0 and zcu.potentially_outdated.count() == 0) {
...@@ -3174,8 +3174,8 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject...@@ -3174,8 +3174,8 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject
3174 return null;3174 return null;
3175 }3175 }
31763176
3177 // Our goal is to find an outdated AnalSubject which itself has no outdated or3177 // Our goal is to find an outdated AnalUnit which itself has no outdated or
3178 // PO dependencies. Most of the time, such an AnalSubject will exist - we track3178 // PO dependencies. Most of the time, such an AnalUnit will exist - we track
3179 // them in the `outdated_ready` set for efficiency. However, this is not3179 // them in the `outdated_ready` set for efficiency. However, this is not
3180 // necessarily the case, since the Decl dependency graph may contain loops3180 // necessarily the case, since the Decl dependency graph may contain loops
3181 // via mutually recursive definitions:3181 // via mutually recursive definitions:
...@@ -3197,7 +3197,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject...@@ -3197,7 +3197,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject
3197 // `outdated`. This set will be small (number of files changed in this3197 // `outdated`. This set will be small (number of files changed in this
3198 // update), so it's alright for us to just iterate here.3198 // update), so it's alright for us to just iterate here.
3199 for (zcu.outdated_file_root.keys()) |file_decl| {3199 for (zcu.outdated_file_root.keys()) |file_decl| {
3200 const decl_depender = InternPool.AnalSubject.wrap(.{ .decl = file_decl });3200 const decl_depender = InternPool.AnalUnit.wrap(.{ .decl = file_decl });
3201 if (zcu.outdated.contains(decl_depender)) {3201 if (zcu.outdated.contains(decl_depender)) {
3202 // Since we didn't hit this in the first loop, this Decl must have3202 // Since we didn't hit this in the first loop, this Decl must have
3203 // pending dependencies, so is ineligible.3203 // pending dependencies, so is ineligible.
...@@ -3213,7 +3213,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject...@@ -3213,7 +3213,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject
3213 return decl_depender;3213 return decl_depender;
3214 }3214 }
32153215
3216 // There is no single AnalSubject which is ready for re-analysis. Instead, we3216 // There is no single AnalUnit which is ready for re-analysis. Instead, we
3217 // must assume that some Decl with PO dependencies is outdated - e.g. in the3217 // must assume that some Decl with PO dependencies is outdated - e.g. in the
3218 // above example we arbitrarily pick one of A or B. We should select a Decl,3218 // above example we arbitrarily pick one of A or B. We should select a Decl,
3219 // since a Decl is definitely responsible for the loop in the dependency3219 // since a Decl is definitely responsible for the loop in the dependency
...@@ -3221,7 +3221,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject...@@ -3221,7 +3221,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject
32213221
3222 // The choice of this Decl could have a big impact on how much total3222 // The choice of this Decl could have a big impact on how much total
3223 // analysis we perform, since if analysis concludes its tyval is unchanged,3223 // analysis we perform, since if analysis concludes its tyval is unchanged,
3224 // then other PO AnalSubject may be resolved as up-to-date. To hopefully avoid3224 // then other PO AnalUnit may be resolved as up-to-date. To hopefully avoid
3225 // doing too much work, let's find a Decl which the most things depend on -3225 // doing too much work, let's find a Decl which the most things depend on -
3226 // the idea is that this will resolve a lot of loops (but this is only a3226 // the idea is that this will resolve a lot of loops (but this is only a
3227 // heuristic).3227 // heuristic).
...@@ -3271,7 +3271,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject...@@ -3271,7 +3271,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?InternPool.AnalSubject
3271 chosen_decl_dependers,3271 chosen_decl_dependers,
3272 });3272 });
32733273
3274 return InternPool.AnalSubject.wrap(.{ .decl = chosen_decl_idx.? });3274 return InternPool.AnalUnit.wrap(.{ .decl = chosen_decl_idx.? });
3275}3275}
32763276
3277/// During an incremental update, before semantic analysis, call this to flush all values from3277/// During an incremental update, before semantic analysis, call this to flush all values from
...@@ -3281,12 +3281,12 @@ pub fn flushRetryableFailures(zcu: *Zcu) !void {...@@ -3281,12 +3281,12 @@ pub fn flushRetryableFailures(zcu: *Zcu) !void {
3281 for (zcu.retryable_failures.items) |depender| {3281 for (zcu.retryable_failures.items) |depender| {
3282 if (zcu.outdated.contains(depender)) continue;3282 if (zcu.outdated.contains(depender)) continue;
3283 if (zcu.potentially_outdated.fetchSwapRemove(depender)) |kv| {3283 if (zcu.potentially_outdated.fetchSwapRemove(depender)) |kv| {
3284 // This AnalSubject was already PO, but we now consider it outdated.3284 // This AnalUnit was already PO, but we now consider it outdated.
3285 // Any transitive dependencies are already marked PO.3285 // Any transitive dependencies are already marked PO.
3286 try zcu.outdated.put(gpa, depender, kv.value);3286 try zcu.outdated.put(gpa, depender, kv.value);
3287 continue;3287 continue;
3288 }3288 }
3289 // This AnalSubject was not marked PO, but is now outdated. Mark it as3289 // This AnalUnit was not marked PO, but is now outdated. Mark it as
3290 // such, then recursively mark transitive dependencies as PO.3290 // such, then recursively mark transitive dependencies as PO.
3291 try zcu.outdated.put(gpa, depender, 0);3291 try zcu.outdated.put(gpa, depender, 0);
3292 try zcu.markTransitiveDependersPotentiallyOutdated(depender);3292 try zcu.markTransitiveDependersPotentiallyOutdated(depender);
...@@ -3456,7 +3456,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {...@@ -3456,7 +3456,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
3456 // which tries to limit re-analysis to Decls whose previously listed3456 // which tries to limit re-analysis to Decls whose previously listed
3457 // dependencies are all up-to-date.3457 // dependencies are all up-to-date.
34583458
3459 const decl_as_depender = InternPool.AnalSubject.wrap(.{ .decl = decl_index });3459 const decl_as_depender = InternPool.AnalUnit.wrap(.{ .decl = decl_index });
3460 const decl_was_outdated = mod.outdated.swapRemove(decl_as_depender) or3460 const decl_was_outdated = mod.outdated.swapRemove(decl_as_depender) or
3461 mod.potentially_outdated.swapRemove(decl_as_depender);3461 mod.potentially_outdated.swapRemove(decl_as_depender);
34623462
...@@ -3522,7 +3522,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {...@@ -3522,7 +3522,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
3522 else => |e| {3522 else => |e| {
3523 decl.analysis = .sema_failure;3523 decl.analysis = .sema_failure;
3524 try mod.failed_decls.ensureUnusedCapacity(mod.gpa, 1);3524 try mod.failed_decls.ensureUnusedCapacity(mod.gpa, 1);
3525 try mod.retryable_failures.append(mod.gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));3525 try mod.retryable_failures.append(mod.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
3526 mod.failed_decls.putAssumeCapacityNoClobber(decl_index, try ErrorMsg.create(3526 mod.failed_decls.putAssumeCapacityNoClobber(decl_index, try ErrorMsg.create(
3527 mod.gpa,3527 mod.gpa,
3528 decl.navSrcLoc(mod).upgrade(mod),3528 decl.navSrcLoc(mod).upgrade(mod),
...@@ -3581,7 +3581,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In...@@ -3581,7 +3581,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In
3581 // that's the case, we should remove this function from the binary.3581 // that's the case, we should remove this function from the binary.
3582 if (decl.val.ip_index != func_index) {3582 if (decl.val.ip_index != func_index) {
3583 try zcu.markDependeeOutdated(.{ .func_ies = func_index });3583 try zcu.markDependeeOutdated(.{ .func_ies = func_index });
3584 ip.removeDependenciesForDepender(gpa, InternPool.AnalSubject.wrap(.{ .func = func_index }));3584 ip.removeDependenciesForDepender(gpa, InternPool.AnalUnit.wrap(.{ .func = func_index }));
3585 ip.remove(func_index);3585 ip.remove(func_index);
3586 @panic("TODO: remove orphaned function from binary");3586 @panic("TODO: remove orphaned function from binary");
3587 }3587 }
...@@ -3607,7 +3607,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In...@@ -3607,7 +3607,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In
3607 .complete => {},3607 .complete => {},
3608 }3608 }
36093609
3610 const func_as_depender = InternPool.AnalSubject.wrap(.{ .func = func_index });3610 const func_as_depender = InternPool.AnalUnit.wrap(.{ .func = func_index });
3611 const was_outdated = zcu.outdated.swapRemove(func_as_depender) or3611 const was_outdated = zcu.outdated.swapRemove(func_as_depender) or
3612 zcu.potentially_outdated.swapRemove(func_as_depender);3612 zcu.potentially_outdated.swapRemove(func_as_depender);
36133613
...@@ -3728,7 +3728,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In...@@ -3728,7 +3728,7 @@ pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.In
3728 .{@errorName(err)},3728 .{@errorName(err)},
3729 ));3729 ));
3730 func.analysis(ip).state = .codegen_failure;3730 func.analysis(ip).state = .codegen_failure;
3731 try zcu.retryable_failures.append(zcu.gpa, InternPool.AnalSubject.wrap(.{ .func = func_index }));3731 try zcu.retryable_failures.append(zcu.gpa, InternPool.AnalUnit.wrap(.{ .func = func_index }));
3732 },3732 },
3733 };3733 };
3734 } else if (zcu.llvm_object) |llvm_object| {3734 } else if (zcu.llvm_object) |llvm_object| {
...@@ -3773,7 +3773,7 @@ pub fn ensureFuncBodyAnalysisQueued(mod: *Module, func_index: InternPool.Index)...@@ -3773,7 +3773,7 @@ pub fn ensureFuncBodyAnalysisQueued(mod: *Module, func_index: InternPool.Index)
37733773
3774 assert(decl.has_tv);3774 assert(decl.has_tv);
37753775
3776 const func_as_depender = InternPool.AnalSubject.wrap(.{ .func = func_index });3776 const func_as_depender = InternPool.AnalUnit.wrap(.{ .func = func_index });
3777 const is_outdated = mod.outdated.contains(func_as_depender) or3777 const is_outdated = mod.outdated.contains(func_as_depender) or
3778 mod.potentially_outdated.contains(func_as_depender);3778 mod.potentially_outdated.contains(func_as_depender);
37793779
...@@ -3857,7 +3857,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa...@@ -3857,7 +3857,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa
3857 if (zcu.comp.debug_incremental) {3857 if (zcu.comp.debug_incremental) {
3858 try ip.addDependency(3858 try ip.addDependency(
3859 gpa,3859 gpa,
3860 InternPool.AnalSubject.wrap(.{ .decl = decl_index }),3860 InternPool.AnalUnit.wrap(.{ .decl = decl_index }),
3861 .{ .src_hash = tracked_inst },3861 .{ .src_hash = tracked_inst },
3862 );3862 );
3863 }3863 }
...@@ -3906,7 +3906,7 @@ fn semaFileUpdate(zcu: *Zcu, file: *File, type_outdated: bool) SemaError!bool {...@@ -3906,7 +3906,7 @@ fn semaFileUpdate(zcu: *Zcu, file: *File, type_outdated: bool) SemaError!bool {
39063906
3907 if (type_outdated) {3907 if (type_outdated) {
3908 // Invalidate the existing type, reusing the decl and namespace.3908 // Invalidate the existing type, reusing the decl and namespace.
3909 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalSubject.wrap(.{ .decl = file.root_decl.unwrap().? }));3909 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalUnit.wrap(.{ .decl = file.root_decl.unwrap().? }));
3910 zcu.intern_pool.remove(decl.val.toIntern());3910 zcu.intern_pool.remove(decl.val.toIntern());
3911 decl.val = undefined;3911 decl.val = undefined;
3912 _ = try zcu.getFileRootStruct(file.root_decl.unwrap().?, decl.src_namespace, file);3912 _ = try zcu.getFileRootStruct(file.root_decl.unwrap().?, decl.src_namespace, file);
...@@ -4097,7 +4097,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult {...@@ -4097,7 +4097,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !SemaDeclResult {
4097 break :ip_index .none;4097 break :ip_index .none;
4098 };4098 };
40994099
4100 mod.intern_pool.removeDependenciesForDepender(gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));4100 mod.intern_pool.removeDependenciesForDepender(gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
41014101
4102 decl.analysis = .in_progress;4102 decl.analysis = .in_progress;
41034103
...@@ -4323,7 +4323,7 @@ fn semaAnonOwnerDecl(zcu: *Zcu, decl_index: Decl.Index) !SemaDeclResult {...@@ -4323,7 +4323,7 @@ fn semaAnonOwnerDecl(zcu: *Zcu, decl_index: Decl.Index) !SemaDeclResult {
4323 // with a new Decl.4323 // with a new Decl.
4324 //4324 //
4325 // Yes, this does mean that any type owner Decl has a constant value for its entire lifetime.4325 // Yes, this does mean that any type owner Decl has a constant value for its entire lifetime.
4326 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));4326 zcu.intern_pool.removeDependenciesForDepender(zcu.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
4327 zcu.intern_pool.remove(decl.val.toIntern());4327 zcu.intern_pool.remove(decl.val.toIntern());
4328 decl.analysis = .dependency_failure;4328 decl.analysis = .dependency_failure;
4329 return .{4329 return .{
...@@ -5026,7 +5026,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato...@@ -5026,7 +5026,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato
5026 const decl_prog_node = mod.sema_prog_node.start((try decl.fullyQualifiedName(mod)).toSlice(ip), 0);5026 const decl_prog_node = mod.sema_prog_node.start((try decl.fullyQualifiedName(mod)).toSlice(ip), 0);
5027 defer decl_prog_node.end();5027 defer decl_prog_node.end();
50285028
5029 mod.intern_pool.removeDependenciesForDepender(gpa, InternPool.AnalSubject.wrap(.{ .func = func_index }));5029 mod.intern_pool.removeDependenciesForDepender(gpa, InternPool.AnalUnit.wrap(.{ .func = func_index }));
50305030
5031 var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa);5031 var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa);
5032 defer comptime_err_ret_trace.deinit();5032 defer comptime_err_ret_trace.deinit();
...@@ -5627,7 +5627,7 @@ pub fn linkerUpdateDecl(zcu: *Zcu, decl_index: Decl.Index) !void {...@@ -5627,7 +5627,7 @@ pub fn linkerUpdateDecl(zcu: *Zcu, decl_index: Decl.Index) !void {
5627 .{@errorName(err)},5627 .{@errorName(err)},
5628 ));5628 ));
5629 decl.analysis = .codegen_failure;5629 decl.analysis = .codegen_failure;
5630 try zcu.retryable_failures.append(zcu.gpa, InternPool.AnalSubject.wrap(.{ .decl = decl_index }));5630 try zcu.retryable_failures.append(zcu.gpa, InternPool.AnalUnit.wrap(.{ .decl = decl_index }));
5631 },5631 },
5632 };5632 };
5633 } else if (zcu.llvm_object) |llvm_object| {5633 } else if (zcu.llvm_object) |llvm_object| {