diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-06-29 01:36:25 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-07-04 21:01:41 +0100 |
| commit | 7e552dc1e9a8388f71cc32083deb9dd848e79808 (patch) | |
| tree | b1c1086002c91be0e6c1195cc18966906a171ce3 /src/link.zig | |
| parent | bc8cd135987c7dc7419d034ba31178331d606cfa (diff) | |
| download | zig-7e552dc1e9a8388f71cc32083deb9dd848e79808.tar.gz zig-7e552dc1e9a8388f71cc32083deb9dd848e79808.zip | |
Zcu: rework exports
This commit reworks our representation of exported Decls and values in
Zcu to be memory-optimized and trivially serialized.
All exports are now stored in the `all_exports` array on `Zcu`. An
`AnalUnit` which performs an export (either through an `export`
annotation or by containing an analyzed `@export`) gains an entry into
`single_exports` if it performs only one export, or `multi_exports` if
it performs multiple.
We no longer store a persistent mapping from a `Decl`/value to all
exports of that entity; this state is not necessary for the majority of
the pipeline. Instead, we construct it in `Zcu.processExports`, just
before flush. This does not affect the algorithmic complexity of
`processExports`, since this function already iterates all exports in
the `Zcu`.
The elimination of `decl_exports` and `value_exports` led to a few
non-trivial backend changes. The LLVM backend has been wrangled into a
more reasonable state in general regarding exports and externs. The C
backend is currently disabled in this commit, because its support for
`export` was quite broken, and that was exposed by this work -- I'm
hoping @jacobly0 will be able to pick this up!
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/link.zig b/src/link.zig index 75a9723f1c..36a5cb8187 100644 --- a/src/link.zig +++ b/src/link.zig @@ -606,12 +606,12 @@ pub const File = struct { base: *File, module: *Module, exported: Module.Exported, - exports: []const *Module.Export, + export_indices: []const u32, ) UpdateExportsError!void { switch (base.tag) { inline else => |tag| { if (tag != .c and build_options.only_c) unreachable; - return @as(*tag.Type(), @fieldParentPtr("base", base)).updateExports(module, exported, exports); + return @as(*tag.Type(), @fieldParentPtr("base", base)).updateExports(module, exported, export_indices); }, } } @@ -671,11 +671,11 @@ pub const File = struct { } } - pub fn deleteDeclExport( + pub fn deleteExport( base: *File, - decl_index: InternPool.DeclIndex, + exported: Zcu.Exported, name: InternPool.NullTerminatedString, - ) !void { + ) void { if (build_options.only_c) @compileError("unreachable"); switch (base.tag) { .plan9, @@ -685,7 +685,7 @@ pub const File = struct { => {}, inline else => |tag| { - return @as(*tag.Type(), @fieldParentPtr("base", base)).deleteDeclExport(decl_index, name); + return @as(*tag.Type(), @fieldParentPtr("base", base)).deleteExport(exported, name); }, } } |
