Skip to content

Commit e5d2c3e

Browse files
Generate single interface dispatch map per canonical form (dotnet#76362)
The dispatch maps are identical because canonically-equivalent types have the same vtable layouts.
1 parent ed9afa8 commit e5d2c3e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ConstructedEETypeNode.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact
3838

3939
if (MightHaveInterfaceDispatchMap(factory))
4040
{
41-
dependencyList.Add(factory.InterfaceDispatchMap(_type), "Interface dispatch map");
41+
TypeDesc canonType = _type.ConvertToCanonForm(CanonicalFormKind.Specific);
42+
dependencyList.Add(factory.InterfaceDispatchMap(canonType), "Interface dispatch map");
4243
}
4344

4445
if (_type.IsArray)

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@ protected internal virtual void ComputeOptionalEETypeFields(NodeFactory factory,
10561056
{
10571057
if (!relocsOnly && MightHaveInterfaceDispatchMap(factory))
10581058
{
1059-
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.DispatchMap, checked((uint)factory.InterfaceDispatchMapIndirection(Type).IndexFromBeginningOfArray));
1059+
TypeDesc canonType = _type.ConvertToCanonForm(CanonicalFormKind.Specific);
1060+
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.DispatchMap, checked((uint)factory.InterfaceDispatchMapIndirection(canonType).IndexFromBeginningOfArray));
10601061
}
10611062

10621063
ComputeRareFlags(factory, relocsOnly);

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public InterfaceDispatchMapNode(NodeFactory factory, TypeDesc type)
2222
// Pointer arrays also follow the same path
2323
Debug.Assert(!type.IsArrayTypeWithoutGenericInterfaces());
2424
Debug.Assert(MightHaveInterfaceDispatchMap(type, factory));
25+
Debug.Assert(type.ConvertToCanonForm(CanonicalFormKind.Specific) == type);
2526

2627
_type = type;
2728
}

0 commit comments

Comments
 (0)