Replace LinkedList by IntrusiveList to avoid allocations on JIT (#931)

* Replace LinkedList by IntrusiveList to avoid allocations on JIT

* Fix wrong replacements
This commit is contained in:
gdkchan 2020-02-17 18:30:54 -03:00 committed by GitHub
parent e9a37ca6a8
commit e5f78fb1d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 365 additions and 198 deletions

View file

@ -12,7 +12,7 @@ namespace ARMeilleure.Translation
{
private Dictionary<Operand, BasicBlock> _irLabels;
private LinkedList<BasicBlock> _irBlocks;
private IntrusiveList<BasicBlock> _irBlocks;
private BasicBlock _irBlock;
@ -22,7 +22,7 @@ namespace ARMeilleure.Translation
{
_irLabels = new Dictionary<Operand, BasicBlock>();
_irBlocks = new LinkedList<BasicBlock>();
_irBlocks = new IntrusiveList<BasicBlock>();
_needsNewBlock = true;
}
@ -508,7 +508,8 @@ namespace ARMeilleure.Translation
if (_irLabels.TryGetValue(label, out BasicBlock nextBlock))
{
nextBlock.Index = _irBlocks.Count;
nextBlock.Node = _irBlocks.AddLast(nextBlock);
_irBlocks.AddLast(nextBlock);
NextBlock(nextBlock);
}
@ -524,7 +525,7 @@ namespace ARMeilleure.Translation
{
BasicBlock block = new BasicBlock(_irBlocks.Count);
block.Node = _irBlocks.AddLast(block);
_irBlocks.AddLast(block);
NextBlock(block);
}
@ -556,7 +557,7 @@ namespace ARMeilleure.Translation
public ControlFlowGraph GetControlFlowGraph()
{
return new ControlFlowGraph(_irBlocks.First.Value, _irBlocks);
return new ControlFlowGraph(_irBlocks.First, _irBlocks);
}
}
}