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:
authorSimon Nattress <simonn@microsoft.com>2017-01-10 05:14:43 +0300
committerSimon Nattress <simonn@microsoft.com>2017-01-14 01:10:09 +0300
commit8089be9159c90226af98f5fa25c6df6014605b6f (patch)
tree7c93d5f57b1cae82390278342d0a884141fb3e6e /src/System.Private.DeveloperExperience.Console
parent262b052c00374794c92e8018ebd2ae1d9944bd73 (diff)
Run ordered class constructors explicitly
Previously, order-dependent class constructors were run by looking at the EagerOrderedClassConstructorAttribute and sorting them accordingly. That mechanism is not ideal for scenarios where separately compiled assembly object files are linked together since we would then have to sort all class constructors from modules on startup. Replace the attribute mechanism with a simple list of module initializers to run. The startup code injects calls to these at runtime after module tables are initialized. Internal.Runtime.TypeLoaderEnvironment..cctor is disabled for C++ code generation due to issue #2486. Remove cctors under #if CORERT from types we want to initialize in an explicit order. Add an Initialize method to those types. Introduce the `ModuleInitializers` class which has a list of assemblies with module-level initialization code to run. Each such assembly has a special type which calls the various Initialize methods in that assembly. The lookup policy here is non-fatal by design so we can compose these things in future more easily. Use a wildcard for the class library so that if a new class library is introduced, it can provide the appropriate module initializer type and automatically get initialized. Remove some old code in `CppWriter` that stubbed out the cctor in `ReflectionExecution`. Instead that is specified in the configuration for System.Private.Reflection.Execution in `ModuleInitializers`. Move the statics in `ClassConstructorRunner+Cctor` up into the nesting class so we need one fewer eager cctors. DeveloperExperience now uses the library initializer mechanism.
Diffstat (limited to 'src/System.Private.DeveloperExperience.Console')
-rw-r--r--src/System.Private.DeveloperExperience.Console/src/Internal/Runtime/CompilerHelpers/LibraryInitializer.cs18
-rw-r--r--src/System.Private.DeveloperExperience.Console/src/System.Private.DeveloperExperience.Console.csproj1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/System.Private.DeveloperExperience.Console/src/Internal/Runtime/CompilerHelpers/LibraryInitializer.cs b/src/System.Private.DeveloperExperience.Console/src/Internal/Runtime/CompilerHelpers/LibraryInitializer.cs
new file mode 100644
index 000000000..68af06c7f
--- /dev/null
+++ b/src/System.Private.DeveloperExperience.Console/src/Internal/Runtime/CompilerHelpers/LibraryInitializer.cs
@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// 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 Internal.DeveloperExperience;
+
+namespace Internal.Runtime.CompilerHelpers
+{
+ public class LibraryInitializer
+ {
+ public static void InitializeLibrary()
+ {
+ DeveloperExperienceConnectorConsole.Initialize();
+ }
+ }
+}
diff --git a/src/System.Private.DeveloperExperience.Console/src/System.Private.DeveloperExperience.Console.csproj b/src/System.Private.DeveloperExperience.Console/src/System.Private.DeveloperExperience.Console.csproj
index 5cf519665..5a748e1b4 100644
--- a/src/System.Private.DeveloperExperience.Console/src/System.Private.DeveloperExperience.Console.csproj
+++ b/src/System.Private.DeveloperExperience.Console/src/System.Private.DeveloperExperience.Console.csproj
@@ -33,6 +33,7 @@
<ItemGroup>
<Compile Include="Internal\DeveloperExperience\DeveloperExperienceConnector.cs" />
<Compile Include="Internal\DeveloperExperience\DeveloperExperienceConsole.cs" />
+ <Compile Include="Internal\Runtime\CompilerHelpers\LibraryInitializer.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />