| ... | ... | @@ -197,11 +197,11 @@ managed_blocks: std.ArrayListUnmanaged(*TextBlock) = .{}, |
| 197 | 197 | |
| 198 | 198 | blocks: std.AutoHashMapUnmanaged(MatchingSection, *TextBlock) = .{}, |
| 199 | 199 | |
| 200 | | /// List of Decls that are currently alive. |
| 200 | /// Table of Decls that are currently alive. |
| 201 | 201 | /// We store them here so that we can properly dispose of any allocated |
| 202 | 202 | /// memory within the TextBlock in the incremental linker. |
| 203 | 203 | /// TODO consolidate this. |
| 204 | | decls: std.ArrayListUnmanaged(*Module.Decl) = .{}, |
| 204 | decls: std.AutoArrayHashMapUnmanaged(*Module.Decl, void) = .{}, |
| 205 | 205 | |
| 206 | 206 | /// Currently active Module.Decl. |
| 207 | 207 | /// TODO this might not be necessary if we figure out how to pass Module.Decl instance |
| ... | ... | @@ -3323,7 +3323,7 @@ pub fn deinit(self: *MachO) void { |
| 3323 | 3323 | self.blocks.deinit(self.base.allocator); |
| 3324 | 3324 | self.text_block_free_list.deinit(self.base.allocator); |
| 3325 | 3325 | |
| 3326 | | for (self.decls.items) |decl| { |
| 3326 | for (self.decls.keys()) |decl| { |
| 3327 | 3327 | decl.link.macho.deinit(self.base.allocator); |
| 3328 | 3328 | } |
| 3329 | 3329 | self.decls.deinit(self.base.allocator); |
| ... | ... | @@ -3427,9 +3427,8 @@ pub fn allocateDeclIndexes(self: *MachO, decl: *Module.Decl) !void { |
| 3427 | 3427 | |
| 3428 | 3428 | try self.locals.ensureUnusedCapacity(self.base.allocator, 1); |
| 3429 | 3429 | try self.got_entries.ensureUnusedCapacity(self.base.allocator, 1); |
| 3430 | | try self.decls.ensureUnusedCapacity(self.base.allocator, 1); |
| 3431 | 3430 | |
| 3432 | | self.decls.appendAssumeCapacity(decl); |
| 3431 | try self.decls.putNoClobber(self.base.allocator, decl, {}); |
| 3433 | 3432 | |
| 3434 | 3433 | if (self.locals_free_list.popOrNull()) |i| { |
| 3435 | 3434 | log.debug("reusing symbol index {d} for {s}", .{ i, decl.name }); |
| ... | ... | @@ -3598,6 +3597,9 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 3598 | 3597 | |
| 3599 | 3598 | // Resolve relocations |
| 3600 | 3599 | try decl.link.macho.resolveRelocs(self); |
| 3600 | // TODO this requires further investigation: should we dispose of resolved relocs, or keep them |
| 3601 | // so that we can reapply them when moving/growing sections? |
| 3602 | decl.link.macho.relocs.clearRetainingCapacity(); |
| 3601 | 3603 | |
| 3602 | 3604 | // Apply pending updates |
| 3603 | 3605 | while (self.pending_updates.popOrNull()) |update| { |
| ... | ... | @@ -3746,6 +3748,7 @@ pub fn deleteExport(self: *MachO, exp: Export) void { |
| 3746 | 3748 | |
| 3747 | 3749 | pub fn freeDecl(self: *MachO, decl: *Module.Decl) void { |
| 3748 | 3750 | log.debug("freeDecl {*}", .{decl}); |
| 3751 | _ = self.decls.swapRemove(decl); |
| 3749 | 3752 | // Appending to free lists is allowed to fail because the free lists are heuristics based anyway. |
| 3750 | 3753 | self.freeTextBlock(&decl.link.macho); |
| 3751 | 3754 | if (decl.link.macho.local_sym_index != 0) { |