diff options
author | Fadi Hanna <fadim@microsoft.com> | 2018-07-18 19:47:25 +0300 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2018-07-18 19:47:25 +0300 |
commit | ce1cd12fd80cdd25205b5167d9ae855322cbc651 (patch) | |
tree | 2da9fd84387c1c962ab56a9a326263ba3304ba35 /src/ILCompiler.Compiler | |
parent | dbf3d4d25650f3b82e2856ef13b22ba22dbdf932 (diff) |
In ProjectN, when compiling in multifile mode, all imported types that are also declared in the weak reflected types list (reflection metadata) get added to the TypeMap table.
This change enables ProjectX to behave in a similar manner, but only if such types are referenced and added to the dependency graph (There's no evidence so far that suggests the need to root all such weak reflected imported types in the graph).
[tfs-changeset: 1707792]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs | 5 | ||||
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs index ca2cb8f0a..469d86dd5 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs @@ -53,12 +53,9 @@ namespace ILCompiler.DependencyAnalysis foreach (var mappingEntry in factory.MetadataManager.GetTypeDefinitionMapping(factory)) { - if (!factory.CompilationModuleGroup.ContainsType(mappingEntry.Entity)) - continue; - // Types that don't have EETypes don't need mapping table entries because there's no risk of them // not unifying to the same System.Type at runtime. - if (!factory.MetadataManager.TypeGeneratesEEType(mappingEntry.Entity)) + if (!factory.MetadataManager.TypeGeneratesEEType(mappingEntry.Entity) && !factory.CompilationModuleGroup.ShouldReferenceThroughImportTable(mappingEntry.Entity)) continue; // Go with a necessary type symbol. It will be upgraded to a constructed one if a constructed was emitted. diff --git a/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs index ccb87ce2a..159f6a237 100644 --- a/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs @@ -33,6 +33,7 @@ namespace ILCompiler public ImmutableArray<ModuleDesc> LocalMetadataModules = ImmutableArray<ModuleDesc>.Empty; public ImmutableArray<ModuleDesc> ExternalMetadataModules = ImmutableArray<ModuleDesc>.Empty; public List<MetadataType> TypesWithStrongMetadataMappings = new List<MetadataType>(); + public Dictionary<MetadataType, int> WeakReflectedTypeMappings = new Dictionary<MetadataType, int>(); public Dictionary<MetadataType, int> AllTypeMappings = new Dictionary<MetadataType, int>(); public Dictionary<MethodDesc, int> MethodMappings = new Dictionary<MethodDesc, int>(); public Dictionary<FieldDesc, int> FieldMappings = new Dictionary<FieldDesc, int>(); @@ -401,7 +402,7 @@ namespace ILCompiler MethodIL weakMethodIL = ilProvider.GetMethodIL(weakMetadataMethod); Dictionary<MethodDesc, int> weakMethodMappings = new Dictionary<MethodDesc, int>(); Dictionary<FieldDesc, int> weakFieldMappings = new Dictionary<FieldDesc, int>(); - ReadMetadataMethod(weakMethodIL, result.AllTypeMappings, weakMethodMappings, weakFieldMappings, metadataModules); + ReadMetadataMethod(weakMethodIL, result.WeakReflectedTypeMappings, weakMethodMappings, weakFieldMappings, metadataModules); if ((weakMethodMappings.Count > 0) || (weakFieldMappings.Count > 0)) { // the format does not permit weak field/method mappings @@ -740,6 +741,14 @@ namespace ILCompiler AddFieldMapping(field, canonicalFieldsAddedToMap, fieldMappings); } + foreach (var typeMapping in loadedMetadata.WeakReflectedTypeMappings) + { + // Imported types that are also declared as weak reflected types need to be added to the TypeMap table, but only if they are also + // reachable from static compilation (node marked in the dependency analysis graph) + if (factory.CompilationModuleGroup.ShouldReferenceThroughImportTable(typeMapping.Key) && factory.NecessaryTypeSymbol(typeMapping.Key).Marked) + typeMappings.Add(new MetadataMapping<MetadataType>(typeMapping.Key, typeMapping.Value)); + } + stackTraceMapping = GenerateStackTraceMetadata(factory); } |