Skip to content

Commit 8d2a410

Browse files
committed
GenericSignatureBuilder: Improved counters
1 parent b3aea6e commit 8d2a410

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,17 +1546,10 @@ class GenericSignatureBuilder::PotentialArchetype {
15461546
llvm::MapVector<Identifier, StoredNestedType> NestedTypes;
15471547

15481548
/// Construct a new potential archetype for a concrete declaration.
1549-
PotentialArchetype(PotentialArchetype *parent, AssociatedTypeDecl *assocType)
1550-
: parentOrContext(parent), identifier(assocType) {
1551-
assert(parent != nullptr && "Not a nested type?");
1552-
assert(assocType->getOverriddenDecls().empty());
1553-
}
1549+
PotentialArchetype(PotentialArchetype *parent, AssociatedTypeDecl *assocType);
15541550

15551551
/// Construct a new potential archetype for a generic parameter.
1556-
PotentialArchetype(ASTContext &ctx, GenericParamKey genericParam)
1557-
: parentOrContext(&ctx), identifier(genericParam)
1558-
{
1559-
}
1552+
PotentialArchetype(ASTContext &ctx, GenericParamKey genericParam);
15601553

15611554
public:
15621555
/// Retrieve the representative for this archetype, performing

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ namespace llvm {
8080

8181
#define DEBUG_TYPE "Generic signature builder"
8282
STATISTIC(NumPotentialArchetypes, "# of potential archetypes");
83+
STATISTIC(NumEquivalenceClassesAllocated, "# of equivalence classes allocated");
84+
STATISTIC(NumEquivalenceClassesFreed, "# of equivalence classes freed");
8385
STATISTIC(NumConformances, "# of conformances tracked");
8486
STATISTIC(NumConformanceConstraints, "# of conformance constraints tracked");
8587
STATISTIC(NumSameTypeConstraints, "# of same-type constraints tracked");
@@ -529,13 +531,18 @@ GenericSignatureBuilder::Implementation::allocateEquivalenceClass(
529531

530532
auto equivClass = new (mem) EquivalenceClass(representative);
531533
EquivalenceClasses.push_back(equivClass);
534+
535+
++NumEquivalenceClassesAllocated;
536+
532537
return equivClass;
533538
}
534539

535540
void GenericSignatureBuilder::Implementation::deallocateEquivalenceClass(
536541
EquivalenceClass *equivClass) {
537542
EquivalenceClasses.erase(equivClass);
538543
FreeEquivalenceClasses.push_back(equivClass);
544+
545+
++NumEquivalenceClassesFreed;
539546
}
540547

541548
namespace {
@@ -1620,9 +1627,22 @@ bool FloatingRequirementSource::isRecursive(
16201627
return false;
16211628
}
16221629

1623-
GenericSignatureBuilder::PotentialArchetype::~PotentialArchetype() {
1630+
GenericSignatureBuilder::PotentialArchetype::PotentialArchetype(
1631+
PotentialArchetype *parent, AssociatedTypeDecl *assocType)
1632+
: parentOrContext(parent), identifier(assocType) {
1633+
++NumPotentialArchetypes;
1634+
assert(parent != nullptr && "Not a nested type?");
1635+
assert(assocType->getOverriddenDecls().empty());
1636+
}
1637+
1638+
1639+
GenericSignatureBuilder::PotentialArchetype::PotentialArchetype(
1640+
ASTContext &ctx, GenericParamKey genericParam)
1641+
: parentOrContext(&ctx), identifier(genericParam) {
16241642
++NumPotentialArchetypes;
1643+
}
16251644

1645+
GenericSignatureBuilder::PotentialArchetype::~PotentialArchetype() {
16261646
for (const auto &nested : NestedTypes) {
16271647
for (auto pa : nested.second) {
16281648
pa->~PotentialArchetype();

0 commit comments

Comments
 (0)