diff options
4 files changed, 7 insertions, 74 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs index 9570f7208..fde8c0764 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics; using System.Collections.Generic; -using System.Linq; using Internal.Text; using Internal.TypeSystem; @@ -16,43 +15,6 @@ using ILCompiler.DependencyAnalysisFramework; namespace ILCompiler.DependencyAnalysis { /// <summary> - /// Dependency analysis node used to keep track of types used by lazy generics, needing an entry in the default - /// constructor map hashtable - /// </summary> - internal sealed class DefaultConstructorFromLazyNode : DependencyNodeCore<NodeFactory> - { - public TypeDesc TypeNeedingDefaultCtor { get; } - - public DefaultConstructorFromLazyNode(TypeDesc type) - { - Debug.Assert(!type.IsRuntimeDeterminedSubtype); - Debug.Assert(type == type.ConvertToCanonForm(CanonicalFormKind.Specific)); - Debug.Assert(type.GetDefaultConstructor() != null && !type.IsValueType); - - TypeNeedingDefaultCtor = type; - } - - public override bool HasDynamicDependencies => false; - public override bool HasConditionalStaticDependencies => false; - public override bool InterestingForDynamicDependencyAnalysis => false; - public override bool StaticDependenciesAreComputed => true; - protected override string GetName(NodeFactory factory) => "__DefaultConstructorFromLazyNode_" + factory.NameMangler.GetMangledTypeName(TypeNeedingDefaultCtor); - public override IEnumerable<CombinedDependencyListEntry> GetConditionalStaticDependencies(NodeFactory context) => null; - public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null; - - public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory context) - { - yield return new DependencyListEntry( - context.MaximallyConstructableType(TypeNeedingDefaultCtor), - "DefaultConstructorNode type"); - - yield return new DependencyListEntry( - context.MethodEntrypoint(TypeNeedingDefaultCtor.GetDefaultConstructor(), TypeNeedingDefaultCtor.IsValueType), - "DefaultConstructorNode"); - } - } - - /// <summary> /// DefaultConstructorMap blob, containing information on default constructor entrypoints of all types used /// by lazy generic instantiations. /// </summary> @@ -97,7 +59,7 @@ namespace ILCompiler.DependencyAnalysis Section defaultConstructorHashtableSection = writer.NewSection(); defaultConstructorHashtableSection.Place(defaultConstructorHashtable); - foreach (var type in factory.MetadataManager.GetTypesWithConstructedEETypes().Union(GetTypesNeedingDefaultConstructors(factory))) + foreach (var type in factory.MetadataManager.GetTypesWithConstructedEETypes()) { MethodDesc defaultCtor = type.GetDefaultConstructor(); if (defaultCtor == null) @@ -122,11 +84,5 @@ namespace ILCompiler.DependencyAnalysis return new ObjectData(hashTableBytes, Array.Empty<Relocation>(), 1, new ISymbolDefinitionNode[] { this, _endSymbol }); } - - private IEnumerable<TypeDesc> GetTypesNeedingDefaultConstructors(NodeFactory factory) - { - foreach (var ctorNeeded in factory.MetadataManager.GetDefaultConstructorsNeeded()) - yield return ctorNeeded.TypeNeedingDefaultCtor; - } } } diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs index 8ebdfa051..799767379 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs @@ -134,11 +134,11 @@ namespace ILCompiler.DependencyAnalysis foreach (var arg in _owningType.Instantiation) { // Skip types that do not have a default constructor (not interesting). - if (arg.IsValueType || arg.GetDefaultConstructor() == null) + if (arg.IsValueType || arg.GetDefaultConstructor() == null || !ConstructedEETypeNode.CreationAllowed(arg)) continue; result.Add(new DependencyListEntry( - factory.DefaultConstructorFromLazy(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), + factory.ConstructedTypeSymbol(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), "Default constructor for lazy generics")); } } @@ -218,21 +218,21 @@ namespace ILCompiler.DependencyAnalysis foreach (var arg in _owningMethod.OwningType.Instantiation) { // Skip types that do not have a default constructor (not interesting). - if (arg.IsValueType || arg.GetDefaultConstructor() == null) + if (arg.IsValueType || arg.GetDefaultConstructor() == null || !ConstructedEETypeNode.CreationAllowed(arg)) continue; dependencies.Add(new DependencyListEntry( - factory.DefaultConstructorFromLazy(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), + factory.ConstructedTypeSymbol(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), "Default constructor for lazy generics")); } foreach (var arg in _owningMethod.Instantiation) { // Skip types that do not have a default constructor (not interesting). - if (arg.IsValueType || arg.GetDefaultConstructor() == null) + if (arg.IsValueType || arg.GetDefaultConstructor() == null || !ConstructedEETypeNode.CreationAllowed(arg)) continue; dependencies.Add(new DependencyListEntry( - factory.DefaultConstructorFromLazy(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), + factory.ConstructedTypeSymbol(arg.ConvertToCanonForm(CanonicalFormKind.Specific)), "Default constructor for lazy generics")); } } diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs index 73eb45898..be26fcd91 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs @@ -480,11 +480,6 @@ namespace ILCompiler.DependencyAnalysis return new StringAllocatorMethodNode(constructor); }); - _defaultConstructorFromLazyNodes = new NodeCache<TypeDesc, DefaultConstructorFromLazyNode>(type => - { - return new DefaultConstructorFromLazyNode(type); - }); - NativeLayout = new NativeLayoutHelper(this); WindowsDebugData = new WindowsDebugDataHelper(this); } @@ -801,12 +796,6 @@ namespace ILCompiler.DependencyAnalysis return _runtimeDeterminedMethods.GetOrAdd(method); } - private NodeCache<TypeDesc, DefaultConstructorFromLazyNode> _defaultConstructorFromLazyNodes; - internal DefaultConstructorFromLazyNode DefaultConstructorFromLazy(TypeDesc type) - { - return _defaultConstructorFromLazyNodes.GetOrAdd(type); - } - private static readonly string[][] s_helperEntrypointNames = new string[][] { new string[] { "System.Runtime.CompilerServices", "ClassConstructorRunner", "CheckStaticClassConstructionReturnGCStaticBase" }, new string[] { "System.Runtime.CompilerServices", "ClassConstructorRunner", "CheckStaticClassConstructionReturnNonGCStaticBase" }, diff --git a/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs index d7f5dc695..301c64572 100644 --- a/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs @@ -50,7 +50,6 @@ namespace ILCompiler private HashSet<GenericDictionaryNode> _genericDictionariesGenerated = new HashSet<GenericDictionaryNode>(); private HashSet<IMethodBodyNode> _methodBodiesGenerated = new HashSet<IMethodBodyNode>(); private List<TypeGVMEntriesNode> _typeGVMEntries = new List<TypeGVMEntriesNode>(); - private HashSet<DefaultConstructorFromLazyNode> _defaultConstructorsNeeded = new HashSet<DefaultConstructorFromLazyNode>(); internal NativeLayoutInfoNode NativeLayoutInfo { get; private set; } internal DynamicInvokeTemplateDataNode DynamicInvokeTemplateData { get; private set; } @@ -205,12 +204,6 @@ namespace ILCompiler { _genericDictionariesGenerated.Add(dictionaryNode); } - - var ctorFromLazyGenericsNode = obj as DefaultConstructorFromLazyNode; - if (ctorFromLazyGenericsNode != null) - { - _defaultConstructorsNeeded.Add(ctorFromLazyGenericsNode); - } } /// <summary> @@ -575,11 +568,6 @@ namespace ILCompiler return _methodBodiesGenerated; } - internal IEnumerable<DefaultConstructorFromLazyNode> GetDefaultConstructorsNeeded() - { - return _defaultConstructorsNeeded; - } - internal bool TypeGeneratesEEType(TypeDesc type) { return _typesWithEETypesGenerated.Contains(type); |