Skip to content

Commit

Permalink
WIP - Method Scanner (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Feb 3, 2019
1 parent a4bf9f2 commit 30f4fd1
Show file tree
Hide file tree
Showing 54 changed files with 1,185 additions and 591 deletions.
366 changes: 342 additions & 24 deletions Source/MOSA.sln

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Source/Mosa.Compiler.Framework/BaseCodeEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void EmitRelative32(Operand symbolOperand)
LinkType.RelativeOffset,
PatchType.I4,
MethodName,
(int)CodeStream.Position,
CodeStream.Position,
symbolOperand.Name,
-4
);
Expand All @@ -258,7 +258,7 @@ public void EmitRelative64(Operand symbolOperand)
LinkType.RelativeOffset,
PatchType.I8,
MethodName,
(int)CodeStream.Position,
CodeStream.Position,
symbolOperand.Name,
-8
);
Expand Down
4 changes: 2 additions & 2 deletions Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ protected TraceLog CreateTraceLog(int traceLevel = 0)
{
bool active = IsTraceable(traceLevel);

var traceLog = new TraceLog(TraceType.DebugTrace, MethodCompiler.Method, FormattedStageName, active);
var traceLog = new TraceLog(TraceType.MethodDebug, MethodCompiler.Method, FormattedStageName, active);

if (active)
traceLogs.Add(traceLog);
Expand All @@ -673,7 +673,7 @@ public TraceLog CreateTraceLog(int traceLevel, string section)
{
bool active = IsTraceable(traceLevel);

var traceLog = new TraceLog(TraceType.DebugTrace, MethodCompiler.Method, FormattedStageName, section, active);
var traceLog = new TraceLog(TraceType.MethodDebug, MethodCompiler.Method, FormattedStageName, section, active);

if (active)
traceLogs.Add(traceLog);
Expand Down
4 changes: 3 additions & 1 deletion Source/Mosa.Compiler.Framework/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void CompileMethod(MosaMethod method, BasicBlocks basicBlocks, int thread
methodCompiler.Compile();

NewCompilerTraceEvent(CompilerEvent.CompiledMethod, method.FullName, threadID);
CompilerTrace.TraceListener.OnMethodcompiled(method);
CompilerTrace.TraceListener.OnMethodCompiled(method);
}

private MethodCompiler GetMethodCompiler(MosaMethod method, BasicBlocks basicBlocks, int threadID = 0)
Expand Down Expand Up @@ -457,6 +457,8 @@ internal void PostCompile()
NewCompilerTraceEvent(CompilerEvent.PostCompileStageEnd, stage.Name);
}

MethodScanner.Complete();

// Sum up the counters
foreach (var methodData in CompilerData.MethodData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public sealed class DebugFileGenerationStage : BaseCompilerStage
{
#region Data Members

public string DebugFile { get; set; }

/// <summary>
/// Holds the text writer used to emit the map file.
/// </summary>
Expand All @@ -24,17 +22,12 @@ public sealed class DebugFileGenerationStage : BaseCompilerStage

#endregion Data Members

protected override void Setup()
{
DebugFile = CompilerOptions.DebugFile;
}

protected override void RunPostCompile()
{
if (string.IsNullOrEmpty(DebugFile))
if (string.IsNullOrEmpty(CompilerOptions.DebugFile))
return;

using (writer = new StreamWriter(DebugFile))
using (writer = new StreamWriter(CompilerOptions.DebugFile))
{
EmitSections();
EmitSymbols();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.Compiler.Framework.Linker;
using System.IO;

namespace Mosa.Compiler.Framework.CompilerStages
Expand All @@ -21,6 +22,11 @@ protected override void RunPostCompile()
{
Linker.Emit(file);
}

Compiler.GlobalCounters.Update("Linker.Text", (int)Linker.LinkerSections[(int)SectionKind.Text].Size);
Compiler.GlobalCounters.Update("Linker.Data", (int)Linker.LinkerSections[(int)SectionKind.Data].Size);
Compiler.GlobalCounters.Update("Linker.ROData", (int)Linker.LinkerSections[(int)SectionKind.ROData].Size);
Compiler.GlobalCounters.Update("Linker.BSS", (int)Linker.LinkerSections[(int)SectionKind.BSS].Size);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public sealed class MapFileGenerationStage : BaseCompilerStage
{
#region Data Members

public string MapFile { get; set; }

/// <summary>
/// Holds the text writer used to emit the map file.
/// </summary>
Expand All @@ -25,15 +23,14 @@ public sealed class MapFileGenerationStage : BaseCompilerStage

protected override void Setup()
{
MapFile = CompilerOptions.MapFile;
}

protected override void RunPostCompile()
{
if (string.IsNullOrEmpty(MapFile))
if (string.IsNullOrEmpty(CompilerOptions.MapFile))
return;

using (writer = new StreamWriter(MapFile))
using (writer = new StreamWriter(CompilerOptions.MapFile))
{
// Emit map file header
writer.WriteLine(CompilerOptions.OutputFile);
Expand Down

0 comments on commit 30f4fd1

Please sign in to comment.