Skip to content

Commit

Permalink
Use fully canonical method in ready to run helpers
Browse files Browse the repository at this point in the history
Helper to call `Foo<string>.Virtual()` and `Foo<object>.Virtual()` is the same. Let's make fewer of them and also avoid helpers for things like `Foo<string, __Canon>.Virtual()` that put weird things in the dependency graph in the process.

Fixes dotnet#5710.
  • Loading branch information
MichalStrehovsky committed Apr 18, 2018
1 parent aa7f41b commit ba639e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ public ReadyToRunHelperNode(NodeFactory factory, ReadyToRunHelperId id, Object t
}
break;
case ReadyToRunHelperId.VirtualCall:
case ReadyToRunHelperId.ResolveVirtualFunction:
{
// Make sure we aren't trying to callvirt Object.Finalize
MethodDesc method = (MethodDesc)target;
if (method.IsFinalizer)
ThrowHelper.ThrowInvalidProgramException(ExceptionStringID.InvalidProgramCallVirtFinalize, method);

// Method should be in fully canonical form. Otherwise we're being wasteful and generate more
// helpers than needed.
Debug.Assert(!method.IsCanonicalMethod(CanonicalFormKind.Any) ||
method.GetCanonMethodTarget(CanonicalFormKind.Specific) == method);
}
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/JitInterface/src/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3355,6 +3355,7 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO
else
{
pResult.exactContextNeedsRuntimeLookup = false;
targetMethod = targetMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);

// Get the slot defining method to make sure our virtual method use tracking gets this right.
// For normal C# code the targetMethod will always be newslot.
Expand Down

0 comments on commit ba639e0

Please sign in to comment.