diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-05 23:46:46 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 15:11:35 -0800 |
| commit | e521879e4730fd85a92081c0040db7dc5daad8a3 (patch) | |
| tree | be07a1a575ad2728027846e0b8cce0f50b807cf0 /src/codegen | |
| parent | b9355edfb1db042098bc232cf8e52e079f4fcf4e (diff) | |
| download | zig-e521879e4730fd85a92081c0040db7dc5daad8a3.tar.gz zig-e521879e4730fd85a92081c0040db7dc5daad8a3.zip | |
rewrite wasm/Emit.zig
mainly, rework how relocations works. This is the point at which symbol
indexes are known - not before. And don't emit unnecessary relocations!
They're only needed when emitting an object file.
Changes wasm linker to keep MIR around long-lived so that fixups can be
reapplied after linker garbage collection.
use labeled switch while we're at it
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 977eeab9da..c23cc4354c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1838,11 +1838,11 @@ pub const Object = struct { o: *Object, zcu: *Zcu, exported_value: InternPool.Index, - export_indices: []const u32, + export_indices: []const Zcu.Export.Index, ) link.File.UpdateExportsError!void { const gpa = zcu.gpa; const ip = &zcu.intern_pool; - const main_exp_name = try o.builder.strtabString(zcu.all_exports.items[export_indices[0]].opts.name.toSlice(ip)); + const main_exp_name = try o.builder.strtabString(export_indices[0].ptr(zcu).opts.name.toSlice(ip)); const global_index = i: { const gop = try o.uav_map.getOrPut(gpa, exported_value); if (gop.found_existing) { @@ -1873,11 +1873,11 @@ pub const Object = struct { o: *Object, zcu: *Zcu, global_index: Builder.Global.Index, - export_indices: []const u32, + export_indices: []const Zcu.Export.Index, ) link.File.UpdateExportsError!void { const comp = zcu.comp; const ip = &zcu.intern_pool; - const first_export = zcu.all_exports.items[export_indices[0]]; + const first_export = export_indices[0].ptr(zcu); // We will rename this global to have a name matching `first_export`. // Successive exports become aliases. @@ -1934,7 +1934,7 @@ pub const Object = struct { // Until then we iterate over existing aliases and make them point // to the correct decl, or otherwise add a new alias. Old aliases are leaked. for (export_indices[1..]) |export_idx| { - const exp = zcu.all_exports.items[export_idx]; + const exp = export_idx.ptr(zcu); const exp_name = try o.builder.strtabString(exp.opts.name.toSlice(ip)); if (o.builder.getGlobal(exp_name)) |global| { switch (global.ptrConst(&o.builder).kind) { |
