-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Improved Method Inlining * Skips emitting methods for methods that were inlined * Uses the final inline variation code
- Loading branch information
Showing
72 changed files
with
1,274 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Source/Mosa.Compiler.Framework/CompilerStages/DevirtualizationStage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using Mosa.Compiler.Framework.IR; | ||
using Mosa.Compiler.Framework.Trace; | ||
using Mosa.Compiler.MosaTypeSystem; | ||
|
||
namespace Mosa.Compiler.Framework.CompilerStages | ||
{ | ||
/// <summary> | ||
/// Devirtualization Stage | ||
/// </remarks> | ||
/// <seealso cref="Mosa.Compiler.Framework.BaseCompilerStage" /> | ||
public sealed class DevirtualizationStage : BaseCompilerStage | ||
{ | ||
private Counter DevirtualizedMethodsCount = new Counter("DevirtualizationStage.DevirtualizedMethodsCount"); | ||
|
||
#region Overrides | ||
|
||
protected override void Setup() | ||
{ | ||
foreach (var type in TypeSystem.AllTypes) | ||
{ | ||
// If type has an interface - don't consider either type for devirtualization | ||
// FUTURE: be more specific and check each method | ||
if (HasInterface(type)) | ||
continue; | ||
|
||
foreach (var method in type.Methods) | ||
{ | ||
if (method.IsStatic || !method.IsVirtual) | ||
continue; | ||
|
||
if (!method.HasImplementation && method.IsAbstract) | ||
continue; | ||
|
||
if (TypeLayout.IsMethodOverridden(method)) | ||
continue; | ||
|
||
var methodData = Compiler.GetMethodData(method); | ||
|
||
methodData.IsDevirtualized = true; | ||
DevirtualizedMethodsCount++; | ||
} | ||
} | ||
} | ||
|
||
protected override void Finalization() | ||
{ | ||
if (CompilerOptions.EnableStatistics) | ||
{ | ||
//var log = new TraceLog(TraceType.MethodCounters, null, string.Empty); | ||
//log.Log(MethodData.Counters.Export()); | ||
//CompilerTrace.PostTraceLog(log); | ||
} | ||
} | ||
|
||
#endregion Overrides | ||
|
||
private bool HasInterface(MosaType type) | ||
{ | ||
var baseType = type; | ||
|
||
while (baseType != null) | ||
{ | ||
foreach (var interfaceType in baseType.Interfaces) | ||
{ | ||
return true; | ||
} | ||
|
||
baseType = baseType.BaseType; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.