diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-09-14 14:16:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-14 14:16:28 -0400 |
| commit | 3c505c22673701339d35eb2151f01c16eb3c78c3 (patch) | |
| tree | ff21543fcc846c693cbb6aba43a4e8ae9918f600 /source/slang/memory_pool.cpp | |
| parent | e1c934972509f4bbd2c05affe565f91e7a1e6c16 (diff) | |
Improvements around IR representation and memory usage (#635)
* * Remove dispose from IRInst
* Use MemoryArena instead of MemoryPool
* Make all IRInst not require Dtor - by having ref counted array store ptrs that need freeing
* Increase block size - typically compilation is 2Mb of IR space(!)
* Fix issues around StringRepresentation::equal because null has special meaning.
* Don't bother to construct as String to compare StringRepresentation, just used UnownedStringSlice.
* Added fromLiteral support to UnownedStringSlice and use instead of strlen version.
* Use more conventional way to test StringRepresentation against a String.
* Fix gcc/clang template problem with cast.
Diffstat (limited to 'source/slang/memory_pool.cpp')
| -rw-r--r-- | source/slang/memory_pool.cpp | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/source/slang/memory_pool.cpp b/source/slang/memory_pool.cpp deleted file mode 100644 index 884c9cfe4..000000000 --- a/source/slang/memory_pool.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "memory_pool.h" - -namespace Slang -{ - const size_t kPoolSegmentSize = 4 << 20; // use 4MB segments - - struct MemoryPoolSegment - { - unsigned char* data = nullptr; - size_t allocPtr = 0; - MemoryPoolSegment* nextSegment = nullptr; - }; - - MemoryPool::~MemoryPool() - { - while (curSegment) - { - auto nxtSegment = curSegment->nextSegment; - free(curSegment->data); - delete curSegment; - curSegment = nxtSegment; - } - } - - void newSegment(MemoryPool* pool) - { - auto seg = new MemoryPoolSegment(); - seg->nextSegment = pool->curSegment; - seg->data = (unsigned char*)malloc(kPoolSegmentSize); - pool->curSegment = seg; - } - - void * MemoryPool::alloc(size_t size) - { - assert(size < kPoolSegmentSize); - // ensure there is a segment available - if (!curSegment) - newSegment(this); - if (curSegment->allocPtr + size > kPoolSegmentSize) - newSegment(this); - // alloc memory from current segment - void* rs = curSegment->data + curSegment->allocPtr; - curSegment->allocPtr += size; - return rs; - } - void * MemoryPool::allocZero(size_t size) - { - auto rs = alloc(size); - memset(rs, 0, size); - return rs; - } -} |
