-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to resolve static virtuals to unshared methods at ru…
…ntime (#104965) Static virtual methods are usually resolved at compile time but whenever there's a dynamic scenario (`MakeGenericType` or a instance generic virtual method call), we might need to resolve them at runtime. This worked when the static virtual is a shared method, but didn't work when it's unshared. This fixes it. The fix has two logical parts: * Runtime part (GenericDictionaryCell.cs): when the computed target of the static virtual lookup is an unshared method, don't call into type loader. We know the function pointer to use and don't need anything else. * Compiler part (everything else): we have a hashtable of all generic virtual methods we could potentially need in the ExactMethodInstantiations hashtable. This hashtable was previously filled with a heuristic: if we compiled an unshared generic virtual method, place it in the hashtable. This places too much and too little in the hashtable. Too much: if the generic virtual method isn't actually part of a generic virtual dispatch (e.g. was called non-virtually), we'd still put it in the hashtable and never use it at runtime. Too little: implementations of static virtual interface methods are not virtual themselves. So we missed them. This makes the tracking more precise so that we put exactly what we need (in a sense it's similar to #87466).
- Loading branch information
1 parent
8f3a317
commit 66ae898
Showing
8 changed files
with
122 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsEntryNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
using ILCompiler.DependencyAnalysisFramework; | ||
|
||
using Internal.TypeSystem; | ||
|
||
using Debug = System.Diagnostics.Debug; | ||
|
||
namespace ILCompiler.DependencyAnalysis | ||
{ | ||
public class ExactMethodInstantiationsEntryNode : DependencyNodeCore<NodeFactory> | ||
{ | ||
private readonly MethodDesc _method; | ||
|
||
public ExactMethodInstantiationsEntryNode(MethodDesc method) | ||
{ | ||
Debug.Assert(!method.IsAbstract); | ||
Debug.Assert(method.HasInstantiation); | ||
Debug.Assert(!method.GetCanonMethodTarget(CanonicalFormKind.Specific).IsCanonicalMethod(CanonicalFormKind.Any)); | ||
_method = method; | ||
} | ||
|
||
public MethodDesc Method => _method; | ||
|
||
public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory) | ||
{ | ||
DependencyList dependencies = null; | ||
ExactMethodInstantiationsNode.GetExactMethodInstantiationDependenciesForMethod(ref dependencies, factory, _method); | ||
Debug.Assert(dependencies != null); | ||
return dependencies; | ||
} | ||
protected override string GetName(NodeFactory factory) | ||
{ | ||
return "Exact methods hashtable entry: " + _method.ToString(); | ||
} | ||
|
||
public override bool InterestingForDynamicDependencyAnalysis => false; | ||
public override bool HasDynamicDependencies => false; | ||
public override bool HasConditionalStaticDependencies => false; | ||
public override bool StaticDependenciesAreComputed => true; | ||
public override IEnumerable<CombinedDependencyListEntry> GetConditionalStaticDependencies(NodeFactory factory) => null; | ||
public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters