diff options
Diffstat (limited to 'src/ILCompiler.Compiler')
5 files changed, 13 insertions, 52 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs index cf9222cb8..e970fdd76 100644 --- a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs +++ b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs @@ -2,12 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using Internal.TypeSystem; -using AssemblyName = System.Reflection.AssemblyName; using Debug = System.Diagnostics.Debug; namespace ILCompiler @@ -17,37 +15,22 @@ namespace ILCompiler /// </summary> public sealed class LibraryInitializers { - private const string ClassLibraryPlaceHolderString = "*ClassLibrary*"; private const string LibraryInitializerContainerNamespaceName = "Internal.Runtime.CompilerHelpers"; private const string LibraryInitializerContainerTypeName = "LibraryInitializer"; private const string LibraryInitializerMethodName = "InitializeLibrary"; - private static readonly LibraryInitializerInfo[] s_assembliesWithLibraryInitializers = - { - new LibraryInitializerInfo(ClassLibraryPlaceHolderString), - new LibraryInitializerInfo("System.Private.TypeLoader"), - new LibraryInitializerInfo("System.Private.Reflection.Execution"), - new LibraryInitializerInfo("System.Private.DeveloperExperience.Console"), - new LibraryInitializerInfo("System.Private.Interop"), - new LibraryInitializerInfo("System.Private.StackTraceMetadata"), - }; - private List<MethodDesc> _libraryInitializerMethods; private readonly TypeSystemContext _context; - private readonly bool _isCppCodeGen; + private IReadOnlyCollection<ModuleDesc> _librariesWithInitializers; - public LibraryInitializers(TypeSystemContext context, bool isCppCodeGen) + public LibraryInitializers(TypeSystemContext context, IEnumerable<ModuleDesc> librariesWithInitalizers) { _context = context; - // - // We should not care which code-gen is being used but for the time being - // this can be useful to workaround CppCodeGen bugs. - // - _isCppCodeGen = isCppCodeGen; + _librariesWithInitializers = new List<ModuleDesc>(librariesWithInitalizers); } - public IList<MethodDesc> LibraryInitializerMethods + public IReadOnlyCollection<MethodDesc> LibraryInitializerMethods { get { @@ -64,18 +47,8 @@ namespace ILCompiler _libraryInitializerMethods = new List<MethodDesc>(); - foreach (var entry in s_assembliesWithLibraryInitializers) + foreach (var assembly in _librariesWithInitializers) { - if (_isCppCodeGen && !entry.UseWithCppCodeGen) - continue; - - ModuleDesc assembly = entry.Assembly == ClassLibraryPlaceHolderString - ? _context.SystemModule - : _context.ResolveAssembly(new AssemblyName(entry.Assembly), false); - - if (assembly == null) - continue; - TypeDesc containingType = assembly.GetType(LibraryInitializerContainerNamespaceName, LibraryInitializerContainerTypeName, false); if (containingType == null) continue; @@ -87,17 +60,5 @@ namespace ILCompiler _libraryInitializerMethods.Add(initializerMethod); } } - - private sealed class LibraryInitializerInfo - { - public string Assembly { get; } - public bool UseWithCppCodeGen { get; } - - public LibraryInitializerInfo(string assembly, bool useWithCppCodeGen = true) - { - Assembly = assembly; - UseWithCppCodeGen = useWithCppCodeGen; - } - } } } diff --git a/src/ILCompiler.Compiler/src/Compiler/MainMethodRootProvider.cs b/src/ILCompiler.Compiler/src/Compiler/MainMethodRootProvider.cs index 4df659ad8..2b716787b 100644 --- a/src/ILCompiler.Compiler/src/Compiler/MainMethodRootProvider.cs +++ b/src/ILCompiler.Compiler/src/Compiler/MainMethodRootProvider.cs @@ -22,9 +22,9 @@ namespace ILCompiler public const string ManagedEntryPointMethodName = "__managed__Main"; private EcmaModule _module; - private IList<MethodDesc> _libraryInitializers; + private IReadOnlyCollection<MethodDesc> _libraryInitializers; - public MainMethodRootProvider(EcmaModule module, IList<MethodDesc> libraryInitializers) + public MainMethodRootProvider(EcmaModule module, IReadOnlyCollection<MethodDesc> libraryInitializers) { _module = module; _libraryInitializers = libraryInitializers; diff --git a/src/ILCompiler.Compiler/src/Compiler/NativeLibraryInitializerRootProvider.cs b/src/ILCompiler.Compiler/src/Compiler/NativeLibraryInitializerRootProvider.cs index 7f1e67700..4079a902b 100644 --- a/src/ILCompiler.Compiler/src/Compiler/NativeLibraryInitializerRootProvider.cs +++ b/src/ILCompiler.Compiler/src/Compiler/NativeLibraryInitializerRootProvider.cs @@ -21,9 +21,9 @@ namespace ILCompiler public const string ManagedEntryPointMethodName = "__managed__Startup"; private ModuleDesc _module; - private IList<MethodDesc> _libraryInitializers; + private IReadOnlyCollection<MethodDesc> _libraryInitializers; - public NativeLibraryInitializerRootProvider(ModuleDesc module, IList<MethodDesc> libraryInitializers) + public NativeLibraryInitializerRootProvider(ModuleDesc module, IReadOnlyCollection<MethodDesc> libraryInitializers) { _module = module; _libraryInitializers = libraryInitializers; diff --git a/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index 80bd691a0..b04e5e988 100644 --- a/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -17,9 +17,9 @@ namespace Internal.IL.Stubs.StartupCode { private TypeDesc _owningType; private MethodSignature _signature; - private IList<MethodDesc> _libraryInitializers; + private IReadOnlyCollection<MethodDesc> _libraryInitializers; - public NativeLibraryStartupMethod(TypeDesc owningType, IList<MethodDesc> libraryInitializers) + public NativeLibraryStartupMethod(TypeDesc owningType, IReadOnlyCollection<MethodDesc> libraryInitializers) { _owningType = owningType; _libraryInitializers = libraryInitializers; diff --git a/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index f994a1d0a..fd16383f5 100644 --- a/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -21,9 +21,9 @@ namespace Internal.IL.Stubs.StartupCode private TypeDesc _owningType; private MainMethodWrapper _mainMethod; private MethodSignature _signature; - private IList<MethodDesc> _libraryInitializers; + private IReadOnlyCollection<MethodDesc> _libraryInitializers; - public StartupCodeMainMethod(TypeDesc owningType, MethodDesc mainMethod, IList<MethodDesc> libraryInitializers) + public StartupCodeMainMethod(TypeDesc owningType, MethodDesc mainMethod, IReadOnlyCollection<MethodDesc> libraryInitializers) { _owningType = owningType; _mainMethod = new MainMethodWrapper(owningType, mainMethod); |