Permalink
Browse files

- General improvements

  • Loading branch information...
tgiphil committed Sep 23, 2018
1 parent 6d35de9 commit ebc228a5e0b6ce9c967afcd629c1642c575e0eb9
@@ -243,13 +243,13 @@ public void Execute()
SubmitTraceLogs(traceLogs);
Finish();
foreach (var counter in Counters)
{
UpdateCounter(counter);
}
Finish();
//if (!MethodCompiler.IsStopped)
//{
// Debug.Assert(BasicBlocks.RuntimeValidation());
@@ -729,16 +729,6 @@ public void UpdateCounter(Counter counter)
MethodData.Counters.UpdateNoLock(counter.Name, counter.Count);
}
/// <summary>
/// Updates the counter.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="count">The count.</param>
public void UpdateCounter(string name, int count)
{
MethodData.Counters.UpdateNoLock(name, count);
}
#region Helpers
/// <summary>
@@ -27,6 +27,11 @@ public void Set(int count)
Count = count;
}
public void Set(bool condition, int truevalue = 1, int falsevalue = 0)
{
Count = condition ? truevalue : falsevalue;
}
public static Counter operator ++(Counter counter)
{
counter.Count++;
@@ -14,16 +14,16 @@ namespace Mosa.Compiler.Framework.Stages
/// </summary>
public class CodeGenerationStage : BaseMethodCompilerStage
{
private Counter GeneratedInstructionCount = new Counter("CodeGeneration.GeneratedInstructions");
private Counter GeneratedBlockCount = new Counter("CodeGeneration.GeneratedBlocks");
#region Data Members
/// <summary>
/// Holds the stream, where code is emitted to.
/// </summary>
protected Stream codeStream;
private int generatedInstructionCount = 0;
private int generatedBlockCount = 0;
#endregion Data Members
#region Properties
@@ -55,10 +55,10 @@ public CodeGenerationStage(bool emitBinary)
#endregion Construction
protected override void Setup()
protected override void Initialize()
{
generatedInstructionCount = 0;
generatedBlockCount = 0;
Register(GeneratedInstructionCount);
Register(GeneratedBlockCount);
}
protected override void Run()
@@ -86,9 +86,6 @@ protected override void Run()
// Emit the method epilogue
EndGenerate();
UpdateCounter("CodeGeneration.GeneratedInstructions", generatedInstructionCount);
UpdateCounter("CodeGeneration.GeneratedBlocks", generatedBlockCount);
}
protected override void Finish()
@@ -149,7 +146,7 @@ protected virtual void EmitInstructions()
baseInstruction.Emit(node, CodeEmitter);
generatedInstructionCount++;
GeneratedInstructionCount++;
if (trace.Active) trace.Log(node.Offset.ToString() + " - /0x" + node.Offset.ToString("X") + " : " + node);
}
@@ -162,7 +159,7 @@ protected virtual void EmitInstructions()
block.Last.Offset = CodeEmitter.CurrentPosition;
BlockEnd(block);
generatedBlockCount++;
GeneratedBlockCount++;
}
MethodCompiler.MethodData.AddLabelRegion(labelCurrent, labelStart, CodeEmitter.CurrentPosition - labelStart);
@@ -11,8 +11,16 @@ namespace Mosa.Compiler.Framework.Stages
/// <seealso cref="Mosa.Compiler.Framework.BaseCodeTransformationStage" />
public sealed class DevirtualizeCallStage : BaseCodeTransformationStage
{
private Counter DevirtualizedCount = new Counter("Devirtualize.Calls");
private TraceLog trace;
private int devirtualizedCount = 0;
protected override void Initialize()
{
base.Initialize();
Register(DevirtualizedCount);
}
protected override void PopulateVisitationDictionary()
{
@@ -23,13 +31,10 @@ protected override void PopulateVisitationDictionary()
protected override void Setup()
{
trace = CreateTraceLog();
devirtualizedCount = 0;
}
protected override void Finish()
{
UpdateCounter("Devirtualize.Calls", devirtualizedCount);
trace = null;
}
@@ -48,7 +53,7 @@ private void CallVirtual(InstructionNode node)
if (trace.Active) trace.Log("De-virtualize: " + method);
devirtualizedCount++;
DevirtualizedCount++;
node.SetInstruction(IRInstruction.CallStatic, node.Result, symbol, operands);
}
Oops, something went wrong.

0 comments on commit ebc228a

Please sign in to comment.