diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-08-24 20:43:43 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-09-21 14:48:40 -0700 |
| commit | accd5701c251c2741479fe08e56c8271c444f021 (patch) | |
| tree | 78871f150609687a9210063e90f8f4eb53997c38 /src/link/Elf/Object.zig | |
| parent | 0345d7866347c9066b0646f9e46be9a068dcfaa3 (diff) | |
| download | zig-accd5701c251c2741479fe08e56c8271c444f021.tar.gz zig-accd5701c251c2741479fe08e56c8271c444f021.zip | |
compiler: move struct types into InternPool proper
Structs were previously using `SegmentedList` to be given indexes, but
were not actually backed by the InternPool arrays.
After this, the only remaining uses of `SegmentedList` in the compiler
are `Module.Decl` and `Module.Namespace`. Once those last two are
migrated to become backed by InternPool arrays as well, we can introduce
state serialization via writing these arrays to disk all at once.
Unfortunately there are a lot of source code locations that touch the
struct type API, so this commit is still work-in-progress. Once I get it
compiling and passing the test suite, I can provide some interesting
data points such as how it affected the InternPool memory size and
performance comparison against master branch.
I also couldn't resist migrating over a bunch of alignment API over to
use the log2 Alignment type rather than a mismash of u32 and u64 byte
units with 0 meaning something implicitly different and special at every
location. Turns out you can do all the math you need directly on the
log2 representation of alignments.
Diffstat (limited to 'src/link/Elf/Object.zig')
| -rw-r--r-- | src/link/Elf/Object.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig index 32c96b8d95..36fb531fa9 100644 --- a/src/link/Elf/Object.zig +++ b/src/link/Elf/Object.zig @@ -181,10 +181,10 @@ fn addAtom(self: *Object, shdr: elf.Elf64_Shdr, shndx: u16, name: [:0]const u8, const data = try self.shdrContents(shndx); const chdr = @as(*align(1) const elf.Elf64_Chdr, @ptrCast(data.ptr)).*; atom.size = chdr.ch_size; - atom.alignment = math.log2_int(u64, chdr.ch_addralign); + atom.alignment = Alignment.fromNonzeroByteUnits(chdr.ch_addralign); } else { atom.size = shdr.sh_size; - atom.alignment = math.log2_int(u64, shdr.sh_addralign); + atom.alignment = Alignment.fromNonzeroByteUnits(shdr.sh_addralign); } } @@ -571,7 +571,7 @@ pub fn convertCommonSymbols(self: *Object, elf_file: *Elf) !void { atom.file = self.index; atom.size = this_sym.st_size; const alignment = this_sym.st_value; - atom.alignment = math.log2_int(u64, alignment); + atom.alignment = Alignment.fromNonzeroByteUnits(alignment); var sh_flags: u32 = elf.SHF_ALLOC | elf.SHF_WRITE; if (is_tls) sh_flags |= elf.SHF_TLS; @@ -870,3 +870,4 @@ const Fde = eh_frame.Fde; const File = @import("file.zig").File; const StringTable = @import("../strtab.zig").StringTable; const Symbol = @import("Symbol.zig"); +const Alignment = Atom.Alignment; |
