diff options
author | Michal Strehovsky <michals@microsoft.com> | 2018-07-04 12:13:44 +0300 |
---|---|---|
committer | Michal Strehovsky <michals@microsoft.com> | 2018-07-04 12:13:44 +0300 |
commit | 303df5960283a70111bd5e09fcd5e1792a502a36 (patch) | |
tree | f1be8c6b5076f92b9073b9e5b3427088c82726e0 /src/ILCompiler.Compiler | |
parent | 2b657a50d4468339ea91e655cdf322dd6a51f2ae (diff) |
Fix MightHaveInterfaceDispatchMap to work with optimized CoreRT builds
This applies the same pattern that was added in CS 1706049. Without this, the code was trying to access virtual slot information for things like IFoo<!0>, which kind of works in Debug builds, but fails when scanner is used (optimized builds or --scan passed at the command line).
[tfs-changeset: 1706526]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs index fb72c8a7c..bab5d54e9 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/InterfaceDispatchMapNode.cs @@ -76,10 +76,15 @@ namespace ILCompiler.DependencyAnalysis if (!type.IsArray && !type.IsDefType) return false; - TypeDesc declType = type.GetClosestDefType().GetTypeDefinition(); + TypeDesc declType = type.GetClosestDefType(); - foreach (DefType interfaceType in declType.RuntimeInterfaces) + for (int interfaceIndex = 0; interfaceIndex < declType.RuntimeInterfaces.Length; interfaceIndex++) { + DefType interfaceType = declType.RuntimeInterfaces[interfaceIndex]; + InstantiatedType interfaceOnDefinitionType = interfaceType.IsTypeDefinition ? + null : + (InstantiatedType)declType.GetTypeDefinition().RuntimeInterfaces[interfaceIndex]; + IEnumerable<MethodDesc> slots; // If the vtable has fixed slots, we can query it directly. @@ -91,12 +96,16 @@ namespace ILCompiler.DependencyAnalysis else slots = interfaceType.GetAllMethods(); - foreach (MethodDesc declMethod in slots) + foreach (MethodDesc slotMethod in slots) { + MethodDesc declMethod = slotMethod; + if (interfaceOnDefinitionType != null) + declMethod = factory.TypeSystemContext.GetMethodForInstantiatedType(declMethod.GetTypicalMethodDefinition(), interfaceOnDefinitionType); + if (declMethod.Signature.IsStatic) continue; - var implMethod = declType.ResolveInterfaceMethodToVirtualMethodOnType(declMethod); + var implMethod = declType.GetTypeDefinition().ResolveInterfaceMethodToVirtualMethodOnType(declMethod); if (implMethod != null) return true; } |