summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-06-30 12:25:27 -0700
committerGitHub <noreply@github.com>2020-06-30 12:25:27 -0700
commit8ced9d2a0efaca8f6dbdaf427be1db52844787b5 (patch)
tree20dc0a8d3ec838253823558fc4df8a82ddd1a910 /source/core
parentdc44b08ec377106a0c6d1c022e2754d9e11c579f (diff)
Clean up unused code for IR object ownership (#1416)
There was a small but non-trivial amount of code across `IRModule`, the `ObjectScopeManager`, and `StringRepresentationCache` that had to do with managing the lifetimes of `RefObject`s that might be referenced by IR instructions (and thus need to be kept alive for the lifetime of the IR module). We have long since migrated to a model where IR instruction do not include owned references to `RefObject`s, so these facilities weren't actually needed. This streamlines `IRModule`'s declaration, and trims code that we aren't actually using. One note for the future is that the `StringRepresentationCache` no longer does what its name implies (it is not a cache of `StringRepresentation`s), so we should consider giving it a more narrowly scoped name. I didn't include that in this change because I wanted to keep the diffs narrow and easy to review. A follow-on renaming change should be trivial if/when we can agree on what the type should be called at this point. Alternatively, we could simply bake the functionality of `StringRepresentationCache` into he IR deserialiation logic itself, since that is the only code using it.
Diffstat (limited to 'source/core')
-rw-r--r--source/core/core.vcxproj2
-rw-r--r--source/core/core.vcxproj.filters6
-rw-r--r--source/core/slang-object-scope-manager.cpp23
-rw-r--r--source/core/slang-object-scope-manager.h67
4 files changed, 0 insertions, 98 deletions
diff --git a/source/core/core.vcxproj b/source/core/core.vcxproj
index 636edb46a..8c4e7753c 100644
--- a/source/core/core.vcxproj
+++ b/source/core/core.vcxproj
@@ -189,7 +189,6 @@
<ClInclude Include="slang-math.h" />
<ClInclude Include="slang-memory-arena.h" />
<ClInclude Include="slang-nvrtc-compiler.h" />
- <ClInclude Include="slang-object-scope-manager.h" />
<ClInclude Include="slang-offset-container.h" />
<ClInclude Include="slang-platform.h" />
<ClInclude Include="slang-process-util.h" />
@@ -225,7 +224,6 @@
<ClCompile Include="slang-io.cpp" />
<ClCompile Include="slang-memory-arena.cpp" />
<ClCompile Include="slang-nvrtc-compiler.cpp" />
- <ClCompile Include="slang-object-scope-manager.cpp" />
<ClCompile Include="slang-offset-container.cpp" />
<ClCompile Include="slang-platform.cpp" />
<ClCompile Include="slang-random-generator.cpp" />
diff --git a/source/core/core.vcxproj.filters b/source/core/core.vcxproj.filters
index 49d8a1065..312c24b17 100644
--- a/source/core/core.vcxproj.filters
+++ b/source/core/core.vcxproj.filters
@@ -66,9 +66,6 @@
<ClInclude Include="slang-nvrtc-compiler.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="slang-object-scope-manager.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="slang-offset-container.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -170,9 +167,6 @@
<ClCompile Include="slang-nvrtc-compiler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="slang-object-scope-manager.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="slang-offset-container.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/source/core/slang-object-scope-manager.cpp b/source/core/slang-object-scope-manager.cpp
deleted file mode 100644
index 2e7b7dfe3..000000000
--- a/source/core/slang-object-scope-manager.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "slang-object-scope-manager.h"
-
-namespace Slang {
-
-void ObjectScopeManager::_releaseAll()
-{
- RefObject*const* objs = m_objs.begin();
- const Index numObjs = m_objs.getCount();
- for (Index i = 0; i < numObjs; ++i)
- {
- objs[i]->decreaseReference();
- }
-}
-
-void ObjectScopeManager::clear()
-{
- _releaseAll();
- // Free the memory as well as resizing
- m_objs = List<RefObject*>();
-}
-
-} // namespace Slang
-
diff --git a/source/core/slang-object-scope-manager.h b/source/core/slang-object-scope-manager.h
deleted file mode 100644
index 9930e46ea..000000000
--- a/source/core/slang-object-scope-manager.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef SLANG_CORE_OBJECT_SCOPE_MANAGER_H
-#define SLANG_CORE_OBJECT_SCOPE_MANAGER_H
-
-#include "slang-smart-pointer.h"
-#include "slang-list.h"
-
-namespace Slang {
-
-/** Keep objects added in scope.
-
-This is currently about the most simple implementation possible. Objects are added to a list
-which members are released when ObjectScopeManager loses scope, or clear is called.
-
-The same object can be added multiple times. This implementation will just add the same object
-multiple times. A more complex implementation might notice that the object is already in scope
-and not add a reference.
-
-Another potential improvement would be to hold the pointers in a MemoryArena. Doing so would remove
-the requirement of a List of contiguous memory.
-
-In implementations that can hold multiple references to the same thing, we may want to add some
-garbage collection to remove repeat references.
-*/
-struct ObjectScopeManager
-{
-public:
-
- /// Add an object which will be kept in scope until manager is destroyed
- SLANG_INLINE RefObject* add(RefObject* obj);
- /// Add an object, where it may be nullptr. If it null its a no-op
- SLANG_INLINE RefObject* addMaybeNull(RefObject* obj);
-
- /// Clear the contents
- void clear();
-
- /// Dtor
- ~ObjectScopeManager() { _releaseAll(); }
-
-protected:
- void _releaseAll();
-
- List<RefObject*> m_objs;
-};
-
-// ---------------------------------------------------------------------------
-RefObject* ObjectScopeManager::addMaybeNull(RefObject* obj)
-{
- if (obj)
- {
- obj->addReference();
- m_objs.add(obj);
- }
- return obj;
-}
-
-// ---------------------------------------------------------------------------
-RefObject* ObjectScopeManager::add(RefObject* obj)
-{
- SLANG_ASSERT(obj);
- obj->addReference();
- m_objs.add(obj);
- return obj;
-}
-
-} // namespace Slang
-
-#endif // SLANG_OBJECT_SCOPE_MANAGER_H