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

@ -16,17 +16,17 @@ namespace ARMeilleure.CodeGen.Optimizations
{
modified = false;
foreach (BasicBlock block in cfg.Blocks)
for (BasicBlock block = cfg.Blocks.First; block != null; block = block.ListNext)
{
LinkedListNode<Node> node = block.Operations.First;
Node node = block.Operations.First;
while (node != null)
{
LinkedListNode<Node> nextNode = node.Next;
Node nextNode = node.ListNext;
bool isUnused = IsUnused(node.Value);
bool isUnused = IsUnused(node);
if (!(node.Value is Operation operation) || isUnused)
if (!(node is Operation operation) || isUnused)
{
if (isUnused)
{
@ -80,13 +80,11 @@ namespace ARMeilleure.CodeGen.Optimizations
}
}
private static void RemoveNode(BasicBlock block, LinkedListNode<Node> llNode)
private static void RemoveNode(BasicBlock block, Node node)
{
// Remove a node from the nodes list, and also remove itself
// from all the use lists on the operands that this node uses.
block.Operations.Remove(llNode);
Node node = llNode.Value;
block.Operations.Remove(node);
for (int index = 0; index < node.SourcesCount; index++)
{