Simplify JIT shutdown logic in crossgen2 (#56687)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 3 Aug 2021 05:34:45 +0000 (14:34 +0900)
committerGitHub <noreply@github.com>
Tue, 3 Aug 2021 05:34:45 +0000 (14:34 +0900)
commita0ff4e1a4390813a2c93684f88b96a0082811729
treeaf827a17ea97c7f7085c5766587a86548571d3e6
parentf21aca10e4906b7763c6bf0841a59bcbaaf91439
Simplify JIT shutdown logic in crossgen2 (#56687)

There was unanswered comment about thread safety in https://github.com/dotnet/runtime/pull/56187/files#r675461236 so I just decided to fix it myself.

While on it, I simplified shutdown to use `AppDomain.ProcessExit`.

I'm not sure `AppDomain.UnhandledException` is needed but the original code had this in a `finally`.

The better fix would be to allow JIT to be initialized right before we start a compilation and shut down after, but that would require no process wide state in the JIT. As it stands now, JIT is once-per-process-global.
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs
src/coreclr/tools/aot/crossgen2/Program.cs