diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-05 12:53:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-05 12:53:23 -0400 |
| commit | 59905a62f9da9946a797cc35a2523c9929663600 (patch) | |
| tree | 93ca52f59d1803fca320819fc5a7058fbb58e61b /src/Module.zig | |
| parent | 49a7ceb5bcd87d8aeb7b25f8b2972ad4ec0b9e24 (diff) | |
| parent | 44252f4d352d53afd86d678c0b0a40b3f681c7eb (diff) | |
| download | zig-59905a62f9da9946a797cc35a2523c9929663600.tar.gz zig-59905a62f9da9946a797cc35a2523c9929663600.zip | |
Merge pull request #11583 from ziglang/stage2-test-behavior
stage2 behavior tests for all targets passing with the LLVM backend
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 55ec1fdd2c..864663ada2 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -151,6 +151,8 @@ allocated_decls: std.SegmentedList(Decl, 0) = .{}, /// When a Decl object is freed from `allocated_decls`, it is pushed into this stack. decls_free_list: std.ArrayListUnmanaged(Decl.Index) = .{}, +global_assembly: std.AutoHashMapUnmanaged(Decl.Index, []u8) = .{}, + const MonomorphedFuncsSet = std.HashMapUnmanaged( *Fn, void, @@ -2831,6 +2833,7 @@ pub fn deinit(mod: *Module) void { mod.decls_free_list.deinit(gpa); mod.allocated_decls.deinit(gpa); + mod.global_assembly.deinit(gpa); } pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { @@ -2842,6 +2845,9 @@ pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { if (decl.deletion_flag) { assert(mod.deletion_set.swapRemove(decl_index)); } + if (mod.global_assembly.fetchRemove(decl_index)) |kv| { + gpa.free(kv.value); + } if (decl.has_tv) { if (decl.getInnerNamespace()) |namespace| { namespace.destroyDecls(mod); @@ -5714,3 +5720,12 @@ pub fn markDeclAlive(mod: *Module, decl: *Decl) void { fn markDeclIndexAlive(mod: *Module, decl_index: Decl.Index) void { return mod.markDeclAlive(mod.declPtr(decl_index)); } + +pub fn addGlobalAssembly(mod: *Module, decl_index: Decl.Index, source: []const u8) !void { + try mod.global_assembly.ensureUnusedCapacity(mod.gpa, 1); + + const duped_source = try mod.gpa.dupe(u8, source); + errdefer mod.gpa.free(duped_source); + + mod.global_assembly.putAssumeCapacityNoClobber(decl_index, duped_source); +} |
