Skip to content

Commit fb042b2

Browse files
committed
log number of notes and includes when counting types
1 parent bfcc0d6 commit fb042b2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ir/module-utils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ namespace {
2424

2525
// Helper for collecting HeapTypes and their frequencies.
2626
struct Counts : public InsertOrderedMap<HeapType, size_t> {
27+
int notes = 0;
28+
int includes = 0;
2729
void note(HeapType type) {
2830
if (!type.isBasic()) {
2931
(*this)[type]++;
32+
notes++;
3033
}
3134
}
3235
void note(Type type) {
@@ -38,6 +41,7 @@ struct Counts : public InsertOrderedMap<HeapType, size_t> {
3841
void include(HeapType type) {
3942
if (!type.isBasic()) {
4043
(*this)[type];
44+
includes++;
4145
}
4246
}
4347
void include(Type type) {
@@ -137,6 +141,8 @@ Counts getHeapTypeCounts(Module& wasm) {
137141
for (auto& [sig, count] : functionCounts) {
138142
counts[sig] += count;
139143
}
144+
counts.notes += functionCounts.notes;
145+
counts.includes += functionCounts.includes;
140146
}
141147

142148
// Recursively traverse each reference type, which may have a child type that
@@ -191,6 +197,8 @@ Counts getHeapTypeCounts(Module& wasm) {
191197
for (auto& [type, count] : counts) {
192198
std::cout << ((type.getID() << 2) % 997) << ", count: " << count << "\n";
193199
}
200+
std::cout << "total notes: " << counts.notes
201+
<< ", includes: " << counts.includes << "\n";
194202
return counts;
195203
}
196204

0 commit comments

Comments
 (0)