authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-02-26 09:56:16-05:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-02-28 22:01:13+02:00
log58b14d01aeb919989d1750a8894350a07fd4e844
tree574dbe169aa0fba72b8901333a82c9e3e5d11c51
parent1f17221bc4e17bcd7116fe12ab3f939346179799

stage2: remove value field from error

This saves memory and from what I have heard allows threading to be easier.

3 files changed, 2 insertions(+), 5 deletions(-)

src/Module.zig-1
......@@ -4101,7 +4101,6 @@ pub fn namedFieldPtr(
41014101 scope.arena(),
41024102 try Value.Tag.@"error".create(scope.arena(), .{
41034103 .name = entry.key,
4104 .value = entry.value,
41054104 }),
41064105 ),
41074106 });
src/value.zig-2
......@@ -1561,7 +1561,6 @@ pub const Value = extern union {
15611561 .@"error" => {
15621562 const payload = self.castTag(.@"error").?.data;
15631563 hasher.update(payload.name);
1564 std.hash.autoHash(&hasher, payload.value);
15651564 },
15661565 .error_union => {
15671566 const payload = self.castTag(.error_union).?.data;
......@@ -2157,7 +2156,6 @@ pub const Value = extern union {
21572156 /// duration of the compilation.
21582157 /// TODO revisit this when we have the concept of the error tag type
21592158 name: []const u8,
2160 value: u16,
21612159 },
21622160 };
21632161
src/zir_sema.zig+2-2
......@@ -1178,7 +1178,6 @@ fn zirErrorValue(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorValue) InnerE
11781178 .ty = result_type,
11791179 .val = try Value.Tag.@"error".create(scope.arena(), .{
11801180 .name = entry.key,
1181 .value = entry.value,
11821181 }),
11831182 });
11841183}
......@@ -2215,7 +2214,8 @@ fn zirCmp(
22152214 }
22162215 if (rhs.value()) |rval| {
22172216 if (lhs.value()) |lval| {
2218 return mod.constBool(scope, inst.base.src, (lval.castTag(.@"error").?.data.value == rval.castTag(.@"error").?.data.value) == (op == .eq));
2217 // TODO optimisation oppurtunity: evaluate if std.mem.eql is faster with the names, or calling to Module.getErrorValue to get the values and then compare them is faster
2218 return mod.constBool(scope, inst.base.src, std.mem.eql(u8, lval.castTag(.@"error").?.data.name, rval.castTag(.@"error").?.data.name) == (op == .eq));
22192219 }
22202220 }
22212221 return mod.fail(scope, inst.base.src, "TODO implement equality comparison between runtime errors", .{});