本文整理汇总了C#中Mosa.Compiler.TypeSystem.RuntimeMethod类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeMethod类的具体用法?C# RuntimeMethod怎么用?C# RuntimeMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeMethod类属于Mosa.Compiler.TypeSystem命名空间,在下文中一共展示了RuntimeMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCaseMethodCompiler
/// <summary>
/// Initializes a new instance of the <see cref="TestCaseMethodCompiler"/> class.
/// </summary>
/// <param name="compiler">The compiler.</param>
/// <param name="method">The method.</param>
public TestCaseMethodCompiler(TestCaseCompiler compiler, RuntimeMethod method)
: base(compiler, method, null)
{
// Populate the pipeline
Pipeline.AddRange(new IMethodCompilerStage[] {
new CILDecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandAssignmentStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
new LocalVariablePromotionStage(),
new EdgeSplitStage(),
new DominanceCalculationStage(),
new PhiPlacementStage(),
new EnterSSAStage(),
new SSAOptimizations(),
new LeaveSSA(),
new StackLayoutStage(),
new PlatformIntrinsicTransformationStage(),
new PlatformStubStage(),
new LoopAwareBlockOrderStage(),
//new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything
new CodeGenerationStage(),
});
}
示例2: Parse
/// <summary>
/// Parses the specified attribute blob and instantiates the attribute.
/// </summary>
/// <param name="blob">The BLOB.</param>
/// <param name="attributeCtor">The constructor of the attribute.</param>
/// <returns>
/// The fully instantiated and initialized attribute.
/// </returns>
public static object[] Parse(byte[] blob, RuntimeMethod attributeCtor)
{
if (blob == null)
throw new ArgumentException(@"Invalid attribute blob token.", @"attributeBlob");
if (blob.Length == 0)
return null;
// Create a binary reader for the blob
using (var reader = new BinaryReader(new MemoryStream(blob), Encoding.UTF8))
{
var prologue = reader.ReadUInt16();
Debug.Assert(prologue == ATTRIBUTE_BLOB_PROLOGUE, @"Attribute prologue doesn't match.");
if (prologue != ATTRIBUTE_BLOB_PROLOGUE)
throw new ArgumentException(@"Invalid custom attribute blob.", "attributeBlob");
var parameters = attributeCtor.Parameters.Count;
object[] args = new object[parameters];
for (int idx = 0; idx < parameters; idx++)
args[idx] = ParseFixedArg(reader, attributeCtor.Signature.Parameters[idx]);
// Create the attribute instance
return args;
}
}
示例3: RuntimeAttribute
/// <summary>
/// Initializes a new instance of the <see cref="RuntimeAttribute"/> class.
/// </summary>
/// <param name="typeModule">The type module.</param>
/// <param name="ctor">The ctor.</param>
/// <param name="ctorMethod">The ctor method.</param>
/// <param name="blobIndex">Index of the blob.</param>
public RuntimeAttribute(ITypeModule typeModule, Token ctor, RuntimeMethod ctorMethod, HeapIndexToken blobIndex)
{
this.typeModule = typeModule;
this.ctorMethod = ctorMethod;
this.ctor = ctor;
this.blobIndex = blobIndex;
}
示例4: TestCaseMethodCompiler
public TestCaseMethodCompiler(TestCaseAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
: base(assemblyCompiler, type, method, null, compilationScheduler)
{
// Populate the pipeline
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new DecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandDeterminationStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
//new CILLeakGuardStage() { MustThrowCompilationException = true },
new EdgeSplitStage(),
new DominanceCalculationStage(),
new PhiPlacementStage(),
new EnterSSAStage(),
new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding),
new ConstantFoldingStage() ,
new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding),
new LeaveSSA(),
new StrengthReductionStage(),
new StackLayoutStage(),
new PlatformStubStage(),
//new BlockReductionStage(),
//new LoopAwareBlockOrderStage(),
new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything
//new BasicBlockOrderStage()
new CodeGenerationStage(),
});
}
示例5: ExplorerMethodCompiler
public ExplorerMethodCompiler(ExplorerAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, CompilerOptions compilerOptions)
: base(assemblyCompiler, type, method, null, compilationScheduler)
{
// Populate the pipeline
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new DecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandDeterminationStage(),
//new SingleUseMarkerStage(),
//new OperandUsageAnalyzerStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
(compilerOptions.EnableSSA) ? new EdgeSplitStage() : null,
(compilerOptions.EnableSSA) ? new DominanceCalculationStage() : null,
(compilerOptions.EnableSSA) ? new PhiPlacementStage() : null,
(compilerOptions.EnableSSA) ? new EnterSSAStage() : null,
(compilerOptions.EnableSSA) ? new SSAOptimizations() : null,
//(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding) : null,
//(compilerOptions.EnableSSA) ? new ConstantFoldingStage() : null,
//(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding) : null,
(compilerOptions.EnableSSA) ? new LeaveSSA() : null,
new StrengthReductionStage(),
new StackLayoutStage(),
new PlatformStubStage(),
//new LoopAwareBlockOrderStage(),
new SimpleTraceBlockOrderStage(),
//new SimpleRegisterAllocatorStage(),
new CodeGenerationStage(),
});
}
示例6: AotMethodCompiler
/// <summary>
/// Initializes a new instance of the <see cref="AotMethodCompiler"/> class.
/// </summary>
/// <param name="compiler">The compiler.</param>
/// <param name="method">The method.</param>
public AotMethodCompiler(BaseCompiler compiler, RuntimeMethod method)
: base(compiler, method, null)
{
var compilerOptions = compiler.CompilerOptions;
Pipeline.AddRange(new IMethodCompilerStage[] {
new CILDecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandAssignmentStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
new IRCheckStage(),
(compilerOptions.EnableSSA && compilerOptions.EnableSSAOptimizations) ? new LocalVariablePromotionStage() : null,
(compilerOptions.EnableSSA) ? new EdgeSplitStage() : null,
(compilerOptions.EnableSSA) ? new DominanceCalculationStage() : null,
(compilerOptions.EnableSSA) ? new PhiPlacementStage() : null,
(compilerOptions.EnableSSA) ? new EnterSSAStage() : null,
(compilerOptions.EnableSSA && compilerOptions.EnableSSAOptimizations) ? new SSAOptimizations() : null,
(compilerOptions.EnableSSA) ? new LeaveSSA() : null,
new StackLayoutStage(),
new PlatformIntrinsicTransformationStage(),
new PlatformStubStage(),
new LoopAwareBlockOrderStage(),
//new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(),
//new LocalCSE(),
new CodeGenerationStage(),
//new RegisterUsageAnalyzerStage(),
});
}
示例7: CompileMethod
void ICompilationScheduler.TrackMethodInvoked(RuntimeMethod method)
{
methodsInvoked.AddIfNew(method);
if (compileAllMethods)
CompileMethod(method);
}
示例8: MemberOperand
/// <summary>
/// Initializes a new instance of the <see cref="MemberOperand"/> class.
/// </summary>
/// <param name="method">The method to reference.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="method"/> is null.</exception>
public MemberOperand(RuntimeMethod method)
: base(null, BuiltInSigType.IntPtr, IntPtr.Zero)
{
if (method == null)
throw new ArgumentNullException(@"method");
this.member = method;
}
示例9: GetPlugMethod
/// <summary>
/// Gets the plug.
/// </summary>
/// <param name="method">The method.</param>
/// <returns></returns>
public RuntimeMethod GetPlugMethod(RuntimeMethod method)
{
RuntimeMethod plug = null;
plugMethods.TryGetValue(method, out plug);
return plug;
}
示例10: ArgumentNullException
void ICompilationSchedulerStage.ScheduleMethodForCompilation(RuntimeMethod method)
{
if (method == null)
throw new ArgumentNullException(@"method");
if (!method.IsGeneric)
{
Trace(CompilerEvent.SchedulingMethod, method.ToString());
methodQueue.Enqueue(method);
}
}
示例11: LinkerMethodCompiler
/// <summary>
/// Initializes a new instance of the <see cref="LinkerMethodCompiler"/> class.
/// </summary>
/// <param name="assemblyCompiler">The assembly compiler executing this method compiler.</param>
/// <param name="method">The metadata of the method to compile.</param>
/// <param name="instructionSet">The instruction set.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="assemblyCompiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
public LinkerMethodCompiler(AssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeMethod method, InstructionSet instructionSet)
: base(assemblyCompiler, method.DeclaringType, method, instructionSet, compilationScheduler)
{
this.CreateBlock(-1, 0);
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new SimpleTraceBlockOrderStage(),
new PlatformStubStage(),
new CodeGenerationStage(),
});
assemblyCompiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
}
示例12: LinkerMethodCompiler
/// <summary>
/// Initializes a new instance of the <see cref="LinkerMethodCompiler"/> class.
/// </summary>
/// <param name="compiler">The assembly compiler executing this method compiler.</param>
/// <param name="method">The metadata of the method to compile.</param>
/// <param name="instructionSet">The instruction set.</param>
public LinkerMethodCompiler(BaseCompiler compiler, RuntimeMethod method, InstructionSet instructionSet)
: base(compiler, method, instructionSet)
{
BasicBlocks.CreateBlock(BasicBlock.PrologueLabel, 0);
BasicBlocks.AddHeaderBlock(BasicBlocks.PrologueBlock);
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new LoopAwareBlockOrderStage(),
new PlatformStubStage(),
new CodeGenerationStage(),
});
compiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
}
示例13: HasGenericParameters
/// <summary>
/// Determines if the given method is a method
/// of a generic class that uses a generic parameter.
/// </summary>
/// <param name="method">The method to check</param>
/// <returns>True if the method relies upon generic parameters</returns>
public static bool HasGenericParameters(RuntimeMethod method)
{
// Check return type
if (IsGenericParameter(method.Signature.ReturnType))
return true;
// Check parameters
foreach (SigType parameter in method.Signature.Parameters)
{
if (IsGenericParameter(parameter))
return true;
}
return false;
}
示例14: Run
public static void Run(IInternalTrace internalLog, IPipelineStage stage, RuntimeMethod method, InstructionSet instructionSet, BasicBlocks basicBlocks)
{
if (internalLog == null)
return;
if (internalLog.TraceListener == null)
return;
if (!internalLog.TraceFilter.IsMatch(method, stage.Name))
return;
StringBuilder text = new StringBuilder();
// Line number
int index = 1;
text.AppendLine(String.Format("IR representation of method {0} after stage {1}:", method, stage.Name));
text.AppendLine();
if (basicBlocks.Count > 0)
{
foreach (BasicBlock block in basicBlocks)
{
text.AppendFormat("Block #{0} - Label L_{1:X4}", index, block.Label);
if (basicBlocks.IsHeaderBlock(block))
text.Append(" [Header]");
text.AppendLine();
text.AppendFormat(" Prev: ");
text.AppendLine(ListBlocks(block.PreviousBlocks));
LogInstructions(text, new Context(instructionSet, block));
text.AppendFormat(" Next: ");
text.AppendLine(ListBlocks(block.NextBlocks));
text.AppendLine();
index++;
}
}
else
{
LogInstructions(text, new Context(instructionSet, 0));
}
internalLog.TraceListener.SubmitInstructionTraceInformation(method, stage.Name, text.ToString());
}
示例15: CompileMethod
private void CompileMethod(RuntimeMethod method)
{
Trace(CompilerEvent.CompilingMethod, method.ToString());
using (IMethodCompiler mc = compiler.CreateMethodCompiler(this, method.DeclaringType, method))
{
mc.Compile();
//try
//{
// mc.Compile();
//}
//catch (Exception e)
//{
// HandleCompilationException(e);
// throw;
//}
}
}