diff options
author | Michal Strehovský <michals@microsoft.com> | 2017-12-11 13:45:02 +0300 |
---|---|---|
committer | Michal Strehovský <michals@microsoft.com> | 2017-12-18 14:28:54 +0300 |
commit | 243c3ef555f525550317f834dd4a8aac8ccfcb66 (patch) | |
tree | 3e5705da50910684b20d3f15878176d1b38e6e16 | |
parent | b5d9787448020192b7986de45d1bcd54696ef123 (diff) |
Do not require CompilationModuleGroup in MetadataManager
7 files changed, 18 insertions, 13 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs b/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs index 7bdaf6abe..fc20b3432 100644 --- a/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs +++ b/src/ILCompiler.Compiler/src/Compiler/CompilationBuilder.cs @@ -33,7 +33,7 @@ namespace ILCompiler _context = context; _compilationGroup = compilationGroup; _nameMangler = nameMangler; - _metadataManager = new EmptyMetadataManager(compilationGroup, context); + _metadataManager = new EmptyMetadataManager(context); } public CompilationBuilder UseLogger(Logger logger) diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs index a5be25757..fbeb03680 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs @@ -63,7 +63,7 @@ namespace ILCompiler { if (metadataFile == null) { - return new EmptyMetadataManager(compilationModuleGroup, context); + return new EmptyMetadataManager(context); } else { diff --git a/src/ILCompiler.Compiler/src/Compiler/EmptyMetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/EmptyMetadataManager.cs index f65e50c67..97eed867a 100644 --- a/src/ILCompiler.Compiler/src/Compiler/EmptyMetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/EmptyMetadataManager.cs @@ -12,12 +12,12 @@ using Debug = System.Diagnostics.Debug; namespace ILCompiler { - class EmptyMetadataManager : MetadataManager + public class EmptyMetadataManager : MetadataManager { public override bool SupportsReflection => false; - public EmptyMetadataManager(CompilationModuleGroup group, CompilerTypeSystemContext typeSystemContext) - : base(group, typeSystemContext, new FullyBlockedMetadataPolicy()) + public EmptyMetadataManager(CompilerTypeSystemContext typeSystemContext) + : base(typeSystemContext, new FullyBlockedMetadataPolicy()) { } diff --git a/src/ILCompiler.Compiler/src/Compiler/GeneratingMetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/GeneratingMetadataManager.cs index 9e9fdc742..50efd7c6d 100644 --- a/src/ILCompiler.Compiler/src/Compiler/GeneratingMetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/GeneratingMetadataManager.cs @@ -27,12 +27,14 @@ namespace ILCompiler private readonly string _metadataLogFile; private readonly StackTraceEmissionPolicy _stackTraceEmissionPolicy; private readonly Dictionary<DynamicInvokeMethodSignature, MethodDesc> _dynamicInvokeThunks; + private readonly ModuleDesc _generatedAssembly; - public GeneratingMetadataManager(CompilationModuleGroup group, CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy, string logFile, StackTraceEmissionPolicy stackTracePolicy) - : base(group, typeSystemContext, blockingPolicy) + public GeneratingMetadataManager(ModuleDesc generatedAssembly, CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy, string logFile, StackTraceEmissionPolicy stackTracePolicy) + : base(typeSystemContext, blockingPolicy) { _metadataLogFile = logFile; _stackTraceEmissionPolicy = stackTracePolicy; + _generatedAssembly = generatedAssembly; if (DynamicInvokeMethodThunk.SupportsThunks(typeSystemContext)) { @@ -232,7 +234,7 @@ namespace ILCompiler var lookupSig = new DynamicInvokeMethodSignature(sig); if (!_dynamicInvokeThunks.TryGetValue(lookupSig, out thunk)) { - thunk = new DynamicInvokeMethodThunk(_compilationModuleGroup.GeneratedAssembly.GetGlobalModuleType(), lookupSig); + thunk = new DynamicInvokeMethodThunk(_generatedAssembly.GetGlobalModuleType(), lookupSig); _dynamicInvokeThunks.Add(lookupSig, thunk); } diff --git a/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs index 41799b762..e6114ad6f 100644 --- a/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/MetadataManager.cs @@ -34,7 +34,6 @@ namespace ILCompiler private List<MetadataMapping<MethodDesc>> _methodMappings; private List<MetadataMapping<MethodDesc>> _stackTraceMappings; - protected readonly CompilationModuleGroup _compilationModuleGroup; protected readonly CompilerTypeSystemContext _typeSystemContext; protected readonly MetadataBlockingPolicy _blockingPolicy; @@ -52,9 +51,8 @@ namespace ILCompiler internal DynamicInvokeTemplateDataNode DynamicInvokeTemplateData { get; private set; } public virtual bool SupportsReflection => true; - public MetadataManager(CompilationModuleGroup compilationModuleGroup, CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy) + public MetadataManager(CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy) { - _compilationModuleGroup = compilationModuleGroup; _typeSystemContext = typeSystemContext; _blockingPolicy = blockingPolicy; } diff --git a/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs index 6413fcff2..5a539cf81 100644 --- a/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/PrecomputedMetadataManager.cs @@ -52,6 +52,7 @@ namespace ILCompiler private readonly byte[] _metadataBlob; private readonly StackTraceEmissionPolicy _stackTraceEmissionPolicy; private byte[] _stackTraceBlob; + private readonly CompilationModuleGroup _compilationModuleGroup; public PrecomputedMetadataManager( CompilationModuleGroup group, @@ -61,8 +62,9 @@ namespace ILCompiler IEnumerable<ModuleDesc> inputMetadataOnlyAssemblies, byte[] metadataBlob, StackTraceEmissionPolicy stackTraceEmissionPolicy) - : base(group, typeSystemContext, new AttributeSpecifiedBlockingPolicy()) + : base(typeSystemContext, new AttributeSpecifiedBlockingPolicy()) { + _compilationModuleGroup = group; _metadataDescribingModule = metadataDescribingModule; _compilationModules = new HashSet<ModuleDesc>(compilationModules); _metadataOnlyAssemblies = new HashSet<ModuleDesc>(inputMetadataOnlyAssemblies); diff --git a/src/ILCompiler.Compiler/src/Compiler/UsageBasedMetadataManager.cs b/src/ILCompiler.Compiler/src/Compiler/UsageBasedMetadataManager.cs index 568afc5b6..fdb813df8 100644 --- a/src/ILCompiler.Compiler/src/Compiler/UsageBasedMetadataManager.cs +++ b/src/ILCompiler.Compiler/src/Compiler/UsageBasedMetadataManager.cs @@ -19,14 +19,17 @@ namespace ILCompiler /// </summary> public sealed class UsageBasedMetadataManager : GeneratingMetadataManager { + private readonly CompilationModuleGroup _compilationModuleGroup; + public UsageBasedMetadataManager( CompilationModuleGroup group, CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy, string logFile, StackTraceEmissionPolicy stackTracePolicy) - : base(group, typeSystemContext, blockingPolicy, logFile, stackTracePolicy) + : base(group.GeneratedAssembly, typeSystemContext, blockingPolicy, logFile, stackTracePolicy) { + _compilationModuleGroup = group; } protected override MetadataCategory GetMetadataCategory(FieldDesc field) |