本文整理汇总了C#中RuntimeMethod类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeMethod类的具体用法?C# RuntimeMethod怎么用?C# RuntimeMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeMethod类属于命名空间,在下文中一共展示了RuntimeMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCaseMethodCompiler
public TestCaseMethodCompiler(IAssemblyLinker linker, IArchitecture architecture, IMetadataModule module, RuntimeType type, RuntimeMethod method)
: base(linker, architecture, module, type, method)
{
// Populate the pipeline
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new DecodingStage(),
new BasicBlockBuilderStage(),
new OperandDeterminationStage(),
new InstructionLogger(),
//new ConstantFoldingStage(),
new CILTransformationStage(),
//new InstructionLogger(),
//InstructionStatisticsStage.Instance,
//new DominanceCalculationStage(),
//new EnterSSA(),
//new ConstantPropagationStage(),
//new ConstantFoldingStage(),
//new LeaveSSA(),
new StackLayoutStage(),
new PlatformStubStage(),
new InstructionLogger(),
//new BlockReductionStage(),
new LoopAwareBlockOrderStage(),
//new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything
//new BasicBlockOrderStage()
new CodeGenerationStage(),
//new InstructionLogger(),
});
}
示例2: ArgumentNullException
void IJitService.SetupJit(RuntimeMethod method)
{
// Check preconditions
if (null == method)
throw new ArgumentNullException(@"method");
Debug.Assert(MethodImplAttributes.IL == (method.ImplAttributes & MethodImplAttributes.IL), @"Non-IL method passed to IJitService.SetupJit");
if (MethodImplAttributes.IL != (method.ImplAttributes & MethodImplAttributes.IL))
throw new ArgumentException(@"Non-IL method passed to IJitService.SetupJit.", @"method");
// Code the appropriate trampoline
/*
if (method.DeclaringType.IsGeneric) {
FIXME: method.DeclaringType is always null right now
* the loader doesn't initialize these properly.
}
*/
if (method.IsGeneric)
{
// Emit a generic call trampoline
method.Address = EmitGenericMethodTrampoline();
}
else
{
// A normal call trampoline
method.Address = EmitStandardTrampoline(method);
}
}
示例3: CreateMethodCompiler
public override MethodCompilerBase CreateMethodCompiler(RuntimeType type, RuntimeMethod method)
{
IArchitecture arch = this.Architecture;
MethodCompilerBase mc = new TestCaseMethodCompiler(this.Pipeline.Find<IAssemblyLinker>(), this.Architecture, this.Assembly, type, method);
arch.ExtendMethodCompilerPipeline(mc.Pipeline);
return mc;
}
示例4: SimpleJitMethodCompiler
public SimpleJitMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, Stream codeStream, ITypeSystem typeSystem)
: base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, typeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
{
if (codeStream == null)
throw new ArgumentNullException(@"codeStream");
this.codeStream = codeStream;
}
示例5: 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(new SigType(CilElementType.I), null, IntPtr.Zero)
{
if (method == null)
throw new ArgumentNullException(@"method");
this.member = method;
}
示例6: MethodCompiler
public MethodCompiler(IAssemblyLinker linker, IArchitecture architecture, IMetadataModule module, RuntimeType type, RuntimeMethod method, Stream codeStream)
: base(linker, architecture, module, type, method)
{
if (null == codeStream)
throw new ArgumentNullException(@"codeStream");
_codeStream = codeStream;
}
示例7: CreateMethodCompiler
/// <summary>
/// Creates a method compiler
/// </summary>
/// <param name="type">The type.</param>
/// <param name="method">The method to compile.</param>
/// <returns>
/// An instance of a MethodCompilerBase for the given type/method pair.
/// </returns>
public override MethodCompilerBase CreateMethodCompiler(RuntimeType type, RuntimeMethod method)
{
MethodCompilerBase mc = new AotMethodCompiler(
this,
type,
method
);
this.Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
return mc;
}
示例8: 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>
/// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
public LinkerMethodCompiler(AssemblyCompiler compiler, RuntimeMethod method, InstructionSet instructionSet)
: base(compiler.Pipeline.Find<IAssemblyLinker>(), compiler.Architecture, compiler.Assembly, method.DeclaringType, method)
{
InstructionSet = instructionSet;
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new BasicBlockBuilderStage(),
new CodeGenerationStage(),
});
compiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
}
示例9: Call
/// <summary>
/// Calls the specified target.
/// </summary>
/// <param name="target">The target.</param>
public void Call(RuntimeMethod target)
{
_linker.Link(
LinkType.RelativeOffset | LinkType.I4,
_compiler.Method,
(int)(_codeStream.Position - _codeStreamBasePosition) - 4,
(int)(_codeStream.Position - _codeStreamBasePosition),
target,
IntPtr.Zero
);
}
示例10: CreateMethodCompiler
/// <summary>
/// Creates a method compiler
/// </summary>
/// <param name="type">The type.</param>
/// <param name="method">The method to compile.</param>
/// <returns>
/// An instance of a MethodCompilerBase for the given type/method pair.
/// </returns>
public override IMethodCompiler CreateMethodCompiler(ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
{
IMethodCompiler mc = new AotMethodCompiler(
this,
compilationScheduler,
type,
method
);
this.Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
return mc;
}
示例11: 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>
/// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
public LinkerMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeMethod method, InstructionSet instructionSet)
: base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, compiler.Assembly, method.DeclaringType, method)
{
this.InstructionSet = instructionSet;
this.CreateBlock(-1, 0);
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new SimpleTraceBlockOrderStage(),
new PlatformStubStage(),
new CodeGenerationStage(),
});
compiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
}
示例12: ScheduleMethodForCompilation
public void ScheduleMethodForCompilation(RuntimeMethod method)
{
if (method == null)
throw new ArgumentNullException(@"method");
if (method.IsGeneric == false)
{
Console.WriteLine(@"Scheduling method {1}.{0} for compilation.", method.Name, method.DeclaringType.FullName);
Debug.WriteLine(String.Format(@"Scheduling method {1}.{0} for compilation.", method.Name, method.DeclaringType.FullName));
this.methodQueue.Enqueue(method);
}
}
示例13: Parse
/// <summary>
/// Parses the specified attribute blob and instantiates the attribute.
/// </summary>
/// <param name="module">The metadata module, which contains the attribute blob.</param>
/// <param name="attributeBlob">The attribute blob token.</param>
/// <param name="attributeCtor">The constructor of the attribute.</param>
/// <returns>The fully instantiated and initialized attribute.</returns>
/// <exception cref="System.ArgumentException"><paramref name="attributeBlob"/> is invalid.</exception>
/// <exception cref="System.ArgumentNullException"><paramref name="module"/> is null or <paramref name="attributeCtor"/> is null.</exception>
public static object Parse(IMetadataModule module, TokenTypes attributeBlob, RuntimeMethod attributeCtor)
{
// Return value
object result;
// Try to load the blob from the module
byte[] blob = module.Metadata.ReadBlob(attributeBlob);
if (null != blob)
{
if (0 != blob.Length)
{
// Create a binary reader for the blob
using (BinaryReader reader = new BinaryReader(new MemoryStream(blob), Encoding.UTF8))
{
ushort prologue = reader.ReadUInt16();
Debug.Assert(ATTRIBUTE_BLOB_PROLOGUE == prologue, @"Attribute prologue doesn't match.");
if (prologue != ATTRIBUTE_BLOB_PROLOGUE)
throw new ArgumentException(@"Invalid custom attribute blob.", "attributeBlob");
// Fixed argument list of the ctor
SigType[] paramSig = attributeCtor.Signature.Parameters;
IList<RuntimeParameter> parameters = attributeCtor.Parameters;
object[] args = new object[parameters.Count];
for (int idx = 0; idx < parameters.Count; idx++)
args[idx] = ParseFixedArg(module, reader, paramSig[idx]);
// Create the attribute instance
result = CreateAttribute(attributeCtor, args);
// Are there any named args?
ushort numNamed = reader.ReadUInt16();
for (ushort idx = 0; idx < numNamed; idx++)
{
// FIXME: Process the named arguments
Trace.WriteLine(@"Skipping named argument of an attribute.");
}
}
}
else
{
result = CreateAttribute(attributeCtor, null);
}
}
else
{
throw new ArgumentException(@"Invalid attribute blob token.", @"attributeBlob");
}
return result;
}
示例14: 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;
}
示例15: AotMethodCompiler
/// <summary>
/// Initializes a new instance of the <see cref="AotMethodCompiler"/> class.
/// </summary>
public AotMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
: base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
{
this.assemblyCompiler = compiler;
this.Pipeline.AddRange(
new IMethodCompilerStage[]
{
new DecodingStage(),
//InstructionLogger.Instance,
new BasicBlockBuilderStage(),
//InstructionLogger.Instance,
new OperandDeterminationStage(),
InstructionLogger.Instance,
StaticAllocationResolutionStageWrapper.Instance,
//InstructionLogger.Instance,
new CILTransformationStage(),
InstructionLogger.Instance,
//InstructionStatisticsStage.Instance,
//new DominanceCalculationStage(),
//InstructionLogger.Instance,
//new EnterSSA(),
//InstructionLogger.Instance,
//new ConstantPropagationStage(),
//InstructionLogger.Instance,
//new ConstantFoldingStage(),
//new StrengthReductionStage(),
//InstructionLogger.Instance,
//new LeaveSSA(),
//InstructionLogger.Instance,
new StackLayoutStage(),
//InstructionLogger.Instance,
new PlatformStubStage(),
InstructionLogger.Instance,
//new BlockReductionStage(),
new LoopAwareBlockOrderStage(),
//InstructionLogger.Instance,
//new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(),
//new LocalCSE(),
new CodeGenerationStage(),
});
}