本文整理汇总了C#中ILCompiler.DependencyAnalysis.NodeFactory类的典型用法代码示例。如果您正苦于以下问题:C# NodeFactory类的具体用法?C# NodeFactory怎么用?C# NodeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeFactory类属于ILCompiler.DependencyAnalysis命名空间,在下文中一共展示了NodeFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
var builder = new ObjectDataBuilder(factory);
// These need to be aligned the same as methods because they show up in same contexts
builder.RequireAlignment(factory.Target.MinimumFunctionAlignment);
builder.DefinedSymbols.Add(this);
MethodDesc canonMethod = Method.GetCanonMethodTarget(CanonicalFormKind.Specific);
// Pointer to the canonical body of the method
builder.EmitPointerReloc(factory.MethodEntrypoint(canonMethod));
// Find out what's the context to use
ISymbolNode contextParameter;
if (canonMethod.RequiresInstMethodDescArg())
{
contextParameter = factory.MethodGenericDictionary(Method);
}
else
{
Debug.Assert(canonMethod.RequiresInstMethodTableArg());
// Ask for a constructed type symbol because we need the vtable to get to the dictionary
contextParameter = factory.ConstructedTypeSymbol(Method.OwningType);
}
// The next entry is a pointer to the pointer to the context to be used for the canonical method
// TODO: in multi-module, this points to the import cell, and is no longer this weird pointer
builder.EmitPointerReloc(factory.Indirection(contextParameter));
return builder.ToObjectData();
}
开发者ID:nattress,项目名称:corert,代码行数:34,代码来源:FatFunctionPointerNode.cs
示例2: EmitCode
protected override void EmitCode(NodeFactory factory, ref X64Emitter encoder, bool relocsOnly)
{
AddrMode thisPtr = new AddrMode(
Register.RegDirect | encoder.TargetRegister.Arg0, null, 0, 0, AddrModeSize.Int64);
encoder.EmitADD(ref thisPtr, (sbyte)factory.Target.PointerSize);
encoder.EmitJMP(factory.MethodEntrypoint(_target));
}
开发者ID:tijoytom,项目名称:corert,代码行数:7,代码来源:X64UnboxingStubNode.cs
示例3: OutputRelatedType
protected override void OutputRelatedType(NodeFactory factory, ref ObjectDataBuilder objData)
{
//
// Cloned types use the related type field to point via an IAT slot at their true implementation
//
objData.EmitPointerReloc(factory.NecessaryTypeSymbol(_type));
}
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:ClonedConstructedEETypeNode.cs
示例4: GetCompilationRoots
private static IEnumerable<ICompilationRootProvider> GetCompilationRoots(IEnumerable<ICompilationRootProvider> existingRoots, NodeFactory factory)
{
yield return new CppCodegenCompilationRootProvider(factory.TypeSystemContext);
foreach (var existingRoot in existingRoots)
yield return existingRoot;
}
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:CppCodegenCompilation.cs
示例5: ExternEETypeSymbolNode
public ExternEETypeSymbolNode(NodeFactory factory, TypeDesc type)
: base("__EEType_" + NodeFactory.NameMangler.GetMangledTypeName(type))
{
_type = type;
EETypeNode.CheckCanGenerateEEType(factory, type);
}
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:ExternEETypeSymbolNode.cs
示例6: Compilation
protected Compilation(
DependencyAnalyzerBase<NodeFactory> dependencyGraph,
NodeFactory nodeFactory,
IEnumerable<ICompilationRootProvider> compilationRoots,
NameMangler nameMangler,
Logger logger)
{
_dependencyGraph = dependencyGraph;
_nodeFactory = nodeFactory;
_nameMangler = nameMangler;
_logger = logger;
_dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
NodeFactory.AttachToDependencyGraph(_dependencyGraph);
// TODO: hacky static field
NodeFactory.NameMangler = nameMangler;
var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);
foreach (var rootProvider in compilationRoots)
rootProvider.AddCompilationRoots(rootingService);
_typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(nodeFactory.CompilationModuleGroup.GeneratedAssembly.GetGlobalModuleType());
PInvokeILProvider = new PInvokeILProvider(new PInvokeILEmitterConfiguration(!nodeFactory.CompilationModuleGroup.IsSingleFileCompilation));
_methodILCache = new ILProvider(PInvokeILProvider);
}
开发者ID:justinvp,项目名称:corert,代码行数:27,代码来源:Compilation.cs
示例7: 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 });
ObjectDataBuilder builder = new ObjectDataBuilder(factory);
foreach (var mappingEntry in factory.MetadataManager.GetTypeDefinitionMapping())
{
if (!factory.CompilationModuleGroup.ContainsType(mappingEntry.Entity))
continue;
var node = factory.ConstructedTypeSymbol(mappingEntry.Entity) as EETypeNode;
if (node.Marked)
{
// TODO: this format got very inefficient due to not being able to use RVAs
// replace with a hash table
builder.EmitPointerReloc(node);
builder.EmitInt(mappingEntry.MetadataHandle);
if (factory.Target.PointerSize == 8)
builder.EmitInt(0); // Pad
}
}
_endSymbol.SetSymbolOffset(builder.CountBytes);
builder.DefinedSymbols.Add(this);
builder.DefinedSymbols.Add(_endSymbol);
return builder.ToObjectData();
}
开发者ID:nguerrera,项目名称:corert,代码行数:35,代码来源:TypeMetadataMapNode.cs
示例8: Create
/// <summary>
/// Constructs a new instance of <see cref="DelegateCreationInfo"/> set up to construct a delegate of type
/// '<paramref name="delegateType"/>' pointing to '<paramref name="targetMethod"/>'.
/// </summary>
public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targetMethod, NodeFactory factory)
{
var context = (CompilerTypeSystemContext)delegateType.Context;
var systemDelegate = targetMethod.Context.GetWellKnownType(WellKnownType.MulticastDelegate).BaseType;
int paramCountTargetMethod = targetMethod.Signature.Length;
if (!targetMethod.Signature.IsStatic)
{
paramCountTargetMethod++;
}
DelegateInfo delegateInfo = context.GetDelegateInfo(delegateType.GetTypeDefinition());
int paramCountDelegateClosed = delegateInfo.Signature.Length + 1;
bool closed = false;
if (paramCountDelegateClosed == paramCountTargetMethod)
{
closed = true;
}
else
{
Debug.Assert(paramCountDelegateClosed == paramCountTargetMethod + 1);
}
if (targetMethod.Signature.IsStatic)
{
MethodDesc invokeThunk;
if (!closed)
{
// Open delegate to a static method
invokeThunk = delegateInfo.Thunks[DelegateThunkKind.OpenStaticThunk];
}
else
{
// Closed delegate to a static method (i.e. delegate to an extension method that locks the first parameter)
invokeThunk = delegateInfo.Thunks[DelegateThunkKind.ClosedStaticThunk];
}
var instantiatedDelegateType = delegateType as InstantiatedType;
if (instantiatedDelegateType != null)
invokeThunk = context.GetMethodForInstantiatedType(invokeThunk, instantiatedDelegateType);
// We use InitializeClosedStaticThunk for both because RyuJIT generates same code for both,
// but passes null as the first parameter for the open one.
return new DelegateCreationInfo(
factory.MethodEntrypoint(systemDelegate.GetKnownMethod("InitializeClosedStaticThunk", null)),
factory.MethodEntrypoint(targetMethod),
factory.MethodEntrypoint(invokeThunk));
}
else
{
if (!closed)
throw new NotImplementedException("Open instance delegates");
bool useUnboxingStub = targetMethod.OwningType.IsValueType;
return new DelegateCreationInfo(
factory.MethodEntrypoint(systemDelegate.GetKnownMethod("InitializeClosedInstance", null)),
factory.MethodEntrypoint(targetMethod, useUnboxingStub));
}
}
开发者ID:nguerrera,项目名称:corert,代码行数:64,代码来源:DelegateCreationInfo.cs
示例9: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory);
builder.Alignment = factory.Target.PointerSize;
if (_sorter != null)
_nestedNodesList.Sort(_sorter);
builder.DefinedSymbols.Add(_startSymbol);
foreach (EmbeddedObjectNode node in _nestedNodesList)
{
if (!relocsOnly)
node.Offset = builder.CountBytes;
node.EncodeData(ref builder, factory, relocsOnly);
if (node is ISymbolNode)
{
builder.DefinedSymbols.Add((ISymbolNode)node);
}
}
_endSymbol.SetSymbolOffset(builder.CountBytes);
builder.DefinedSymbols.Add(_endSymbol);
ObjectData objData = builder.ToObjectData();
return objData;
}
开发者ID:huamichaelchen,项目名称:corert,代码行数:26,代码来源:ArrayOfEmbeddedDataNode.cs
示例10: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory);
builder.Alignment = factory.Target.PointerSize;
builder.DefinedSymbols.Add(this);
_items.Sort((x, y) => Comparer<int>.Default.Compare((int)x.Id, (int)y.Id));
// ReadyToRunHeader.Magic
builder.EmitInt((int)(ReadyToRunHeaderConstants.Signature));
// ReadyToRunHeader.MajorVersion
builder.EmitShort((short)(ReadyToRunHeaderConstants.CurrentMajorVersion));
builder.EmitShort((short)(ReadyToRunHeaderConstants.CurrentMinorVersion));
// ReadyToRunHeader.Flags
builder.EmitInt(0);
// ReadyToRunHeader.NumberOfSections
var sectionCountReservation = builder.ReserveShort();
// ReadyToRunHeader.EntrySize
builder.EmitByte((byte)(8 + 2 * factory.Target.PointerSize));
// ReadyToRunHeader.EntryType
builder.EmitByte(1);
int count = 0;
foreach (var item in _items)
{
// Skip empty entries
if (item.Node.ShouldSkipEmittingObjectNode(factory))
continue;
builder.EmitInt((int)item.Id);
ModuleInfoFlags flags = 0;
if (item.EndSymbol != null)
{
flags |= ModuleInfoFlags.HasEndPointer;
}
builder.EmitInt((int)flags);
builder.EmitPointerReloc(item.StartSymbol);
if (item.EndSymbol != null)
{
builder.EmitPointerReloc(item.EndSymbol);
}
else
{
builder.EmitZeroPointer();
}
count++;
}
builder.EmitShort(sectionCountReservation, checked((short)count));
return builder.ToObjectData();
}
开发者ID:krytarowski,项目名称:corert,代码行数:60,代码来源:ReadyToRunHeaderNode.cs
示例11: 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");
}
}
return dependencies;
}
开发者ID:krytarowski,项目名称:corert,代码行数:25,代码来源:MethodCodeNode.cs
示例12: Compilation
protected Compilation(
DependencyAnalyzerBase<NodeFactory> dependencyGraph,
NodeFactory nodeFactory,
IEnumerable<ICompilationRootProvider> compilationRoots,
NameMangler nameMangler,
Logger logger)
{
_dependencyGraph = dependencyGraph;
_nodeFactory = nodeFactory;
_nameMangler = nameMangler;
_logger = logger;
_dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
NodeFactory.AttachToDependencyGraph(_dependencyGraph);
// TODO: hacky static field
NodeFactory.NameMangler = nameMangler;
var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);
foreach (var rootProvider in compilationRoots)
rootProvider.AddCompilationRoots(rootingService);
// TODO: use a better owning type for multi-file friendliness
_typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(TypeSystemContext.SystemModule.GetGlobalModuleType());
}
开发者ID:davidwrighton,项目名称:corert,代码行数:25,代码来源:Compilation.cs
示例13: EmitDispatchMap
void EmitDispatchMap(ref ObjectDataBuilder builder, NodeFactory factory)
{
var entryCountReservation = builder.ReserveInt();
int entryCount = 0;
for (int interfaceIndex = 0; interfaceIndex < _type.RuntimeInterfaces.Length; interfaceIndex++)
{
var interfaceType = _type.RuntimeInterfaces[interfaceIndex];
Debug.Assert(interfaceType.IsInterface);
IReadOnlyList<MethodDesc> virtualSlots = factory.VTable(interfaceType).Slots;
for (int interfaceMethodSlot = 0; interfaceMethodSlot < virtualSlots.Count; interfaceMethodSlot++)
{
MethodDesc declMethod = virtualSlots[interfaceMethodSlot];
var implMethod = _type.GetClosestDefType().ResolveInterfaceMethodToVirtualMethodOnType(declMethod);
// Interface methods first implemented by a base type in the hierarchy will return null for the implMethod (runtime interface
// dispatch will walk the inheritance chain).
if (implMethod != null)
{
builder.EmitShort(checked((short)interfaceIndex));
builder.EmitShort(checked((short)interfaceMethodSlot));
builder.EmitShort(checked((short)VirtualMethodSlotHelper.GetVirtualMethodSlot(factory, implMethod)));
entryCount++;
}
}
}
builder.EmitInt(entryCountReservation, entryCount);
}
开发者ID:tijoytom,项目名称:corert,代码行数:31,代码来源:InterfaceDispatchMapNode.cs
示例14: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder objData = new ObjectDataBuilder(factory);
// The interface dispatch cell has an alignment requirement of 2 * [Pointer size] as part of the
// synchronization mechanism of the two values in the runtime.
objData.Alignment = _targetMethod.Context.Target.PointerSize * 2;
objData.DefinedSymbols.Add(this);
objData.EmitPointerReloc(factory.ExternSymbol("RhpInitialDynamicInterfaceDispatch"));
// The second cell field uses the two lower-order bits to communicate the contents.
// We add 1 to signal IDC_CachePointerIsInterfacePointer. See src\Native\Runtime\inc\rhbinder.h.
objData.EmitPointerReloc(factory.NecessaryTypeSymbol(_targetMethod.OwningType), 1);
// End the run of dispatch cells
objData.EmitZeroPointer();
// Avoid consulting VTable slots until they're guaranteed complete during final data emission
if (!relocsOnly)
{
int interfaceMethodSlot = VirtualMethodSlotHelper.GetVirtualMethodSlot(factory, _targetMethod);
if (factory.Target.PointerSize == 8)
{
objData.EmitLong(interfaceMethodSlot);
}
else
{
throw new NotImplementedException();
}
}
return objData.ToObjectData();
}
开发者ID:krytarowski,项目名称:corert,代码行数:33,代码来源:InterfaceDispatchCellNode.cs
示例15: EncodeData
public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly)
{
dataBuilder.EmitZeroPointer(); // Sync block
DefType systemStringType = factory.TypeSystemContext.GetWellKnownType(WellKnownType.String);
//
// The GC requires a direct reference to frozen objects' EETypes. If System.String will be compiled into a separate
// binary, it must be cloned into this one.
//
if (factory.CompilationModuleGroup.ShouldReferenceThroughImportTable(systemStringType))
{
dataBuilder.EmitPointerReloc(factory.ConstructedClonedTypeSymbol(systemStringType));
}
else
{
dataBuilder.EmitPointerReloc(factory.ConstructedTypeSymbol(systemStringType));
}
dataBuilder.EmitInt(_data.Length);
foreach (char c in _data)
{
dataBuilder.EmitShort((short)c);
}
// Null-terminate for friendliness with interop
dataBuilder.EmitShort(0);
}
开发者ID:krytarowski,项目名称:corert,代码行数:30,代码来源:FrozenStringNode.cs
示例16: ComputeNonRelocationBasedDependencies
protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory)
{
return new DependencyList
{
new DependencyListEntry(GetDictionaryLayout(factory), "Dictionary layout"),
};
}
开发者ID:stephentoub,项目名称:corert,代码行数:7,代码来源:GenericDictionaryNode.cs
示例17: InstantiateDependencies
public IEnumerable<DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
{
switch (_id)
{
case ReadyToRunHelperId.GetGCStaticBase:
case ReadyToRunHelperId.GetThreadStaticBase:
{
// If the type has a lazy static constructor, we also need the non-GC static base
// because that's where the class constructor context is.
TypeDesc type = (TypeDesc)_target;
if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
{
return new[] {
new DependencyListEntry(
factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency"),
new DependencyListEntry(
_lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency") };
}
}
break;
}
// All other generic lookups just depend on the thing they point to
return new[] { new DependencyListEntry(
_lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency") };
}
开发者ID:stephentoub,项目名称:corert,代码行数:30,代码来源:ReadyToRunGenericHelperNode.cs
示例18: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory);
builder.DefinedSymbols.Add(this);
//
// Emit a MethodFixupCell struct
//
// Address (to be fixed up at runtime)
builder.EmitZeroPointer();
// Entry point name
if (factory.Target.IsWindows && _entryPointName.StartsWith("#", StringComparison.OrdinalIgnoreCase))
{
// Windows-specific ordinal import
// CLR-compatible behavior: Strings that can't be parsed as a signed integer are treated as zero.
int entrypointOrdinal;
if (!int.TryParse(_entryPointName.Substring(1), out entrypointOrdinal))
entrypointOrdinal = 0;
// CLR-compatible behavior: Ordinal imports are 16-bit on Windows. Discard rest of the bits.
builder.EmitNaturalInt((ushort)entrypointOrdinal);
}
else
{
// Import by name
builder.EmitPointerReloc(factory.ConstantUtf8String(_entryPointName));
}
// Module fixup cell
builder.EmitPointerReloc(factory.PInvokeModuleFixup(_moduleName));
return builder.ToObjectData();
}
开发者ID:justinvp,项目名称:corert,代码行数:35,代码来源:PInvokeMethodFixupNode.cs
示例19: GetNumberOfBaseSlots
private static int GetNumberOfBaseSlots(NodeFactory factory, TypeDesc owningType)
{
int baseSlots = 0;
TypeDesc baseType = owningType.BaseType;
while (baseType != null)
{
// Normalize the base type. Necessary to make this work with the lazy vtable slot
// concept - if we start with a canonical type, the base type could end up being
// something like Base<__Canon, string>. We would get "0 slots used" for weird
// base types like this.
baseType = baseType.ConvertToCanonForm(CanonicalFormKind.Specific);
// For types that have a generic dictionary, the introduced virtual method slots are
// prefixed with a pointer to the generic dictionary.
if (baseType.HasGenericDictionarySlot())
baseSlots++;
IReadOnlyList<MethodDesc> baseVirtualSlots = factory.VTable(baseType).Slots;
baseSlots += baseVirtualSlots.Count;
baseType = baseType.BaseType;
}
return baseSlots;
}
开发者ID:nattress,项目名称:corert,代码行数:26,代码来源:VirtualMethodCallHelper.cs
示例20: BuildDispatchMap
DispatchMapEntry[] BuildDispatchMap(NodeFactory factory)
{
ArrayBuilder<DispatchMapEntry> dispatchMapEntries = new ArrayBuilder<DispatchMapEntry>();
for (int i = 0; i < _type.RuntimeInterfaces.Length; i++)
{
var interfaceType = _type.RuntimeInterfaces[i];
Debug.Assert(interfaceType.IsInterface);
List<MethodDesc> virtualSlots;
factory.VirtualSlots.TryGetValue(interfaceType, out virtualSlots);
if (virtualSlots != null)
{
for (int j = 0; j < virtualSlots.Count; j++)
{
MethodDesc declMethod = virtualSlots[j];
var implMethod = VirtualFunctionResolution.ResolveInterfaceMethodToVirtualMethodOnType(declMethod, _type.GetClosestMetadataType());
// Interface methods first implemented by a base type in the hierarchy will return null for the implMethod (runtime interface
// dispatch will walk the inheritance chain).
if (implMethod != null)
{
var entry = new DispatchMapEntry();
entry.InterfaceIndex = checked((short)i);
entry.InterfaceMethodSlot = checked((short)j);
entry.ImplementationMethodSlot = checked((short)VirtualMethodSlotHelper.GetVirtualMethodSlot(factory, implMethod));
dispatchMapEntries.Add(entry);
}
}
}
}
return dispatchMapEntries.ToArray();
}
开发者ID:TerabyteX,项目名称:corert,代码行数:35,代码来源:InterfaceDispatchMapNode.cs
注:本文中的ILCompiler.DependencyAnalysis.NodeFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论