Repository navigation
Set resolvedCallvirt if virtual method can be resolved at compile time - #1099
Conversation
Found this with CoreCLR tests. The logic that special cases the delegates expects resolvedCallVirt to be set, but we were never setting it for this case. This pattern was copied from CoreCLR JitInterface and it puzzles me as to how it could possibly work there. We ended up asking for a ReadyToRun helper to resolve the virtual call even though the method was not virtual.
|
LGTM |
| { | ||
| // Delegate targets are always treated as direct calls here. (It would be nice to clean it up...). | ||
| directCall = true; | ||
| resolvedCallVirt = !targetMethod.IsVirtual || targetMethod.IsFinal || targetMethod.OwningType.IsSealed(); |
There was a problem hiding this comment.
There is comment above about getting this cleaned up, and the new line is duplicating condition from a couple of lines below.
Would it be better to get rid of this special treatment and move the check for LDFTN to be later when we are actually creating the entrypoint for JIT to use?
There was a problem hiding this comment.
I would ideally want to fix this in the exact same way CoreCLR handles this, but I can't find where that happens (they clearly don't set the bool on CoreCLR even though they check for it and expect it to represent the reality).
I think there's value in trying to mirror the CoreCLR implementation and don't diverge too much because this method will get more complicated over time and the CoreCLR JitInterface has a decade of bug fixes in it (and admittedly, a decade of legacy quirks).
I will go with this as a minimally invasive fix to the structure of the method. We can always revisit.
There was a problem hiding this comment.
It works in CoreCLR because of it can deal with the virtual call that is not actually one till pretty late and then compensate for it. I do not think it makes sense to do it this way for CoreRT. Also - it make sense to not diverge JIT-EE interface implementation from CoreCLR for no good reason, but I would not write convoluted code to make it match.
This is actually my fault. I have added this hack for delegates when I was refactoring the JIT-EE interface a few years ago but forgot to remove it (TFS changeset 13508).
I have submitted #1106 to cleanup this up.
Found this with CoreCLR tests. The logic that special cases the
delegates expects resolvedCallVirt to be set, but we were never setting
it for this case. This pattern was copied from CoreCLR JitInterface and
it puzzles me as to how it could possibly work there.
We ended up asking for a ReadyToRun helper to resolve the virtual call
even though the method was not virtual.