diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-compiler.h | 1 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 13 |
3 files changed, 11 insertions, 5 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index f548fb819..01cd303c7 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -2565,7 +2565,7 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr) // We should only use the cached candidate if it is persistent direct declref // created from GlobalSession's ASTBuilder, or it is created in the current Linkage. if (candidate.cacheVersion == typeCheckingCache->version || - as<DirectDeclRef>(candidate.candidate.item.declRef.declRefBase)) + findNextOuterGeneric(candidate.decl) == nullptr) { context.bestCandidateStorage = candidate.candidate; context.bestCandidate = &context.bestCandidateStorage; diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 3e00e4b04..056c1fc83 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -3591,6 +3591,7 @@ public: RefPtr<RefObject> m_typeCheckingCache; TypeCheckingCache* getTypeCheckingCache(); + std::mutex m_typeCheckingCacheMutex; private: struct BuiltinModuleInfo diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index ec90ee418..001354162 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -809,9 +809,12 @@ Session::createSession(slang::SessionDesc const& inDesc, slang::ISession** outSe RefPtr<Linkage> linkage = new Linkage(this, astBuilder, getBuiltinLinkage()); - if (m_typeCheckingCache) - linkage->m_typeCheckingCache = - new TypeCheckingCache(*static_cast<TypeCheckingCache*>(m_typeCheckingCache.get())); + { + std::lock_guard<std::mutex> lock(m_typeCheckingCacheMutex); + if (m_typeCheckingCache) + linkage->m_typeCheckingCache = + new TypeCheckingCache(*static_cast<TypeCheckingCache*>(m_typeCheckingCache.get())); + } linkage->setMatrixLayoutMode(desc.defaultMatrixLayoutMode); @@ -1308,14 +1311,16 @@ Linkage::~Linkage() if (m_typeCheckingCache) { auto globalSession = getSessionImpl(); + std::lock_guard<std::mutex> lock(globalSession->m_typeCheckingCacheMutex); if (!globalSession->m_typeCheckingCache || globalSession->getTypeCheckingCache()->resolvedOperatorOverloadCache.getCount() < getTypeCheckingCache()->resolvedOperatorOverloadCache.getCount()) { globalSession->m_typeCheckingCache = m_typeCheckingCache; + getTypeCheckingCache()->version++; } + destroyTypeCheckingCache(); } - destroyTypeCheckingCache(); } SearchDirectoryList& Linkage::getSearchDirectories() |
