Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2017-12-01 22:25:59 +0300
committerGitHub <noreply@github.com>2017-12-01 22:25:59 +0300
commitf826d5678f9b7f8b5a04c9b8bbdc1d13bd779aa9 (patch)
tree26115e3668147a987f783a876f6e976e6bc0432f
parent58f9c991887293ca8a9ca375c63e15b2e9664798 (diff)
Do not track RuntimeDeterminedMethod dependencies from canonical methods (#5040)
The concept of RuntimeDeterminedMethodNode was added when I was trying to support a mode where generic dictionaries could have "holes" (null entries for things that are not used for the particular instantiation). This turned out to be not feasible and we now have dependency analysis infra to patch those holes up anyway. We don't need to track dependencies of canonical code on such granularity. The only exception to that were generic methods, but I'm fixing that by having the method generic dictionary (which is tracked as a runtime determined dependency of the canonical body) to also depend on the ShadowConcreteMethod (to make sure we can actually fill it). I'm doing this because the devirtualization in RyuJIT causes `getCallInfo` to be called with bogus `pResolvedToken` and we can no longer use that to get a `RuntimeDeterminedMethod` anyway.
-rw-r--r--src/Common/src/TypeSystem/IL/DelegateInfo.cs18
-rw-r--r--src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs8
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.cs8
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs3
-rw-r--r--src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs2
-rw-r--r--src/JitInterface/src/CorInfoImpl.cs26
6 files changed, 30 insertions, 35 deletions
diff --git a/src/Common/src/TypeSystem/IL/DelegateInfo.cs b/src/Common/src/TypeSystem/IL/DelegateInfo.cs
index 36cadba32..66267bf45 100644
--- a/src/Common/src/TypeSystem/IL/DelegateInfo.cs
+++ b/src/Common/src/TypeSystem/IL/DelegateInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
+
using Internal.IL.Stubs;
using Internal.TypeSystem;
@@ -23,9 +25,9 @@ namespace Internal.IL
private DelegateThunkCollection _thunks;
/// <summary>
- /// Gets the Delegate.GetThunk override implementation for this delegate type.
+ /// Gets the synthetic methods that support this delegate type.
/// </summary>
- public MethodDesc GetThunkMethod
+ public IEnumerable<MethodDesc> Methods
{
get
{
@@ -34,7 +36,15 @@ namespace Internal.IL
Interlocked.CompareExchange(ref _getThunkMethod, new DelegateGetThunkMethodOverride(this), null);
}
- return _getThunkMethod;
+ yield return _getThunkMethod;
+
+ DelegateThunkCollection thunks = Thunks;
+ for (DelegateThunkKind kind = 0; kind < DelegateThunkCollection.MaxThunkKind; kind++)
+ {
+ MethodDesc thunk = thunks[kind];
+ if (thunk != null)
+ yield return thunk;
+ }
}
}
@@ -93,6 +103,8 @@ namespace Internal.IL
/// </summary>
public class DelegateThunkCollection
{
+ public const DelegateThunkKind MaxThunkKind = DelegateThunkKind.ObjectArrayThunk + 1;
+
private MethodDesc _openStaticThunk;
private MethodDesc _multicastThunk;
private MethodDesc _closedStaticThunk;
diff --git a/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
index abb60e283..af8cb9a05 100644
--- a/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
+++ b/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
@@ -911,16 +911,14 @@ namespace Internal.IL.Stubs
public override MethodIL EmitIL()
{
- const DelegateThunkKind maxThunkKind = DelegateThunkKind.ObjectArrayThunk + 1;
-
ILEmitter emitter = new ILEmitter();
var codeStream = emitter.NewCodeStream();
ILCodeLabel returnNullLabel = emitter.NewCodeLabel();
- ILCodeLabel[] labels = new ILCodeLabel[(int)maxThunkKind];
- for (DelegateThunkKind i = 0; i < maxThunkKind; i++)
+ ILCodeLabel[] labels = new ILCodeLabel[(int)DelegateThunkCollection.MaxThunkKind];
+ for (DelegateThunkKind i = 0; i < DelegateThunkCollection.MaxThunkKind; i++)
{
MethodDesc thunk = _delegateInfo.Thunks[i];
if (thunk != null)
@@ -934,7 +932,7 @@ namespace Internal.IL.Stubs
codeStream.Emit(ILOpcode.br, returnNullLabel);
- for (DelegateThunkKind i = 0; i < maxThunkKind; i++)
+ for (DelegateThunkKind i = 0; i < DelegateThunkCollection.MaxThunkKind; i++)
{
MethodDesc thunk = _delegateInfo.Thunks[i];
if (thunk != null)
diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.cs b/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.cs
index 37ceff9f3..b224f558f 100644
--- a/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.cs
@@ -351,17 +351,19 @@ namespace ILCompiler
protected virtual IEnumerable<MethodDesc> GetAllMethodsForDelegate(TypeDesc type)
{
- // Inject the synthetic GetThunk virtual override
+ // Inject the synthetic methods that support the implementation of the delegate.
InstantiatedType instantiatedType = type as InstantiatedType;
if (instantiatedType != null)
{
DelegateInfo info = GetDelegateInfo(type.GetTypeDefinition());
- yield return GetMethodForInstantiatedType(info.GetThunkMethod, instantiatedType);
+ foreach (MethodDesc syntheticMethod in info.Methods)
+ yield return GetMethodForInstantiatedType(syntheticMethod, instantiatedType);
}
else
{
DelegateInfo info = GetDelegateInfo(type);
- yield return info.GetThunkMethod;
+ foreach (MethodDesc syntheticMethod in info.Methods)
+ yield return syntheticMethod;
}
// Append all the methods defined in metadata
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs
index 8919c9882..8ebdfa051 100644
--- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/GenericDictionaryNode.cs
@@ -237,6 +237,9 @@ namespace ILCompiler.DependencyAnalysis
}
}
+ // Make sure the dictionary can also be populated
+ dependencies.Add(factory.ShadowConcreteMethod(_owningMethod), "Dictionary contents");
+
return dependencies;
}
diff --git a/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs b/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs
index 9c1243223..2691f216a 100644
--- a/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs
+++ b/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs
@@ -563,7 +563,7 @@ namespace Internal.IL
_dependencies.Add(instParam, reason);
}
- _dependencies.Add(_factory.RuntimeDeterminedMethod(runtimeDeterminedMethod), reason);
+ _dependencies.Add(_factory.CanonicalEntrypoint(targetMethod), reason);
}
else
{
diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs
index d71b9a8f1..027343539 100644
--- a/src/JitInterface/src/CorInfoImpl.cs
+++ b/src/JitInterface/src/CorInfoImpl.cs
@@ -3122,29 +3122,9 @@ namespace Internal.JitInterface
// (Note: The generic lookup in R2R is performed by a call to a helper at runtime, not by
// codegen emitted at crossgen time)
- MethodDesc contextMethod = methodFromContext(pResolvedToken.tokenContext);
-
- // Do not bother capturing the runtime determined context if we're inlining. The JIT is going
- // to abort the inlining attempt if the inlinee does any generic lookups.
- bool inlining = contextMethod != MethodBeingCompiled;
-
- // If we resolved a constrained call, calling GetRuntimeDeterminedObjectForToken below would
- // result in getting back the unresolved target. Don't capture runtime determined dependencies
- // in that case and rely on the dependency analysis computing them based on seeing a call to the
- // canonical method body.
- // Same applies to array address method (the method doesn't actually do any generic lookups).
- if (targetMethod.IsSharedByGenericInstantiations && !inlining && !resolvedConstraint && !referencingArrayAddressMethod)
- {
- MethodDesc runtimeDeterminedMethod = (MethodDesc)GetRuntimeDeterminedObjectForToken(ref pResolvedToken);
- pResult.codePointerOrStubLookup.constLookup =
- CreateConstLookupToSymbol(_compilation.NodeFactory.RuntimeDeterminedMethod(runtimeDeterminedMethod));
- }
- else
- {
- Debug.Assert(!forceUseRuntimeLookup);
- pResult.codePointerOrStubLookup.constLookup =
- CreateConstLookupToSymbol(_compilation.NodeFactory.MethodEntrypoint(targetMethod));
- }
+ Debug.Assert(!forceUseRuntimeLookup);
+ pResult.codePointerOrStubLookup.constLookup =
+ CreateConstLookupToSymbol(_compilation.NodeFactory.MethodEntrypoint(targetMethod));
}
else
{