From 45d9961a6a86d184248ef84f6a07125b0c224f97 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Wed, 16 Aug 2023 08:57:47 +0800 Subject: Use ankerl/unordered_dense as a hashmap implementation (#3036) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Correct namespace for getClockFrequency * missing const * Add missing assignment operator * Remove unused variables * Return correct modified variable * Use stable hash code for file system identity * terse static_assert * Structured binding for map iteration * Make (==) and getHashCode const on many structs * Add ConstIterator for LinkedList * Replace uses of ItemProxy::getValue with Dictionary::at * Extract list of loads from gradientsMap before updating it * Const correctness in type layout * Add unordered_dense hashmap submodule * Use wyhash or getHashCode in slang-hash.h * refactor slang-hash.h * Use ankerl/unordered_dense as a hashmap implementation Notable changes: - The subscript operator returns a reference directly to the value, rather than a lazy ItemProxy (pair of dict pointer and key) slang-profile time (95% over 10 runs): - Before: 6.3913906 (±0.0746) - After: 5.9276123 (±0.0964) * 64 bit hash for strings So they have the same hash as char buffers with the same contents * Narrowing warnings for gcc to match msvc * revert back to c++17 * Correct c++ version for msvc * Use path to unordered_dense which keeps tests happy * Do not assign to and read from map in same expression * Remove redundant map operations in primal-hoist * Split out stable hash functions into slang-stable-hash.h * 64 bit hash by default * regenerate vs projects * Correct return type from HashSetBase::getCount() * correct width for call to Dictionary::reserve * Use stable hash for obfuscated module ids * Signed int for reserve * clearer variable naming * Parameterize Dictionary on hash and equality functors * Allow heterogenous lookup for Dictionary * missing const * Use set over operator[] in some places * Remove unused function * s/at/getValue --- source/compiler-core/slang-source-loc.cpp | 1 - source/compiler-core/slang-visual-studio-compiler-util.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-source-loc.cpp b/source/compiler-core/slang-source-loc.cpp index f9014e0d8..33f93074e 100644 --- a/source/compiler-core/slang-source-loc.cpp +++ b/source/compiler-core/slang-source-loc.cpp @@ -318,7 +318,6 @@ SlangResult SourceView::_findSourceMapLoc(SourceLoc loc, SourceLocType type, Han // view, which may be a parent to the current one. auto lookupSourceManager = m_sourceFile->getSourceManager(); - HandleSourceLoc handleLoc; SLANG_RETURN_ON_FAIL(_findLocWithSourceMap(lookupSourceManager, this, loc, type, outLoc)); return SLANG_OK; diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp index 81e00d73e..14fad0aec 100644 --- a/source/compiler-core/slang-visual-studio-compiler-util.cpp +++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp @@ -83,14 +83,17 @@ static void _addFile(const String& path, const ArtifactDesc& desc, IOSFileArtifa // Display full path of source files in diagnostics cmdLine.addArg("/FC"); - if (options.flags & CompileOptions::Flag::EnableExceptionHandling) + if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP) { - if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP) + if (options.flags & CompileOptions::Flag::EnableExceptionHandling) { // https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019 // Assumes c functions cannot throw cmdLine.addArg("/EHsc"); } + + // To maintain parity with the slang compiler headers which are shared + cmdLine.addArg("/std:c++17"); } if (options.flags & CompileOptions::Flag::Verbose) -- cgit v1.2.3