| ... | @@ -45,8 +45,6 @@ const Builtin = @import("Builtin.zig"); | ... | @@ -45,8 +45,6 @@ const Builtin = @import("Builtin.zig"); |
| 45 | const LlvmObject = @import("codegen/llvm.zig").Object; | 45 | const LlvmObject = @import("codegen/llvm.zig").Object; |
| 46 | const dev = @import("dev.zig"); | 46 | const dev = @import("dev.zig"); |
| 47 | | 47 | |
| 48 | const DeprecatedLinearFifo = @import("deprecated.zig").LinearFifo; | | |
| 49 | | | |
| 50 | pub const Config = @import("Compilation/Config.zig"); | 48 | pub const Config = @import("Compilation/Config.zig"); |
| 51 | | 49 | |
| 52 | /// General-purpose allocator. Used for both temporary and long-term storage. | 50 | /// General-purpose allocator. Used for both temporary and long-term storage. |
| ... | @@ -124,20 +122,21 @@ work_queues: [ | ... | @@ -124,20 +122,21 @@ work_queues: [ |
| 124 | } | 122 | } |
| 125 | break :len len; | 123 | break :len len; |
| 126 | } | 124 | } |
| 127 | ]DeprecatedLinearFifo(Job), | 125 | ]std.Deque(Job), |
| 128 | | 126 | |
| 129 | /// These jobs are to invoke the Clang compiler to create an object file, which | 127 | /// These jobs are to invoke the Clang compiler to create an object file, which |
| 130 | /// gets linked with the Compilation. | 128 | /// gets linked with the Compilation. |
| 131 | c_object_work_queue: DeprecatedLinearFifo(*CObject), | 129 | c_object_work_queue: std.Deque(*CObject), |
| 132 | | 130 | |
| 133 | /// These jobs are to invoke the RC compiler to create a compiled resource file (.res), which | 131 | /// These jobs are to invoke the RC compiler to create a compiled resource file (.res), which |
| 134 | /// gets linked with the Compilation. | 132 | /// gets linked with the Compilation. |
| 135 | win32_resource_work_queue: if (dev.env.supports(.win32_resource)) DeprecatedLinearFifo(*Win32Resource) else struct { | 133 | win32_resource_work_queue: if (dev.env.supports(.win32_resource)) std.Deque(*Win32Resource) else struct { |
| 136 | pub fn ensureUnusedCapacity(_: @This(), _: u0) error{}!void {} | 134 | pub const empty: @This() = .{}; |
| 137 | pub fn readItem(_: @This()) ?noreturn { | 135 | pub fn ensureUnusedCapacity(_: @This(), _: Allocator, _: u0) error{}!void {} |
| | 136 | pub fn popFront(_: @This()) ?noreturn { |
| 138 | return null; | 137 | return null; |
| 139 | } | 138 | } |
| 140 | pub fn deinit(_: @This()) void {} | 139 | pub fn deinit(_: @This(), _: Allocator) void {} |
| 141 | }, | 140 | }, |
| 142 | | 141 | |
| 143 | /// The ErrorMsg memory is owned by the `CObject`, using Compilation's general purpose allocator. | 142 | /// The ErrorMsg memory is owned by the `CObject`, using Compilation's general purpose allocator. |
| ... | @@ -2231,9 +2230,9 @@ pub fn create(gpa: Allocator, arena: Allocator, diag: *CreateDiagnostic, options | ... | @@ -2231,9 +2230,9 @@ pub fn create(gpa: Allocator, arena: Allocator, diag: *CreateDiagnostic, options |
| 2231 | .root_mod = options.root_mod, | 2230 | .root_mod = options.root_mod, |
| 2232 | .config = options.config, | 2231 | .config = options.config, |
| 2233 | .dirs = options.dirs, | 2232 | .dirs = options.dirs, |
| 2234 | .work_queues = @splat(.init(gpa)), | 2233 | .work_queues = @splat(.empty), |
| 2235 | .c_object_work_queue = .init(gpa), | 2234 | .c_object_work_queue = .empty, |
| 2236 | .win32_resource_work_queue = if (dev.env.supports(.win32_resource)) .init(gpa) else .{}, | 2235 | .win32_resource_work_queue = .empty, |
| 2237 | .c_source_files = options.c_source_files, | 2236 | .c_source_files = options.c_source_files, |
| 2238 | .rc_source_files = options.rc_source_files, | 2237 | .rc_source_files = options.rc_source_files, |
| 2239 | .cache_parent = cache, | 2238 | .cache_parent = cache, |
| ... | @@ -2699,9 +2698,9 @@ pub fn destroy(comp: *Compilation) void { | ... | @@ -2699,9 +2698,9 @@ pub fn destroy(comp: *Compilation) void { |
| 2699 | if (comp.zcu) |zcu| zcu.deinit(); | 2698 | if (comp.zcu) |zcu| zcu.deinit(); |
| 2700 | comp.cache_use.deinit(); | 2699 | comp.cache_use.deinit(); |
| 2701 | | 2700 | |
| 2702 | for (&comp.work_queues) |*work_queue| work_queue.deinit(); | 2701 | for (&comp.work_queues) |*work_queue| work_queue.deinit(gpa); |
| 2703 | comp.c_object_work_queue.deinit(); | 2702 | comp.c_object_work_queue.deinit(gpa); |
| 2704 | comp.win32_resource_work_queue.deinit(); | 2703 | comp.win32_resource_work_queue.deinit(gpa); |
| 2705 | | 2704 | |
| 2706 | for (comp.windows_libs.keys()) |windows_lib| gpa.free(windows_lib); | 2705 | for (comp.windows_libs.keys()) |windows_lib| gpa.free(windows_lib); |
| 2707 | comp.windows_libs.deinit(gpa); | 2706 | comp.windows_libs.deinit(gpa); |
| ... | @@ -3016,17 +3015,17 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE | ... | @@ -3016,17 +3015,17 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3016 | | 3015 | |
| 3017 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. | 3016 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. |
| 3018 | // Add a Job for each C object. | 3017 | // Add a Job for each C object. |
| 3019 | try comp.c_object_work_queue.ensureUnusedCapacity(comp.c_object_table.count()); | 3018 | try comp.c_object_work_queue.ensureUnusedCapacity(gpa, comp.c_object_table.count()); |
| 3020 | for (comp.c_object_table.keys()) |c_object| { | 3019 | for (comp.c_object_table.keys()) |c_object| { |
| 3021 | comp.c_object_work_queue.writeItemAssumeCapacity(c_object); | 3020 | comp.c_object_work_queue.pushBackAssumeCapacity(c_object); |
| 3022 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{c_object.src.src_path})); | 3021 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{c_object.src.src_path})); |
| 3023 | } | 3022 | } |
| 3024 | | 3023 | |
| 3025 | // For compiling Win32 resources, we rely on the cache hash system to avoid duplicating work. | 3024 | // For compiling Win32 resources, we rely on the cache hash system to avoid duplicating work. |
| 3026 | // Add a Job for each Win32 resource file. | 3025 | // Add a Job for each Win32 resource file. |
| 3027 | try comp.win32_resource_work_queue.ensureUnusedCapacity(comp.win32_resource_table.count()); | 3026 | try comp.win32_resource_work_queue.ensureUnusedCapacity(gpa, comp.win32_resource_table.count()); |
| 3028 | for (comp.win32_resource_table.keys()) |win32_resource| { | 3027 | for (comp.win32_resource_table.keys()) |win32_resource| { |
| 3029 | comp.win32_resource_work_queue.writeItemAssumeCapacity(win32_resource); | 3028 | comp.win32_resource_work_queue.pushBackAssumeCapacity(win32_resource); |
| 3030 | switch (win32_resource.src) { | 3029 | switch (win32_resource.src) { |
| 3031 | .rc => |f| { | 3030 | .rc => |f| { |
| 3032 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{f.src_path})); | 3031 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{f.src_path})); |
| ... | @@ -4869,14 +4868,14 @@ fn performAllTheWork( | ... | @@ -4869,14 +4868,14 @@ fn performAllTheWork( |
| 4869 | } | 4868 | } |
| 4870 | } | 4869 | } |
| 4871 | | 4870 | |
| 4872 | while (comp.c_object_work_queue.readItem()) |c_object| { | 4871 | while (comp.c_object_work_queue.popFront()) |c_object| { |
| 4873 | comp.link_task_queue.startPrelinkItem(); | 4872 | comp.link_task_queue.startPrelinkItem(); |
| 4874 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateCObject, .{ | 4873 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateCObject, .{ |
| 4875 | comp, c_object, main_progress_node, | 4874 | comp, c_object, main_progress_node, |
| 4876 | }); | 4875 | }); |
| 4877 | } | 4876 | } |
| 4878 | | 4877 | |
| 4879 | while (comp.win32_resource_work_queue.readItem()) |win32_resource| { | 4878 | while (comp.win32_resource_work_queue.popFront()) |win32_resource| { |
| 4880 | comp.link_task_queue.startPrelinkItem(); | 4879 | comp.link_task_queue.startPrelinkItem(); |
| 4881 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateWin32Resource, .{ | 4880 | comp.thread_pool.spawnWg(&comp.link_task_wait_group, workerUpdateWin32Resource, .{ |
| 4882 | comp, win32_resource, main_progress_node, | 4881 | comp, win32_resource, main_progress_node, |
| ... | @@ -4996,7 +4995,7 @@ fn performAllTheWork( | ... | @@ -4996,7 +4995,7 @@ fn performAllTheWork( |
| 4996 | } | 4995 | } |
| 4997 | | 4996 | |
| 4998 | work: while (true) { | 4997 | work: while (true) { |
| 4999 | for (&comp.work_queues) |*work_queue| if (work_queue.readItem()) |job| { | 4998 | for (&comp.work_queues) |*work_queue| if (work_queue.popFront()) |job| { |
| 5000 | try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job); | 4999 | try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job); |
| 5001 | continue :work; | 5000 | continue :work; |
| 5002 | }; | 5001 | }; |
| ... | @@ -5025,7 +5024,7 @@ fn performAllTheWork( | ... | @@ -5025,7 +5024,7 @@ fn performAllTheWork( |
| 5025 | const JobError = Allocator.Error; | 5024 | const JobError = Allocator.Error; |
| 5026 | | 5025 | |
| 5027 | pub fn queueJob(comp: *Compilation, job: Job) !void { | 5026 | pub fn queueJob(comp: *Compilation, job: Job) !void { |
| 5028 | try comp.work_queues[Job.stage(job)].writeItem(job); | 5027 | try comp.work_queues[Job.stage(job)].pushBack(comp.gpa, job); |
| 5029 | } | 5028 | } |
| 5030 | | 5029 | |
| 5031 | pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void { | 5030 | pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void { |