authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 22:22:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 22:22:47-07:00
log9b3a70c8aab74b804cac0d7c15e4e7518a88c868
tree34e835a80ed4d835356fb1402c049d9ad65c0699
parent0c598100d8dbcf94fa8916a8aa5dcf5f55ef6d46

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.

2 files changed, 8 insertions(+), 4 deletions(-)

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