aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-26 15:06:11 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:56 -0700
commite156c1c07ea3db3b2cb163ec7230ed8ecbf42859 (patch)
treed58fd76b5361a2da7c224bb0e824efefddb68022
parent1dc01f11401b6ec0be1e7685cdc445d1b10d4f19 (diff)
downloadzig-e156c1c07ea3db3b2cb163ec7230ed8ecbf42859.tar.gz
zig-e156c1c07ea3db3b2cb163ec7230ed8ecbf42859.zip
InternPool: correct the logic for struct size dump
-rw-r--r--src/InternPool.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index ea3bafaf48..07e74ffe35 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -4435,6 +4435,7 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
const items_size = (1 + 4) * ip.items.len;
const extra_size = 4 * ip.extra.items.len;
const limbs_size = 8 * ip.limbs.items.len;
+ // TODO: fields size is not taken into account
const structs_size = ip.allocated_structs.len *
(@sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @sizeOf(Module.Decl));
const unions_size = ip.allocated_unions.len *
@@ -4501,7 +4502,14 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
.type_enum_explicit, .type_enum_nonexhaustive => @sizeOf(EnumExplicit),
.type_enum_auto => @sizeOf(EnumAuto),
.type_opaque => @sizeOf(Key.OpaqueType),
- .type_struct => @sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @sizeOf(Module.Decl),
+ .type_struct => b: {
+ const struct_index = @intToEnum(Module.Struct.Index, data);
+ const struct_obj = ip.structPtrConst(struct_index);
+ break :b @sizeOf(Module.Struct) +
+ @sizeOf(Module.Namespace) +
+ @sizeOf(Module.Decl) +
+ (struct_obj.fields.count() * @sizeOf(Module.Struct.Field));
+ },
.type_struct_ns => @sizeOf(Module.Namespace),
.type_struct_anon => b: {
const info = ip.extraData(TypeStructAnon, data);