Skip to content

Commit

Permalink
Merge pull request #603 from tgiphil/017-PriortyQueue
Browse files Browse the repository at this point in the history
- Switched to a real priority queue
  • Loading branch information
tgiphil committed Mar 3, 2019
2 parents b82d87e + d15ee71 commit 3dd005c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 111 deletions.
55 changes: 0 additions & 55 deletions Source/Mosa.Compiler.Common/SimplePriorityQueue.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<ItemGroup>
<Compile Include="LiveRangeTests.cs" />
<Compile Include="SparseBitArrayTests.cs" />
<Compile Include="SimplePriorityQueueTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
40 changes: 0 additions & 40 deletions Source/Mosa.Compiler.Framework.xUnit/SimplePriorityQueueTests.cs

This file was deleted.

3 changes: 3 additions & 0 deletions Source/Mosa.Compiler.Framework/Mosa.Compiler.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OptimizedPriorityQueue" Version="4.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mosa.Compiler.MosaTypeSystem\Mosa.Compiler.MosaTypeSystem.csproj" />
<ProjectReference Include="..\Mosa.Compiler.Common\Mosa.Compiler.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Mosa.Compiler.Framework.IR;
using Mosa.Compiler.Framework.Trace;
using Mosa.Compiler.MosaTypeSystem;
using Priority_Queue;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -33,7 +34,7 @@ public abstract class BaseRegisterAllocator
protected readonly List<ExtendedBlock> ExtendedBlocks;
protected readonly List<VirtualRegister> VirtualRegisters;

private readonly SimpleKeyPriorityQueue<LiveInterval> PriorityQueue;
private readonly SimplePriorityQueue<LiveInterval> PriorityQueue;
protected readonly List<LiveIntervalTrack> LiveIntervalTracks;

private readonly PhysicalRegister StackFrameRegister;
Expand Down Expand Up @@ -92,7 +93,7 @@ protected BaseRegisterAllocator(BasicBlocks basicBlocks, VirtualRegisters virtua
VirtualRegisters.Add(new VirtualRegister(virtualRegister));
}

PriorityQueue = new SimpleKeyPriorityQueue<LiveInterval>();
PriorityQueue = new SimplePriorityQueue<LiveInterval>();
SpilledIntervals = new List<LiveInterval>();

KillAll = new List<SlotIndex>();
Expand Down Expand Up @@ -634,9 +635,7 @@ private void ComputeLocalLiveSets()
liveGen.Set(index, true);

if (liveSetTrace.Active)
{
liveSetTrace.Log("GEN: " + index.ToString() + " " + op);
}
}
}

Expand Down Expand Up @@ -948,7 +947,7 @@ protected void AddPriorityQueue(LiveInterval liveInterval)
// priority is based on allocation stage (primary, lower first) and interval size (secondary, higher first)
int value = CalculatePriorityValue(liveInterval);

PriorityQueue.Enqueue(value, liveInterval);
PriorityQueue.Enqueue(liveInterval, value);
}

private void PopulatePriorityQueue()
Expand All @@ -975,7 +974,7 @@ private void PopulatePriorityQueue()

private void ProcessPriorityQueue()
{
while (!PriorityQueue.IsEmpty)
while (PriorityQueue.Count != 0)
{
var liveInterval = PriorityQueue.Dequeue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ protected override void CalculateSpillCost(LiveInterval liveInterval)
liveInterval.SpillValue = spillvalue;
}

protected override int CalculatePriorityValue(LiveInterval liveInterval)
{
return liveInterval.Length | ((int)((int)LiveInterval.AllocationStage.Max - liveInterval.Stage) << 28);
}

private bool PlaceLiveIntervalOnTrack(LiveInterval liveInterval, MoveHint[] hints)
{
if (hints == null)
Expand Down
8 changes: 4 additions & 4 deletions Source/Mosa.Compiler.Framework/Stages/InlineStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ protected override void Run()

Inline(callSiteNode, blocks);

if (!BasicBlocks.RuntimeValidation())
{
throw new CompilerException($"InlineStage: Block Validation after inlining: {invokedMethod} into {Method}");
}
//if (!BasicBlocks.RuntimeValidation())
//{
// throw new CompilerException($"InlineStage: Block Validation after inlining: {invokedMethod} into {Method}");
//}
}

InlinedMethodsCount.Set(1);
Expand Down

0 comments on commit 3dd005c

Please sign in to comment.