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/ir.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/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 83735d6df..6b2939987 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -763,7 +763,7 @@ namespace Slang // Create an IR instruction/value and initialize it. // - // In this case `argCount` and `args` represnt the + // In this case `argCount` and `args` represent the // arguments *after* the type (which is a mandatory // argument for all instructions). template<typename T> @@ -791,9 +791,10 @@ namespace Slang } SLANG_ASSERT(module); - T* inst = (T*)module->memoryPool.allocZero(size); - new(inst)T(); + T* inst = (T*)module->memoryArena.allocateAndZero(size); + // TODO: Do we need to run ctor after zeroing? + new(inst)T(); inst->operandCount = (uint32_t)(fixedArgCount + varArgCount); @@ -833,7 +834,6 @@ namespace Slang operand++; } } - module->irObjectsToFree.Add(inst); return inst; } @@ -2285,7 +2285,7 @@ namespace Slang IRLayoutDecoration* IRBuilder::addLayoutDecoration(IRInst* inst, Layout* layout) { auto decoration = addDecoration<IRLayoutDecoration>(inst); - decoration->layout = layout; + decoration->layout = addRefObjectToFree(layout); return decoration; } @@ -2534,7 +2534,7 @@ namespace Slang dump(context, "\n"); dumpIndent(context); dump(context, "[target("); - dump(context, decoration->targetName.Buffer()); + dump(context, StringRepresentation::getData(decoration->targetName)); dump(context, ")]"); } break; @@ -2910,11 +2910,6 @@ namespace Slang ff->debugValidate(); } - void IRInst::dispose() - { - IRObject::dispose(); - } - // Insert this instruction into the same basic block // as `other`, right before it. void IRInst::insertBefore(IRInst* other) @@ -4223,7 +4218,7 @@ namespace Slang continue; auto decoration = (IRTargetIntrinsicDecoration*) dd; - if(decoration->targetName == targetName) + if(String(decoration->targetName) == targetName) return decoration; } @@ -4469,7 +4464,7 @@ namespace Slang if(!decoration) continue; - if(decoration->definition != "EmitVertex()") + if(StringRepresentation::asSlice(decoration->definition) != UnownedStringSlice::fromLiteral("EmitVertex()")) { continue; } @@ -5425,7 +5420,7 @@ namespace Slang continue; auto decoration = (IRTargetDecoration*) dd; - if(decoration->targetName == targetName) + if(String(decoration->targetName) == targetName) return TargetSpecializationLevel::specializedForTarget; result = TargetSpecializationLevel::specializedForOtherTarget; |
