aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-19 21:51:08 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-04-20 17:37:35 -0700
commitf7596ae9423e9de8276629803147e1a243f2177b (patch)
treeb97f2a8e8fdb84a118f587bcbfd76918710587dd /src/main.zig
parent4f527e5d36f66a83ff6a263a03f16e2c4d049f1e (diff)
downloadzig-f7596ae9423e9de8276629803147e1a243f2177b.tar.gz
zig-f7596ae9423e9de8276629803147e1a243f2177b.zip
stage2: use indexes for Decl objects
Rather than allocating Decl objects with an Allocator, we instead allocate them with a SegmentedList. This provides four advantages: * Stable memory so that one thread can access a Decl object while another thread allocates additional Decl objects from this list. * It allows us to use u32 indexes to reference Decl objects rather than pointers, saving memory in Type, Value, and dependency sets. * Using integers to reference Decl objects rather than pointers makes serialization trivial. * It provides a unique integer to be used for anonymous symbol names, avoiding multi-threaded contention on an atomic counter.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig
index 84a69b98f1..e47ff0e272 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -3892,7 +3892,7 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
.tree_loaded = true,
.zir = undefined,
.pkg = undefined,
- .root_decl = null,
+ .root_decl = .none,
};
file.pkg = try Package.create(gpa, null, file.sub_file_path);
@@ -4098,7 +4098,7 @@ fn fmtPathFile(
.tree_loaded = true,
.zir = undefined,
.pkg = undefined,
- .root_decl = null,
+ .root_decl = .none,
};
file.pkg = try Package.create(fmt.gpa, null, file.sub_file_path);
@@ -4757,7 +4757,7 @@ pub fn cmdAstCheck(
.tree = undefined,
.zir = undefined,
.pkg = undefined,
- .root_decl = null,
+ .root_decl = .none,
};
if (zig_source_file) |file_name| {
var f = fs.cwd().openFile(file_name, .{}) catch |err| {
@@ -4910,7 +4910,7 @@ pub fn cmdChangelist(
.tree = undefined,
.zir = undefined,
.pkg = undefined,
- .root_decl = null,
+ .root_decl = .none,
};
file.pkg = try Package.create(gpa, null, file.sub_file_path);