diff options
author | Fadi Hanna <fadim@microsoft.com> | 2017-05-19 03:04:28 +0300 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2017-05-19 03:04:28 +0300 |
commit | e0f9230083afc469a93a77668cab37ec3e36da46 (patch) | |
tree | 8c5e70b225dc3acd953b1620fe8bc00aeb7ce56b /src | |
parent | afd750916dd70dfee38042111322707ba599c65e (diff) |
Moving the TOC emitting logic to the ILCompiler side for ProjectX.
[tfs-changeset: 1658842]
Diffstat (limited to 'src')
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericLookupResult.cs | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericLookupResult.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericLookupResult.cs index 0fd1c94b0..2b0b548a1 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericLookupResult.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericLookupResult.cs @@ -21,6 +21,45 @@ namespace ILCompiler.DependencyAnalysis ConditionalIndirect, // The slot may be a direct pointer or an indirection cell, depending on the last digit } + // Represents a generic lookup within a canonical method body. + // TODO: unify with NativeFormat.FixupSignatureKind + public enum LookupResultType + { + Invalid, + EEType, // a type + UnwrapNullable, // a type (The type T described by a type spec that is generic over Nullable<T>) + NonGcStatic, // the non-gc statics of a type + GcStatic, // the gc statics of a type + Method, // a method + InterfaceDispatchCell, // the dispatch cell for calling an interface method + MethodDictionary, // a dictionary for calling a generic method + UnboxingStub, // the unboxing stub for a method + ArrayType, // an array of type + DefaultCtor, // default ctor of a type + TlsIndex, // tls index of a type + TlsOffset, // tls offset of a type + AllocObject, // the allocator of a type + GvmVtableOffset, // vtable offset of a generic virtual method + ProfileCounter, // profiling counter cell + MethodLdToken, // a ldtoken result for a method + FieldLdToken, // a ldtoken result for a field + Field, // a field descriptor + IsInst, // isinst helper + CastClass, // castclass helper + AllocArray, // the array allocator of a type + CheckArrayElementType, // check the array element type + TypeSize, // size of the type + FieldOffset, // field offset + CallingConvention, // CallingConventionConverterThunk + VtableOffset, // Offset of a virtual method into the type's vtable + Constrained, // ConstrainedCallDesc + } + + public interface IGenericLookupResultTocWriter + { + void WriteData(GenericLookupResultReferenceType referenceType, LookupResultType slotType, TypeSystemEntity context); + } + /// <summary> /// Represents the result of a generic lookup within a canonical method body. /// The concrete artifact the generic lookup will result in can only be determined after substituting @@ -56,6 +95,8 @@ namespace ILCompiler.DependencyAnalysis public abstract NativeLayoutVertexNode TemplateDictionaryNode(NodeFactory factory); + public abstract void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer); + // Call this api to get non-reloc dependencies that arise from use of a dictionary lookup public virtual IEnumerable<DependencyNodeCore<NodeFactory>> NonRelocDependenciesFromUsage(NodeFactory factory) { @@ -147,6 +188,11 @@ namespace ILCompiler.DependencyAnalysis } } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.EEType, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((TypeHandleGenericLookupResult)other)._type); @@ -206,6 +252,11 @@ namespace ILCompiler.DependencyAnalysis } } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.UnwrapNullable, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((UnwrapNullableTypeHandleGenericLookupResult)other)._type); @@ -254,6 +305,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.FieldOffsetDictionarySlot(_field); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.FieldOffset, _field); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_field, ((FieldOffsetGenericLookupResult)other)._field); @@ -314,6 +370,11 @@ namespace ILCompiler.DependencyAnalysis }; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.VtableOffset, _method); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_method, ((VTableOffsetGenericLookupResult)other)._method); @@ -354,6 +415,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.MethodLdTokenDictionarySlot(_method); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.MethodLdToken, _method); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_method, ((MethodHandleGenericLookupResult)other)._method); @@ -394,6 +460,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.FieldLdTokenDictionarySlot(_field); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.FieldLdToken, _field); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_field, ((FieldHandleGenericLookupResult)other)._field); @@ -446,6 +517,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.MethodDictionaryDictionarySlot(_method); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.MethodDictionary, _method); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_method, ((MethodDictionaryGenericLookupResult)other)._method); @@ -493,6 +569,11 @@ namespace ILCompiler.DependencyAnalysis (_method, unboxing: true, functionPointerTarget: factory.MethodEntrypoint(_method.GetCanonMethodTarget(CanonicalFormKind.Specific))); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.Method, _method); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { var otherEntry = (MethodEntryGenericLookupResult)other; @@ -558,6 +639,19 @@ namespace ILCompiler.DependencyAnalysis } } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + if (factory.Target.Abi == TargetAbi.CoreRT) + { + // TODO + throw new NotImplementedException(); + } + else + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.InterfaceDispatchCell, _method); + } + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_method, ((VirtualDispatchGenericLookupResult)other)._method); @@ -620,6 +714,19 @@ namespace ILCompiler.DependencyAnalysis } } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + if (factory.Target.Abi == TargetAbi.CoreRT) + { + // TODO + throw new NotImplementedException(); + } + else + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.InterfaceDispatchCell, _method); + } + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_method, ((VirtualResolveGenericLookupResult)other)._method); @@ -666,6 +773,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.NonGcStatic, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((TypeNonGCStaticBaseGenericLookupResult)other)._type); @@ -707,6 +819,12 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.NotSupportedDictionarySlot; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + // TODO + throw new NotImplementedException(); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((TypeThreadStaticBaseIndexGenericLookupResult)other)._type); @@ -753,6 +871,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.GcStatic, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((TypeGCStaticBaseGenericLookupResult)other)._type); @@ -798,6 +921,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.AllocObject, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((ObjectAllocatorGenericLookupResult)other)._type); @@ -844,6 +972,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.AllocArray, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((ArrayAllocatorGenericLookupResult)other)._type); @@ -889,6 +1022,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.CastClass, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((CastClassGenericLookupResult)other)._type); @@ -934,6 +1072,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.IsInst, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((IsInstGenericLookupResult)other)._type); @@ -978,6 +1121,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.TlsIndex, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((ThreadStaticIndexLookupResult)other)._type); @@ -1023,6 +1171,11 @@ namespace ILCompiler.DependencyAnalysis return GenericLookupResultReferenceType.Indirect; } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.TlsOffset, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((ThreadStaticOffsetLookupResult)other)._type); @@ -1075,6 +1228,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.DefaultConstructorDictionarySlot(_type); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.DefaultCtor, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((DefaultConstructorLookupResult)other)._type); @@ -1118,6 +1276,12 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.CallingConventionConverter(_callingConventionConverter); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + // TODO + throw new NotImplementedException(); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { var otherEntry = (CallingConventionConverterLookupResult)other; @@ -1176,6 +1340,11 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.TypeSizeDictionarySlot(_type); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + writer.WriteData(LookupResultReferenceType(factory), LookupResultType.TypeSize, _type); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { return comparer.Compare(_type, ((TypeSizeLookupResult)other)._type); @@ -1237,6 +1406,12 @@ namespace ILCompiler.DependencyAnalysis return factory.NativeLayout.ConstrainedMethodUse(_constrainedMethod, _constraintType, _directCall); } + public override void WriteDictionaryTocData(NodeFactory factory, IGenericLookupResultTocWriter writer) + { + // TODO + throw new NotImplementedException(); + } + protected override int CompareToImpl(GenericLookupResult other, TypeSystemComparer comparer) { var otherResult = (ConstrainedMethodUseLookupResult)other; |