diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-09-24 19:22:25 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-03 12:12:50 -0700 |
| commit | c0b55125443cab63945205b2f7c66bf12cae71e1 (patch) | |
| tree | c47592afbee6b860b6a611e594ab8e7ed732e621 /src/Module.zig | |
| parent | 4df7f7c86a0a105b5d3764121f259a39487a6c8a (diff) | |
| download | zig-c0b55125443cab63945205b2f7c66bf12cae71e1.tar.gz zig-c0b55125443cab63945205b2f7c66bf12cae71e1.zip | |
compiler: start handling anonymous decls differently
Instead of explicitly creating a `Module.Decl` object for each anonymous
declaration, each `InternPool.Index` value is implicitly understood to
be an anonymous declaration when encountered by backend codegen.
The memory management strategy for these anonymous decls then becomes to
garbage collect them along with standard InternPool garbage.
In the interest of a smooth transition, this commit only implements this
new scheme for string literals and leaves all the previous mechanisms in
place.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/Module.zig b/src/Module.zig index c4c2b634f7..8c4035cc9a 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -109,9 +109,6 @@ comptime_capture_scopes: std.AutoArrayHashMapUnmanaged(CaptureScope.Key, InternP /// This memory lives until the Module is destroyed. tmp_hack_arena: std.heap.ArenaAllocator, -/// This is currently only used for string literals. -memoized_decls: std.AutoHashMapUnmanaged(InternPool.Index, Decl.Index) = .{}, - /// We optimize memory usage for a compilation with no compile errors by storing the /// error messages and mapping outside of `Decl`. /// The ErrorMsg memory is owned by the decl, using Module's general purpose allocator. @@ -2627,7 +2624,6 @@ pub fn deinit(mod: *Module) void { mod.global_assembly.deinit(gpa); mod.reference_table.deinit(gpa); - mod.memoized_decls.deinit(gpa); mod.intern_pool.deinit(gpa); mod.tmp_hack_arena.deinit(); @@ -5814,6 +5810,7 @@ pub fn markReferencedDeclsAlive(mod: *Module, val: Value) Allocator.Error!void { .ptr => |ptr| { switch (ptr.addr) { .decl => |decl| try mod.markDeclIndexAlive(decl), + .anon_decl => {}, .mut_decl => |mut_decl| try mod.markDeclIndexAlive(mut_decl.decl), .int, .comptime_field => {}, .eu_payload, .opt_payload => |parent| try mod.markReferencedDeclsAlive(parent.toValue()), |
