zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 9b3a70c8aab74b804cac0d7c15e4e7518a88c868 (tree)
parent 0c598100d8dbcf94fa8916a8aa5dcf5f55ef6d46
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon,  3 Aug 2020 22:22:47 -0700

stage2: move link.File.ELF.SrcFn field from Module.Fn to Module.Decl

SrcFn represents the function in the linked output file, if the
`Decl` is a function. This is stored here and not in `Fn` because `Decl`
survives across updates but `Fn` does not.

TODO Look into making `Fn` a longer lived structure and moving this field there
to save on memory usage.

Diffstat:
Msrc-self-hosted/Module.zig | 10+++++++---
Msrc-self-hosted/link.zig | 2+-
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src-self-hosted/Module.zig b/src-self-hosted/Module.zig @@ -176,6 +176,13 @@ pub const Decl = struct { /// This is populated regardless of semantic analysis and code generation. link: link.File.Elf.TextBlock = link.File.Elf.TextBlock.empty, + /// Represents the function in the linked output file, if the `Decl` is a function. + /// This is stored here and not in `Fn` because `Decl` survives across updates but + /// `Fn` does not. + /// TODO Look into making `Fn` a longer lived structure and moving this field there + /// to save on memory usage. + fn_link: link.File.Elf.SrcFn = link.File.Elf.SrcFn.empty, + contents_hash: std.zig.SrcHash, /// The shallow set of other decls whose typed_value could possibly change if this Decl's @@ -280,9 +287,6 @@ pub const Fn = struct { }, owner_decl: *Decl, - /// Represents the function in the linked output file. - link: link.File.Elf.SrcFn = link.File.Elf.SrcFn.empty, - /// This memory is temporary and points to stack memory for the duration /// of Fn analysis. pub const Analysis = struct { diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig @@ -1922,7 +1922,7 @@ pub const File = struct { // Now we have the full contents and may allocate a region to store it. const debug_line_sect = &self.sections.items[self.debug_line_section_index.?]; - const src_fn = &typed_value.val.cast(Value.Payload.Function).?.func.link; + const src_fn = &decl.fn_link; if (self.dbg_line_fn_last) |last| { if (src_fn.prev == null and src_fn.next == null) { // Append new function.