From efdbb954c57b89362e390f955d45f90e59d66878 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 29 May 2024 18:01:11 -0700 Subject: Improve compile time performance. (#3857) * Handle type check cache update on extensions more gracefully. * Correctness fix. * Cache implcit cast overload resolution results. * Fix. * More optimizations. * Cache implicit default ctor resolution. * Disable redundancy removal. * Fix. * Fix test. * Fix. * Correctness fix. * Fix. * Fix, * Fix test. * Small tweak. --- source/slang/slang-check-inheritance.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/slang/slang-check-inheritance.cpp') diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp index 18624424c..f1dbaef5c 100644 --- a/source/slang/slang-check-inheritance.cpp +++ b/source/slang/slang-check-inheritance.cpp @@ -5,11 +5,6 @@ // related to computing linearized inheritance // information for types and decalrations. -//#include "slang-lookup.h" -//#include "slang-syntax.h" -//#include "slang-ast-synthesis.h" -//#include - namespace Slang { InheritanceInfo SharedSemanticsContext::getInheritanceInfo(Type* type) @@ -17,7 +12,12 @@ namespace Slang // We cache the computed inheritance information for types, // and re-use that information whenever possible. - if(auto found = m_mapTypeToInheritanceInfo.tryGetValue(type)) + // DeclRefTypes will have their inheritance info cached in m_mapDeclRefToInheritanceInfo. + if (auto declRefType = as(type)) + return _getInheritanceInfo(declRefType->getDeclRef(), declRefType); + + // Non ordinary types are cached on m_mapTypeToInheritanceInfo. + if (auto found = m_mapTypeToInheritanceInfo.tryGetValue(type)) return *found; // Note: we install a null pointer into the dictionary to act @@ -32,9 +32,6 @@ namespace Slang auto info = _calcInheritanceInfo(type); m_mapTypeToInheritanceInfo[type] = info; - getSession()->m_typeDictionarySize = Math::Max( - getSession()->m_typeDictionarySize, (int)m_mapTypeToInheritanceInfo.getCount()); - return info; } @@ -68,6 +65,9 @@ namespace Slang auto info = _calcInheritanceInfo(declRef, declRefType); m_mapDeclRefToInheritanceInfo[declRef] = info; + getSession()->m_typeDictionarySize = Math::Max( + getSession()->m_typeDictionarySize, (int)m_mapDeclRefToInheritanceInfo.getCount()); + return info; } -- cgit v1.2.3