diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-05 18:34:05 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:42:28 -0700 |
| commit | 3e6dd0da7a9aae1e6e3d3e0d897a2b3a28bfc043 (patch) | |
| tree | 553b6f64983871e8483228d008aa540498c334c5 /src/Module.zig | |
| parent | ce3cffbd5a00a6ae44ec3f2c6550de1c52c293c4 (diff) | |
| download | zig-3e6dd0da7a9aae1e6e3d3e0d897a2b3a28bfc043.tar.gz zig-3e6dd0da7a9aae1e6e3d3e0d897a2b3a28bfc043.zip | |
stage2: add tmp_hack_arena for the InternPool transition
Temporarily used for some unfortunate allocations made by backends that
need to construct pointer types that can't be represented by the
InternPool. Once all types are migrated to be stored in the InternPool,
this can be removed.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index bfc06ac5ab..e9658ad89f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -98,6 +98,10 @@ string_literal_bytes: ArrayListUnmanaged(u8) = .{}, /// Stores all Type and Value objects; periodically garbage collected. intern_pool: InternPool = .{}, +/// Temporarily used for some unfortunate allocations made by backends that need to construct +/// pointer types that can't be represented by the InternPool. Once all types are migrated +/// to be stored in the InternPool, this can be removed. +tmp_hack_arena: std.heap.ArenaAllocator, /// The set of all the generic function instantiations. This is used so that when a generic /// function is called twice with the same comptime parameter arguments, both calls dispatch @@ -3552,6 +3556,7 @@ pub fn deinit(mod: *Module) void { mod.string_literal_bytes.deinit(gpa); mod.intern_pool.deinit(gpa); + mod.tmp_hack_arena.deinit(); } pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { @@ -6848,10 +6853,25 @@ pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type } pub fn singleMutPtrType(mod: *Module, child_type: Type) Allocator.Error!Type { + if (child_type.ip_index == .none) { + // TODO remove this after all types can be represented via the InternPool + return Type.Tag.pointer.create(mod.tmp_hack_arena.allocator(), .{ + .pointee_type = child_type, + .@"addrspace" = .generic, + }); + } return ptrType(mod, .{ .elem_type = child_type.ip_index }); } pub fn singleConstPtrType(mod: *Module, child_type: Type) Allocator.Error!Type { + if (child_type.ip_index == .none) { + // TODO remove this after all types can be represented via the InternPool + return Type.Tag.pointer.create(mod.tmp_hack_arena.allocator(), .{ + .pointee_type = child_type, + .mutable = false, + .@"addrspace" = .generic, + }); + } return ptrType(mod, .{ .elem_type = child_type.ip_index, .is_const = true }); } |
