-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mono] Extend mono_gsharedvt_constrained_call JIT icall to handle static virtual methods #90875
[mono] Extend mono_gsharedvt_constrained_call JIT icall to handle static virtual methods #90875
Conversation
Tagging subscribers to 'os-ios': @steveisok, @akoeplinger, @kotlarmilos Issue DetailsThis PR extends Hopefully fixes #90732
|
Can you also add the testcase here? |
Good idea. We will add a test case once we confirm this is the right fix. |
src/mono/mono/mini/jit-icalls.c
Outdated
@@ -1449,8 +1449,8 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl | |||
m = info->method; | |||
break; | |||
default: | |||
/* Object.GetType () is an intrinsic under netcore */ | |||
if (!mono_class_is_ginst (cmethod->klass) && !cmethod->is_inflated && !strcmp (cmethod->name, "GetType")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this code was a special case for call to Object.GetType ()
by returning vt->type
. Your change just makes every static virtual call do the same thing instead of running the actual method !?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here is the reasoning behind this change. Before the optimization of constrained calls from gshared methods in #79339, the type was retrieved as vt = mono_class_vtable_checked (klass, error);
, in the same way as it is done here. After that, in #65126 arguments of static virtual methods are handled in the same way as for Object.GetType ()
:
runtime/src/mono/mono/mini/method-to-ir.c
Lines 3857 to 3858 in 5d00fc5
/* !fsig->hasthis is for the wrapper for the Object.GetType () icall or static virtual methods */ | |
if ((fsig->hasthis || m_method_is_static (cmethod)) && fsig->param_count) { |
Additionally, there is a note that the mp is null in case of static virtual methods, which is why the constrained_gsharedvt_call_setup
fails:
runtime/src/mono/mono/mini/jit-icalls.c
Lines 1423 to 1433 in 5d00fc5
/* | |
* mono_gsharedvt_constrained_call: | |
* | |
* Make a call to CMETHOD using the receiver MP, which is assumed to be of type KLASS. ARGS contains | |
* the arguments to the method in the format used by mono_runtime_invoke_checked (). | |
* MP is NULL if CMETHOD is a static virtual method. | |
*/ | |
MonoObject* | |
mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *klass, | |
MonoGsharedvtConstrainedCallInfo *info, guint8 *deref_args, gpointer *args) | |
{ |
My assumption was that it shouldn't reach the constrained_gsharedvt_call_setup
in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After offline discussion, the above ^ was a wild assumption :) The static methods should be handled in constrained_gsharedvt_call_setup as @BrzVlad suggested.
As far as my understanding goes, when you get below to |
Thanks for feedback! It should be already handled here: runtime/src/mono/mono/mini/jit-icalls.c Lines 1377 to 1390 in 5d00fc5
Do you think we can avoid |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
public class test | ||
{ | ||
[Fact] | ||
public static int TestEntryPoint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems quite trivial. Would it even fail on CI ? Or is the failure dependent on compilation flags that we don't use on CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue occurred in full AOT mode only. This test is used locally to reproduce and fix the issue, which is similar to the customer reported issue. Do you think it should be expanded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you disable your fix will this test fail on CI currently ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before adding a new test, we should verify if it is not already covered on the CI. This will be done once the AOT job is fixed. The customer issue won't be closed until we verify that this case has test coverage.
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/5964549560 |
This PR extends
mono_gsharedvt_constrained_call
JIT icall to handle static virtual methods. If cmethod is a static virtual method,this
arg should be null.Contributes to #90732