Improve the performance of the type loader through various tweaks (#85743)
authorDavid Wrighton <davidwr@microsoft.com>
Tue, 13 Jun 2023 22:25:50 +0000 (15:25 -0700)
committerGitHub <noreply@github.com>
Tue, 13 Jun 2023 22:25:50 +0000 (15:25 -0700)
commit8042facb423e8a1151282409e70e380273674926
treed814d9240af5a9375eb9137061f13b6d038bc82f
parent1087766a7b81104753f209a93e0a1102499e91f0
Improve the performance of the type loader through various tweaks (#85743)

* Skip type validation by default in ReadyToRun images
- Technically, this is a breaking change, so I've provided a means for disabling the type validation skip
- The model is that the C# compile won't get these details wrong, so disable the checks when run through crossgen2. The idea is that we'll get these things checked during normal, non-R2R usage of the app, and publish won't check these details.

* Replace expensive lookups of generic parameter and nested class data with R2R optimized forms

* Store index of MethodDesc as well as ChunkIndex. Makes MethodDesc::GetTemporaryEntryPoint *much* faster

* Optimize the path for computing if a method is eligible for tiered compilation

* Remove CanShareVtableChunksFrom concept
- it was only needed to support NGen

* Fix up some more issues

* Bring back late virtual propagation in the presence of covariant overrides only

* Check correct flag on EEClass

* Drive by fix for GetRestoredSlot. We don't need the handling of unrestored slots anymore

* Fix composite build with new tables

* Uniquify the mangled names

* Add more __

* Initial pass at type skip verifation checker

* Fix logging and some correctness issues

* Enable the more of type checking
- Notably, the recursive stuff now works
- Also fix a bug in constraint checking involving open types in the type system

* Fix build breaks involving new feature of GenericParameterDesc

* Add documentation for R2R format changes
Fix command line parameter to be more reasonable, and allow logging on command
Fix the rest of issues noted in crossgen2 testing

* Fix implementation of CompareMethodContraints. instead of using IsGeneric map, check to see if the method is generic in the first place. It turns out we have an efficient way to check in every place that matters

* Fix nits noticed by Aaron

* Add some const correctness to the world

* Fix issues noted by Michal, as well as remaining constrain checking issues

* Code review details

* Code review from trylek
51 files changed:
docs/design/coreclr/botr/readytorun-format.md
src/coreclr/inc/readytorun.h
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeGenericParameterDesc.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs
src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs
src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs
src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs
src/coreclr/tools/Common/TypeSystem/Common/SignatureVariable.cs
src/coreclr/tools/Common/TypeSystem/Common/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs [moved from src/coreclr/tools/ILVerification/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs with 91% similarity]
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs
src/coreclr/tools/ILVerification/ILVerification.projitems
src/coreclr/tools/ILVerification/InstantiatedGenericParameter.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/EnclosingTypeMapNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/HeaderNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodEntryPointTableNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodIsGenericMapNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeGenericInfoMapNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj
src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
src/coreclr/tools/aot/crossgen2/Program.cs
src/coreclr/tools/aot/crossgen2/Properties/Resources.resx
src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemGenericParameter.cs
src/coreclr/tools/r2rdump/TextDumper.cs
src/coreclr/vm/array.cpp
src/coreclr/vm/ceeload.cpp
src/coreclr/vm/ceeload.h
src/coreclr/vm/class.cpp
src/coreclr/vm/clsload.cpp
src/coreclr/vm/generics.cpp
src/coreclr/vm/method.cpp
src/coreclr/vm/method.hpp
src/coreclr/vm/methodtable.cpp
src/coreclr/vm/methodtable.h
src/coreclr/vm/methodtablebuilder.cpp
src/coreclr/vm/methodtablebuilder.h
src/coreclr/vm/precode.cpp
src/coreclr/vm/readytoruninfo.cpp
src/coreclr/vm/readytoruninfo.h
src/coreclr/vm/siginfo.cpp
src/coreclr/vm/typedesc.cpp