Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovsky <michals@microsoft.com>2018-06-04 12:22:30 +0300
committerMichal Strehovsky <michals@microsoft.com>2018-06-04 12:22:30 +0300
commit31ea93ce5007177dd037e34a2b6982965119c254 (patch)
tree53afe927f1f13d412879d6f710eb5a0dc338d523 /src/ILCompiler.Compiler
parent7f1ec023c89d884cbde7ee569da771e069fdd692 (diff)
Clean up tracking default .ctor dependencies
Changeset 1702272 added logic that uses a big hammer to track default ctors. There was some existing logic that was trying to surgically do the same thing but didn't really work. I don't really see the reason to keep the surgical code in place. [tfs-changeset: 1702600]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/DefaultConstructorMapNode.cs46
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs12
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs11
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs12
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);