Skip to content

Commit 8ec531d

Browse files
MethodEntrypointOrTentativeMethod should tolerate same entrypoints for different MethodDescs (#121703)
Ran into this as I was trying something with #121456. That PR introduces a situation where two MethodDescs could map to the same EntryPoint. We didn't previously have that since MethodEntrypointOrTentativeMethod doesn't support unboxing thunks (that do a similar trick). Without this fix we would end up with two `TentativeInstanceMethodNode` that point to the same EntryPoint and that doesn't lead to anything good. These need to be 1:1 with entrypoints. Cc @dotnet/ilc-contrib
1 parent 23a83bc commit 8ec531d

File tree

1 file changed

+4
-4
lines changed
  • src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ private void CreateNodeCaches()
305305
tentative.RealBody : (IMethodBodyNode)entrypoint);
306306
});
307307

308-
_tentativeMethods = new NodeCache<MethodDesc, TentativeInstanceMethodNode>(method =>
308+
_tentativeMethods = new NodeCache<IMethodBodyNode, TentativeInstanceMethodNode>(method =>
309309
{
310-
return new TentativeInstanceMethodNode((IMethodBodyNode)MethodEntrypoint(method));
310+
return new TentativeInstanceMethodNode(method);
311311
});
312312

313313
_unboxingStubs = new NodeCache<MethodDesc, IMethodNode>(CreateUnboxingStubNode);
@@ -1106,14 +1106,14 @@ public IMethodNode TentativeMethodEntrypoint(MethodDesc method, bool unboxingStu
11061106
return _tentativeMethodEntrypoints.GetOrAdd(method);
11071107
}
11081108

1109-
private NodeCache<MethodDesc, TentativeInstanceMethodNode> _tentativeMethods;
1109+
private NodeCache<IMethodBodyNode, TentativeInstanceMethodNode> _tentativeMethods;
11101110
public IMethodNode MethodEntrypointOrTentativeMethod(MethodDesc method, bool unboxingStub = false)
11111111
{
11121112
// We might be able to optimize the method body away if the owning type was never seen as allocated.
11131113
if (method.NotCallableWithoutOwningEEType() && CompilationModuleGroup.AllowInstanceMethodOptimization(method))
11141114
{
11151115
Debug.Assert(!unboxingStub);
1116-
return _tentativeMethods.GetOrAdd(method);
1116+
return _tentativeMethods.GetOrAdd((IMethodBodyNode)MethodEntrypoint(method, unboxingStub));
11171117
}
11181118

11191119
return MethodEntrypoint(method, unboxingStub);

0 commit comments

Comments
 (0)