From 30ec43a6c78d9c8803becbea5a02edb8fae08af6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 4 Jul 2024 14:16:42 -0700 Subject: Zcu: extract permanent state from File Primarily, this commit removes 2 fields from File, relying on the data being stored in the `files` field, with the key as the path digest, and the value as the struct decl corresponding to the File. This table is serialized into the compiler state that survives between incremental updates. Meanwhile, the File struct remains ephemeral data that can be reconstructed the first time it is needed by the compiler process, as well as operated on by independent worker threads. A key outcome of this commit is that there is now a stable index that can be used to refer to a File. This will be needed when serializing error messages to survive incremental compilation updates. --- src/InternPool.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/InternPool.zig') diff --git a/src/InternPool.zig b/src/InternPool.zig index c6b27acaf3..e79de26516 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -123,9 +123,14 @@ pub const TrackedInst = extern struct { }; }; -pub fn trackZir(ip: *InternPool, gpa: Allocator, file: *Module.File, inst: Zir.Inst.Index) Allocator.Error!TrackedInst.Index { +pub fn trackZir( + ip: *InternPool, + gpa: Allocator, + path_digest: Cache.BinDigest, + inst: Zir.Inst.Index, +) Allocator.Error!TrackedInst.Index { const key: TrackedInst = .{ - .path_digest = file.path_digest, + .path_digest = path_digest, .inst = inst, }; const gop = try ip.tracked_insts.getOrPut(gpa, key); -- cgit v1.2.3