本文整理汇总了C#中ILCompiler.DependencyAnalysis.NodeFactory.FatFunctionPointer方法的典型用法代码示例。如果您正苦于以下问题:C# NodeFactory.FatFunctionPointer方法的具体用法?C# NodeFactory.FatFunctionPointer怎么用?C# NodeFactory.FatFunctionPointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.DependencyAnalysis.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.FatFunctionPointer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
// This node does not trigger generation of other nodes.
if (relocsOnly)
return new ObjectData(Array.Empty<byte>(), Array.Empty<Relocation>(), 1, new ISymbolNode[] { this });
var writer = new NativeWriter();
var typeMapHashTable = new VertexHashtable();
Section hashTableSection = writer.NewSection();
hashTableSection.Place(typeMapHashTable);
// Get a list of all methods that have a method body and metadata from the metadata manager.
foreach (var mappingEntry in factory.MetadataManager.GetMethodMapping())
{
MethodDesc method = mappingEntry.Entity;
// The current format requires us to have an EEType for the owning type. We might want to lift this.
if (!factory.MetadataManager.TypeGeneratesEEType(method.OwningType))
continue;
// We have a method body, we have a metadata token, but we can't get an invoke stub. Bail.
if (!factory.MetadataManager.HasReflectionInvokeStub(method))
continue;
InvokeTableFlags flags = 0;
if (method.HasInstantiation)
flags |= InvokeTableFlags.IsGenericMethod;
if (method.GetCanonMethodTarget(CanonicalFormKind.Specific).RequiresInstArg())
flags |= InvokeTableFlags.RequiresInstArg;
// TODO: better check for default public(!) constructor
if (method.IsConstructor && method.Signature.Length == 0)
flags |= InvokeTableFlags.IsDefaultConstructor;
// TODO: HasVirtualInvoke
if (!method.IsAbstract)
flags |= InvokeTableFlags.HasEntrypoint;
// Once we have a true multi module compilation story, we'll need to start emitting entries where this is not set.
flags |= InvokeTableFlags.HasMetadataHandle;
// TODO: native signature for P/Invokes and NativeCallable methods
if (method.IsRawPInvoke() || method.IsNativeCallable)
continue;
// Grammar of an entry in the hash table:
// Flags + DeclaringType + MetadataHandle/NameAndSig + Entrypoint + DynamicInvokeMethod + [NumGenericArgs + GenericArgs]
Vertex vertex = writer.GetUnsignedConstant((uint)flags);
if ((flags & InvokeTableFlags.HasMetadataHandle) != 0)
{
// Only store the offset portion of the metadata handle to get better integer compression
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant((uint)(mappingEntry.MetadataHandle & MetadataGeneration.MetadataOffsetMask)));
}
else
{
// TODO: no MD handle case
}
// Go with a necessary type symbol. It will be upgraded to a constructed one if a constructed was emitted.
IEETypeNode owningTypeSymbol = factory.NecessaryTypeSymbol(method.OwningType);
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(owningTypeSymbol)));
if ((flags & InvokeTableFlags.HasEntrypoint) != 0)
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(
factory.MethodEntrypoint(method.GetCanonMethodTarget(CanonicalFormKind.Specific)))));
}
// TODO: data to generate the generic dictionary with the type loader
MethodDesc invokeStubMethod = factory.MetadataManager.GetReflectionInvokeStub(method);
MethodDesc canonInvokeStubMethod = invokeStubMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);
if (invokeStubMethod != canonInvokeStubMethod)
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(factory.FatFunctionPointer(invokeStubMethod), FatFunctionPointerConstants.Offset) << 1));
}
else
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(factory.MethodEntrypoint(invokeStubMethod)) << 1));
}
if ((flags & InvokeTableFlags.IsGenericMethod) != 0)
{
if ((flags & InvokeTableFlags.RequiresInstArg) == 0 || (flags & InvokeTableFlags.HasEntrypoint) == 0)
{
VertexSequence args = new VertexSequence();
for (int i = 0; i < method.Instantiation.Length; i++)
{
uint argId = _externalReferences.GetIndex(factory.NecessaryTypeSymbol(method.Instantiation[i]));
args.Append(writer.GetUnsignedConstant(argId));
//.........这里部分代码省略.........
示例2: ComputeNonRelocationBasedDependencies
protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory)
{
DependencyList dependencies = null;
TypeDesc owningType = _method.OwningType;
if (factory.TypeSystemContext.HasEagerStaticConstructor(owningType))
{
if (dependencies == null)
dependencies = new DependencyList();
dependencies.Add(factory.EagerCctorIndirection(owningType.GetStaticConstructor()), "Eager .cctor");
}
if (_ehInfo != null && _ehInfo.Relocs != null)
{
if (dependencies == null)
dependencies = new DependencyList();
foreach (Relocation reloc in _ehInfo.Relocs)
{
dependencies.Add(reloc.Target, "reloc");
}
}
// Reflection invoke stub handling is here because in the current reflection model we reflection-enable
// all methods that are compiled. Ideally the list of reflection enabled methods should be known before
// we even start the compilation process (with the invocation stubs being compilation roots like any other).
// The existing model has it's problems: e.g. the invocability of the method depends on inliner decisions.
if (factory.MetadataManager.HasReflectionInvokeStub(_method)
&& !_method.IsCanonicalMethod(CanonicalFormKind.Any) /* Shared generics handled in the shadow concrete method node */)
{
if (dependencies == null)
dependencies = new DependencyList();
MethodDesc invokeStub = factory.MetadataManager.GetReflectionInvokeStub(Method);
MethodDesc canonInvokeStub = invokeStub.GetCanonMethodTarget(CanonicalFormKind.Specific);
if (invokeStub != canonInvokeStub)
dependencies.Add(new DependencyListEntry(factory.FatFunctionPointer(invokeStub), "Reflection invoke"));
else
dependencies.Add(new DependencyListEntry(factory.MethodEntrypoint(invokeStub), "Reflection invoke"));
}
return dependencies;
}
示例3: GetTarget
public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
{
MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);
return factory.FatFunctionPointer(instantiatedMethod);
}
示例4: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory);
// If the type has a class constructor, its non-GC statics section is prefixed
// by System.Runtime.CompilerServices.StaticClassConstructionContext struct.
if (factory.TypeSystemContext.HasLazyStaticConstructor(_type))
{
int alignmentRequired = Math.Max(_type.NonGCStaticFieldAlignment, GetClassConstructorContextAlignment(_type.Context.Target));
int classConstructorContextStorageSize = GetClassConstructorContextStorageSize(factory.Target, _type);
builder.RequireAlignment(alignmentRequired);
Debug.Assert(classConstructorContextStorageSize >= GetClassConstructorContextSize(_type.Context.Target));
// Add padding before the context if alignment forces us to do so
builder.EmitZeros(classConstructorContextStorageSize - GetClassConstructorContextSize(_type.Context.Target));
// Emit the actual StaticClassConstructionContext
MethodDesc cctorMethod = _type.GetStaticConstructor();
MethodDesc canonCctorMethod = cctorMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);
if (cctorMethod != canonCctorMethod)
builder.EmitPointerReloc(factory.FatFunctionPointer(cctorMethod), FatFunctionPointerConstants.Offset);
else
builder.EmitPointerReloc(factory.MethodEntrypoint(cctorMethod));
builder.EmitZeroPointer();
}
else
{
builder.RequireAlignment(_type.NonGCStaticFieldAlignment);
}
builder.EmitZeros(_type.NonGCStaticFieldSize);
builder.DefinedSymbols.Add(this);
return builder.ToObjectData();
}