Type equivalence support in Crossgen2 (#87899)
authorDavid Wrighton <davidwr@microsoft.com>
Thu, 6 Jul 2023 00:55:38 +0000 (17:55 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Jul 2023 00:55:38 +0000 (17:55 -0700)
commitd510ea2bb599641c7a32d3ed7418ed9b64cbe3f4
tree8bc08ed667c5b5fe5552d6d963fd6e9c2950e44a
parent94aed3242e5335f9e55d22bfb93bdc22622b50ec
Type equivalence support in Crossgen2 (#87899)

We currently have a small behavior hole on Windows where if a binary uses TypeEquivalence, it is technically possible to get crossgen2 to generate invalid code.

This fixes that by adding support for type equivalence to the managed type system, and adjusting crossgen2 to use it. This is complicated by the detail that this may generate some type references which cannot be referenced from an R2R file, so additional error checking was needed (this additional error checking is what fixes #67855).

However, while basic support for type equivalence has been added to the type system, support for actually performing type equivalent interface resolution has not been, so devirtualization of type equivalent interface calls is disabled. At this time, I do not expect to see a customer need for implementing that fairly complicated feature

Fixes #67855
52 files changed:
src/coreclr/inc/corinfo.h
src/coreclr/inc/jiteeversionguid.h
src/coreclr/jit/compiler.cpp
src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs
src/coreclr/tools/Common/Compiler/TypeExtensions.cs
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs
src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs [new file with mode: 0644]
src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs
src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.TypeEquivalence.cs [new file with mode: 0644]
src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs
src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs
src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs
src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.TypeEquivalence.cs [new file with mode: 0644]
src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs
src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs [new file with mode: 0644]
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs
src/coreclr/tools/Common/TypeSystem/Ecma/EffectiveVisibility.cs [moved from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/EffectiveVisibility.cs with 55% similarity]
src/coreclr/tools/Common/TypeSystem/Interop/MarshalAsDescriptor.cs
src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs
src/coreclr/tools/ILVerification/ILVerification.csproj
src/coreclr/tools/ILVerification/ILVerification.projitems
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Canonicalization.cs
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Platform.cs
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceAssembly/TypeEquivalenceAssembly1.csproj [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceAssembly/TypeEquivalenceAssembly2.csproj [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceAssembly/TypesWhichDoNotLoad.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceAssembly/TypesWhichDoNotMatch.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceAssembly/TypesWhichMatch.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj
src/coreclr/vm/methodtable.cpp
src/tests/baseservices/typeequivalence/istypeequivalent/istypeequivalent.cs [new file with mode: 0644]
src/tests/baseservices/typeequivalence/istypeequivalent/istypeequivalent.csproj [new file with mode: 0644]
src/tests/baseservices/typeequivalence/istypeequivalent/typeequivalenttypes_1.csproj [new file with mode: 0644]
src/tests/baseservices/typeequivalence/istypeequivalent/typeequivalenttypes_2.csproj [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/basetestclassesil.il [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/basetestclassesil.ilproj [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/nopiatestil.il [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/nopiatestil.ilproj [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/testclassesil.il [new file with mode: 0644]
src/tests/baseservices/typeequivalence/signatures/testclassesil.ilproj [new file with mode: 0644]
src/tests/issues.targets