diff options
author | Michal Strehovský <michals@microsoft.com> | 2017-01-13 00:51:05 +0300 |
---|---|---|
committer | Michal Strehovský <michals@microsoft.com> | 2017-01-13 00:51:05 +0300 |
commit | 85bff685f8be306a0f8abc737d91657e60aa6089 (patch) | |
tree | abb576a997285cb21e0bd79c7d39df1e96b38dc8 | |
parent | ee738f2da66742730dad656f1d9540f19e63c5ca (diff) |
Delete redundant collections and state
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs | 28 | ||||
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/MetadataGeneration.cs | 11 |
2 files changed, 11 insertions, 28 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs index 9c6ed6029..124b1854f 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs @@ -5,7 +5,6 @@ using System; using System.IO; using System.Diagnostics; -using System.Collections.Generic; using Internal.Text; using Internal.TypeSystem; @@ -21,16 +20,10 @@ namespace ILCompiler.DependencyAnalysis private ObjectAndOffsetSymbolNode _endSymbol; private ExternalReferencesTableNode _externalReferences; - private HashSet<MethodDesc> _visitedMethods; - private List<MethodDesc> _exactMethodInstantiationsList; - public ExactMethodInstantiationsNode(ExternalReferencesTableNode externalReferences) { _endSymbol = new ObjectAndOffsetSymbolNode(this, 0, "__exact_method_instantiations_End", true); _externalReferences = externalReferences; - - _visitedMethods = new HashSet<MethodDesc>(); - _exactMethodInstantiationsList = new List<MethodDesc>(); } public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) @@ -51,21 +44,20 @@ namespace ILCompiler.DependencyAnalysis if (relocsOnly) return new ObjectData(Array.Empty<byte>(), Array.Empty<Relocation>(), 1, new ISymbolNode[] { this }); - // Zero out the hashset so that we AV if someone tries to insert after we're done. - _visitedMethods = null; - // Ensure the native layout data has been saved, in order to get valid Vertex offsets for the signature Vertices factory.MetadataManager.NativeLayoutInfo.SaveNativeLayoutInfoWriter(factory); - NativeWriter nativeWriter = new NativeWriter(); VertexHashtable hashtable = new VertexHashtable(); Section nativeSection = nativeWriter.NewSection(); nativeSection.Place(hashtable); - foreach (MethodDesc method in _exactMethodInstantiationsList) + foreach (MethodDesc method in factory.MetadataManager.GetCompiledMethods()) { + if (!IsMethodEligibleForTracking(method)) + continue; + // Get the method pointer vertex bool getUnboxingStub = method.OwningType.IsValueType && !method.Signature.IsStatic; @@ -143,18 +135,6 @@ namespace ILCompiler.DependencyAnalysis return dependencies; } - public void AddEntryIfEligible(NodeFactory factory, MethodDesc method) - { - // Check if we already saw this method - if (!_visitedMethods.Add(method)) - return; - - if (!IsMethodEligibleForTracking(method)) - return; - - _exactMethodInstantiationsList.Add(method); - } - private static bool IsMethodEligibleForTracking(MethodDesc method) { // Runtime determined methods should never show up here. diff --git a/src/ILCompiler.Compiler/src/Compiler/MetadataGeneration.cs b/src/ILCompiler.Compiler/src/Compiler/MetadataGeneration.cs index 2fa4c80d0..3d07881b2 100644 --- a/src/ILCompiler.Compiler/src/Compiler/MetadataGeneration.cs +++ b/src/ILCompiler.Compiler/src/Compiler/MetadataGeneration.cs @@ -47,7 +47,6 @@ namespace ILCompiler private Dictionary<DynamicInvokeMethodSignature, MethodDesc> _dynamicInvokeThunks = new Dictionary<DynamicInvokeMethodSignature, MethodDesc>(); private GenericsHashtableNode _genericsHashtable; - private ExactMethodInstantiationsNode _exactMethodInstantiations; internal NativeLayoutInfoNode NativeLayoutInfo { get; private set; } @@ -101,8 +100,8 @@ namespace ILCompiler NativeLayoutInfo = new NativeLayoutInfoNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeLayoutInfo), NativeLayoutInfo, NativeLayoutInfo, NativeLayoutInfo.EndSymbol); - _exactMethodInstantiations = new ExactMethodInstantiationsNode(nativeReferencesTableNode); - header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ExactMethodInstantiationsHashtable), _exactMethodInstantiations, _exactMethodInstantiations, _exactMethodInstantiations.EndSymbol); + var exactMethodInstantiations = new ExactMethodInstantiationsNode(nativeReferencesTableNode); + header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ExactMethodInstantiationsHashtable), exactMethodInstantiations, exactMethodInstantiations, exactMethodInstantiations.EndSymbol); _genericsHashtable = new GenericsHashtableNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericsHashtable), _genericsHashtable, _genericsHashtable, _genericsHashtable.EndSymbol); @@ -137,7 +136,6 @@ namespace ILCompiler } AddGeneratedType(method.OwningType); - _exactMethodInstantiations.AddEntryIfEligible(_nodeFactory, method); _methodDefinitionsGenerated.Add(method.GetTypicalMethodDefinition()); _methodsGenerated.Add(method); return; @@ -389,6 +387,11 @@ namespace ILCompiler return _arrayTypesGenerated; } + internal IEnumerable<MethodDesc> GetCompiledMethods() + { + return _methodsGenerated; + } + internal bool TypeGeneratesEEType(TypeDesc type) { return _typesWithEETypesGenerated.Contains(type); |