From e13fdd8fe19f248a925232e918501f55dafa40d8 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 11 Feb 2019 10:54:58 -0500 Subject: MemoryArena rewindability/Improved IRInst construction (#837) * Make MemoryArena rewindable. * Add test for rewinding MemoryArena * Use memory rewinding in IRInst lookup instead of malloc/free. * Small tidy. * Don't bother recreating instruction if after lookup it's found it's new. * Fix 32 bit signed compare issue. --- tools/slang-test/unit-test-memory-arena.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/slang-test/unit-test-memory-arena.cpp b/tools/slang-test/unit-test-memory-arena.cpp index 1b09ae9e7..e993d4f7a 100644 --- a/tools/slang-test/unit-test-memory-arena.cpp +++ b/tools/slang-test/unit-test-memory-arena.cpp @@ -169,6 +169,21 @@ static void memoryArenaUnitTest() arena.reset(); blocks.Clear(); } + else if (var == 3) + { + arena.rewindToCursor(nullptr); + blocks.Clear(); + } + else if (var == 4) + { + // Rewind to a random position + int rewindIndex = randGen.nextInt32UpTo(int32_t(blocks.Count())); + // rewind to this block + arena.rewindToCursor(blocks[rewindIndex].m_data); + // All the blocks (includign this one) and now deallocated + blocks.SetSize(rewindIndex); + + } else { size_t usedMemory = arena.calcTotalMemoryUsed(); @@ -247,7 +262,13 @@ static void memoryArenaUnitTest() } } } + } + { + // Do lots of allocations and test out rewind + + + } } -SLANG_UNIT_TEST("MemoryArena", memoryArenaUnitTest); \ No newline at end of file +SLANG_UNIT_TEST("MemoryArena", memoryArenaUnitTest); -- cgit v1.2.3