summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-overload.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-13 13:11:48 -0700
committerGitHub <noreply@github.com>2022-09-13 13:11:48 -0700
commitf216b77752b9e4aea52882b2110ceb1cc64a2171 (patch)
treefbb33485b7260bc0f89b406e1be6fb8196f94196 /source/slang/slang-check-overload.cpp
parent9f3e83cf0d664c87a618edf08d834829178030e6 (diff)
Deduplicate AST type nodes and cache lookup operations. (#2397)
* wip: dedup AST type nodes and cache lookup. * Fix. * Remove profiling. * Fixes. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
-rw-r--r--source/slang/slang-check-overload.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index 9109130e2..55263453d 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -210,7 +210,7 @@ namespace Slang
//
auto genSubst = m_astBuilder->create<GenericSubstitution>();
candidate.subst = genSubst;
- auto& checkedArgs = genSubst->args;
+ auto& checkedArgs = (List<Val*>&)genSubst->getArgs();
// Rather than bail out as soon as we hit a problem,
// we are going to process *all* of the parameters of the
@@ -474,7 +474,7 @@ namespace Slang
bool SemanticsVisitor::TryCheckOverloadCandidateConstraints(
OverloadResolveContext& context,
- OverloadCandidate const& candidate)
+ OverloadCandidate& candidate)
{
// We only need this step for generics, so always succeed on
// everything else.
@@ -493,6 +493,8 @@ namespace Slang
subst->genericDecl = genericDeclRef.getDecl();
subst->outer = genericDeclRef.substitutions.substitutions;
+ List<Val*> newArgs = subst->getArgs();
+
for( auto constraintDecl : genericDeclRef.getDecl()->getMembersOfType<GenericTypeConstraintDecl>() )
{
auto subset = genericDeclRef.substitutions;
@@ -506,7 +508,7 @@ namespace Slang
auto subTypeWitness = tryGetSubtypeWitness(sub, sup);
if(subTypeWitness)
{
- subst->args.add(subTypeWitness);
+ newArgs.add(subTypeWitness);
}
else
{
@@ -518,6 +520,8 @@ namespace Slang
}
}
+ candidate.subst = m_astBuilder->getOrCreateGenericSubstitution(genericDeclRef.getDecl(), newArgs, genericDeclRef.substitutions.substitutions);
+
// Done checking all the constraints, hooray.
return true;
}