authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-05 20:48:44-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:42:29-07:00
log6350aabf9d00cbdfe73c6aa0a7d8e8f52fe6d8f1
tree6971ecfd2f2a81253e805cc52122d2b081317a0a
parent9626811725ba7bb979559b718492b1fbe7fc0578

InternPool: fix bug in addLimbsExtraAssumeCapacity


1 files changed, 16 insertions(+), 8 deletions(-)

src/InternPool.zig+16-8
...@@ -1319,7 +1319,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {...@@ -1319,7 +1319,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
1319 @sizeOf(u64) => {},1319 @sizeOf(u64) => {},
1320 else => @compileError("unsupported host"),1320 else => @compileError("unsupported host"),
1321 }1321 }
1322 const result = @intCast(u32, ip.extra.items.len);1322 const result = @intCast(u32, ip.limbs.items.len);
1323 inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| {1323 inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| {
1324 const new: u32 = switch (field.type) {1324 const new: u32 = switch (field.type) {
1325 u32 => @field(extra, field.name),1325 u32 => @field(extra, field.name),
...@@ -1452,11 +1452,19 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {...@@ -1452,11 +1452,19 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
14521452
1453 std.debug.print(1453 std.debug.print(
1454 \\InternPool size: {d} bytes1454 \\InternPool size: {d} bytes
1455 \\ items: {d} bytes1455 \\ {d} items: {d} bytes
1456 \\ extra: {d} bytes1456 \\ {d} extra: {d} bytes
1457 \\ limbs: {d} bytes1457 \\ {d} limbs: {d} bytes
1458 \\1458 \\
1459 , .{ total_size, items_size, extra_size, limbs_size });1459 , .{
1460 total_size,
1461 ip.items.len,
1462 items_size,
1463 ip.extra.items.len,
1464 extra_size,
1465 ip.limbs.items.len,
1466 limbs_size,
1467 });
14601468
1461 const tags = ip.items.items(.tag);1469 const tags = ip.items.items(.tag);
1462 const datas = ip.items.items(.data);1470 const datas = ip.items.items(.data);
...@@ -1512,10 +1520,10 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {...@@ -1512,10 +1520,10 @@ fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {
1512 }1520 }
1513 };1521 };
1514 counts.sort(SortContext{ .map = &counts });1522 counts.sort(SortContext{ .map = &counts });
1515 const len = @min(50, tags.len);1523 const len = @min(50, counts.count());
1516 std.debug.print("top 50 tags:\n", .{});1524 std.debug.print(" top 50 tags:\n", .{});
1517 for (counts.keys()[0..len], counts.values()[0..len]) |tag, stats| {1525 for (counts.keys()[0..len], counts.values()[0..len]) |tag, stats| {
1518 std.debug.print(" {s}: {d} occurrences, {d} total bytes\n", .{1526 std.debug.print(" {s}: {d} occurrences, {d} total bytes\n", .{
1519 @tagName(tag), stats.count, stats.bytes,1527 @tagName(tag), stats.count, stats.bytes,
1520 });1528 });
1521 }1529 }