summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-doc-extractor.cpp2
-rw-r--r--source/compiler-core/slang-lexer.cpp2
-rw-r--r--source/compiler-core/slang-name.cpp6
-rw-r--r--source/compiler-core/slang-name.h30
-rw-r--r--source/slang/slang-compiler.h6
-rw-r--r--source/slang/slang-language-server-auto-format.cpp2
-rw-r--r--source/slang/slang.cpp6
7 files changed, 11 insertions, 43 deletions
diff --git a/source/compiler-core/slang-doc-extractor.cpp b/source/compiler-core/slang-doc-extractor.cpp
index f2f4775fa..0a5c1355d 100644
--- a/source/compiler-core/slang-doc-extractor.cpp
+++ b/source/compiler-core/slang-doc-extractor.cpp
@@ -885,9 +885,7 @@ SlangResult DocMarkupExtractor::extract(
MemoryArena memoryArena(4096);
- RootNamePool rootNamePool;
NamePool namePool;
- namePool.setRootNamePool(&rootNamePool);
Index viewIndex = -1;
SourceView* sourceView = nullptr;
diff --git a/source/compiler-core/slang-lexer.cpp b/source/compiler-core/slang-lexer.cpp
index 119c34d48..d9ff9c0f0 100644
--- a/source/compiler-core/slang-lexer.cpp
+++ b/source/compiler-core/slang-lexer.cpp
@@ -1921,9 +1921,7 @@ TokenList Lexer::lexAllTokens()
MemoryArena arena;
- RootNamePool rootNamePool;
NamePool namePool;
- namePool.setRootNamePool(&rootNamePool);
lexer.initialize(sourceView, &sink, &namePool, &arena);
diff --git a/source/compiler-core/slang-name.cpp b/source/compiler-core/slang-name.cpp
index 6f79d25b5..da19dfe3b 100644
--- a/source/compiler-core/slang-name.cpp
+++ b/source/compiler-core/slang-name.cpp
@@ -24,12 +24,12 @@ const char* getCstr(Name* name)
Name* NamePool::getName(UnownedStringSlice text)
{
RefPtr<Name> name;
- if (rootPool->names.tryGetValue(text, name))
+ if (names.tryGetValue(text, name))
return name;
name = new Name();
name->text = text;
- rootPool->names.add(text, name);
+ names.add(text, name);
return name;
}
@@ -41,7 +41,7 @@ Name* NamePool::getName(String const& text)
Name* NamePool::tryGetName(String const& text)
{
RefPtr<Name> name;
- if (rootPool->names.tryGetValue(text, name))
+ if (names.tryGetValue(text, name))
return name;
return nullptr;
}
diff --git a/source/compiler-core/slang-name.h b/source/compiler-core/slang-name.h
index 331086d77..aa178968d 100644
--- a/source/compiler-core/slang-name.h
+++ b/source/compiler-core/slang-name.h
@@ -43,28 +43,10 @@ UnownedStringSlice getUnownedStringSliceText(Name* name);
// Get a name as a C style string, or nullptr if name is nullptr
const char* getCstr(Name* name);
-// A `RootNamePool` is used to store and look up names.
+// A `NamePool` is used to store and look up names.
// If two systems need to work together with names, and be sure that they
// get equivalent names for a string like `"Foo"`, then they need to use
-// the same root name pool (directly or indirectly).
-//
-struct RootNamePool
-{
- // The mapping from text strings to the corresponding name.
- Dictionary<String, RefPtr<Name>> names;
-};
-
-// A `NamePool` is effectively a way of storing a subset of the
-// names that have been created through a `RootNamePool`.
-//
-// The intention is that eventually we will add the ability to clean
-// up a `NamePool`, and remove the names it created from the corresponding
-// `RootNamePool` *if* those names are no longer in use.
-//
-// The goal of such an approach would be to ensure that the memory
-// usage of a `Session` can't bloat over time just because of multiple
-// `CompileRequest`s being created, used, and then destroyed (each time
-// adding just a few more strings to the name mapping).
+// the same name pool (directly or indirectly).
//
struct NamePool
{
@@ -74,13 +56,9 @@ struct NamePool
// Try find the `Name` that represents the given `text`.
// If the name does not exist, return nullptr
Name* tryGetName(String const& text);
- // Set the parent name pool to use for lookup
- void setRootNamePool(RootNamePool* rootNamePool) { this->rootPool = rootNamePool; }
-
- //
- // The root name pool to use for storage/lookup
- RootNamePool* rootPool = nullptr;
+ // The mapping from text strings to the corresponding name.
+ Dictionary<String, RefPtr<Name>> names;
};
} // namespace Slang
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 6054492bc..d45e796d9 100644
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -2353,9 +2353,9 @@ public:
StringSlicePool m_stringSlicePool;
// Name pool for looking up names
- NamePool namePool;
+ NamePool* namePool = nullptr;
- NamePool* getNamePool() { return &namePool; }
+ NamePool* getNamePool() { return namePool; }
ASTBuilder* getASTBuilder() { return m_astBuilder; }
@@ -3740,10 +3740,8 @@ public:
// Name pool stuff for unique-ing identifiers
- RootNamePool rootNamePool;
NamePool namePool;
- RootNamePool* getRootNamePool() { return &rootNamePool; }
NamePool* getNamePool() { return &namePool; }
Name* getNameObj(String name) { return namePool.getName(name); }
Name* tryGetNameObj(String name) { return namePool.tryGetName(name); }
diff --git a/source/slang/slang-language-server-auto-format.cpp b/source/slang/slang-language-server-auto-format.cpp
index b7f601bc2..a65eb64ec 100644
--- a/source/slang/slang-language-server-auto-format.cpp
+++ b/source/slang/slang-language-server-auto-format.cpp
@@ -77,9 +77,7 @@ List<TextRange> extractFormattingExclusionRanges(UnownedStringSlice text)
auto sourceFile = manager.createSourceFileWithString(PathInfo(), text);
auto sourceView = manager.createSourceView(sourceFile, nullptr, SourceLoc());
DiagnosticSink sink;
- RootNamePool rootPool;
NamePool namePool;
- namePool.setRootNamePool(&rootPool);
MemoryArena memory;
memory.init(1 << 16);
lexer.initialize(sourceView, &sink, &namePool, &memory);
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 090e34e9a..f65681e4b 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -167,8 +167,6 @@ void Session::init()
DownstreamCompilerUtil::setDefaultLocators(m_downstreamCompilerLocators);
m_downstreamCompilerSet = new DownstreamCompilerSet;
- // Initialize name pool
- getNamePool()->setRootNamePool(getRootNamePool());
m_completionTokenName = getNamePool()->getName("#?");
m_sharedLibraryLoader = DefaultSharedLibraryLoader::getSingleton();
@@ -1370,7 +1368,7 @@ Linkage::Linkage(Session* session, ASTBuilder* astBuilder, Linkage* builtinLinka
, m_cmdLineContext(new CommandLineContext())
, m_stringSlicePool(StringSlicePool::Style::Default)
{
- getNamePool()->setRootNamePool(session->getRootNamePool());
+ namePool = session->getNamePool();
m_defaultSourceManager.initialize(session->getBuiltinSourceManager(), nullptr);
@@ -3601,7 +3599,7 @@ void FrontEndCompileRequest::parseTranslationUnit(TranslationUnitRequest* transl
#if 0
// Test serialization
{
- ASTSerialTestUtil::testSerialize(translationUnit->getModuleDecl(), getSession()->getRootNamePool(), getLinkage()->getASTBuilder()->getSharedASTBuilder(), getSourceManager());
+ ASTSerialTestUtil::testSerialize(translationUnit->getModuleDecl(), getSession()->getNamePool(), getLinkage()->getASTBuilder()->getSharedASTBuilder(), getSourceManager());
}
#endif
}