authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-26 15:06:11-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:56-07:00
loge156c1c07ea3db3b2cb163ec7230ed8ecbf42859
treed58fd76b5361a2da7c224bb0e824efefddb68022
parent1dc01f11401b6ec0be1e7685cdc445d1b10d4f19

InternPool: correct the logic for struct size dump


1 files changed, 9 insertions(+), 1 deletions(-)

src/InternPool.zig+9-1
...@@ -4435,6 +4435,7 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {...@@ -4435,6 +4435,7 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
4435 const items_size = (1 + 4) * ip.items.len;4435 const items_size = (1 + 4) * ip.items.len;
4436 const extra_size = 4 * ip.extra.items.len;4436 const extra_size = 4 * ip.extra.items.len;
4437 const limbs_size = 8 * ip.limbs.items.len;4437 const limbs_size = 8 * ip.limbs.items.len;
4438 // TODO: fields size is not taken into account
4438 const structs_size = ip.allocated_structs.len *4439 const structs_size = ip.allocated_structs.len *
4439 (@sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @sizeOf(Module.Decl));4440 (@sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @sizeOf(Module.Decl));
4440 const unions_size = ip.allocated_unions.len *4441 const unions_size = ip.allocated_unions.len *
...@@ -4501,7 +4502,14 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {...@@ -4501,7 +4502,14 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
4501 .type_enum_explicit, .type_enum_nonexhaustive => @sizeOf(EnumExplicit),4502 .type_enum_explicit, .type_enum_nonexhaustive => @sizeOf(EnumExplicit),
4502 .type_enum_auto => @sizeOf(EnumAuto),4503 .type_enum_auto => @sizeOf(EnumAuto),
4503 .type_opaque => @sizeOf(Key.OpaqueType),4504 .type_opaque => @sizeOf(Key.OpaqueType),
4504 .type_struct => @sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @sizeOf(Module.Decl),4505 .type_struct => b: {
4506 const struct_index = @intToEnum(Module.Struct.Index, data);
4507 const struct_obj = ip.structPtrConst(struct_index);
4508 break :b @sizeOf(Module.Struct) +
4509 @sizeOf(Module.Namespace) +
4510 @sizeOf(Module.Decl) +
4511 (struct_obj.fields.count() * @sizeOf(Module.Struct.Field));
4512 },
4505 .type_struct_ns => @sizeOf(Module.Namespace),4513 .type_struct_ns => @sizeOf(Module.Namespace),
4506 .type_struct_anon => b: {4514 .type_struct_anon => b: {
4507 const info = ip.extraData(TypeStructAnon, data);4515 const info = ip.extraData(TypeStructAnon, data);