aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2024-08-19 07:52:16 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2024-08-20 08:09:33 -0400
commit78dec0a3da4bdf617841062d42c172acb1a5dcbb (patch)
tree72022eddbda83732c6266e68cf743aef669cadae /src/Compilation.zig
parent0a70455095a19a4c18497e6786ca6139c1cc2892 (diff)
downloadzig-78dec0a3da4bdf617841062d42c172acb1a5dcbb.tar.gz
zig-78dec0a3da4bdf617841062d42c172acb1a5dcbb.zip
Compilation: fix crash saving incremental state
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 48387e4501..dc7d0ba925 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2997,14 +2997,26 @@ pub fn saveState(comp: *Compilation) !void {
addBuf(&bufs, mem.sliceAsBytes(ip.free_dep_entries.items));
for (ip.locals, pt_headers.items) |*local, pt_header| {
- addBuf(&bufs, mem.sliceAsBytes(local.shared.limbs.view().items(.@"0")[0..pt_header.intern_pool.limbs_len]));
- addBuf(&bufs, mem.sliceAsBytes(local.shared.extra.view().items(.@"0")[0..pt_header.intern_pool.extra_len]));
- addBuf(&bufs, mem.sliceAsBytes(local.shared.items.view().items(.data)[0..pt_header.intern_pool.items_len]));
- addBuf(&bufs, mem.sliceAsBytes(local.shared.items.view().items(.tag)[0..pt_header.intern_pool.items_len]));
- addBuf(&bufs, local.shared.strings.view().items(.@"0")[0..pt_header.intern_pool.string_bytes_len]);
- addBuf(&bufs, mem.sliceAsBytes(local.shared.tracked_insts.view().items(.@"0")[0..pt_header.intern_pool.tracked_insts_len]));
- addBuf(&bufs, mem.sliceAsBytes(local.shared.files.view().items(.bin_digest)[0..pt_header.intern_pool.files_len]));
- addBuf(&bufs, mem.sliceAsBytes(local.shared.files.view().items(.root_type)[0..pt_header.intern_pool.files_len]));
+ if (pt_header.intern_pool.limbs_len > 0) {
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.limbs.view().items(.@"0")[0..pt_header.intern_pool.limbs_len]));
+ }
+ if (pt_header.intern_pool.extra_len > 0) {
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.extra.view().items(.@"0")[0..pt_header.intern_pool.extra_len]));
+ }
+ if (pt_header.intern_pool.items_len > 0) {
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.items.view().items(.data)[0..pt_header.intern_pool.items_len]));
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.items.view().items(.tag)[0..pt_header.intern_pool.items_len]));
+ }
+ if (pt_header.intern_pool.string_bytes_len > 0) {
+ addBuf(&bufs, local.shared.strings.view().items(.@"0")[0..pt_header.intern_pool.string_bytes_len]);
+ }
+ if (pt_header.intern_pool.tracked_insts_len > 0) {
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.tracked_insts.view().items(.@"0")[0..pt_header.intern_pool.tracked_insts_len]));
+ }
+ if (pt_header.intern_pool.files_len > 0) {
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.files.view().items(.bin_digest)[0..pt_header.intern_pool.files_len]));
+ addBuf(&bufs, mem.sliceAsBytes(local.shared.files.view().items(.root_type)[0..pt_header.intern_pool.files_len]));
+ }
}
//// TODO: compilation errors