-
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][aot] Optimize constrained calls made from gsharedvt methods. #79339
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
This will also avoid some interpreter transitions on wasm, making the stack traces on BCL test suite crashes etc. smaller. |
4d41c57
to
03a6dcf
Compare
03a6dcf
to
ec5e62d
Compare
The failures look relevant. |
cc @ivanpovazan @jandupej @kotlarmilos @fanyang-mono --fyi |
cbe44f4
to
ef2aec6
Compare
5229775
to
f144a24
Compare
* do an indirect call. | ||
*/ | ||
calls [0] = NULL; | ||
// FIXME: Add more cases |
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.
what would be the additional cases that would fit into the fastpath approach?
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 cases excluded by the if.
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.
I am trying to understand the code and the effect that covering more cases would bring.
f144a24
to
03e2564
Compare
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
Failures are relevant. |
03e2564
to
8088965
Compare
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
Failures are unrelated. |
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
b772123
to
68b30bc
Compare
/* Lookup the virtual method */ | ||
mono_class_setup_vtable (klass); | ||
g_assert (m_class_get_vtable (klass)); | ||
vt_slot = mono_method_get_vtable_slot (cmethod); | ||
if (mono_class_is_interface (cmethod->klass)) { | ||
iface_offset = mono_class_interface_offset (klass, cmethod->klass); | ||
g_assert (iface_offset != -1); | ||
vt_slot += iface_offset; | ||
} | ||
m = m_class_get_vtable (klass) [vt_slot]; | ||
if (cmethod->is_inflated) { | ||
m = mono_class_inflate_generic_method_full_checked (m, NULL, mono_method_get_context (cmethod), error); | ||
return_val_if_nok (error, NULL); | ||
} | ||
|
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.
We don't have some helper function that does this already?
The calls are of the form: .constrained T_GSHAREDVT callvirt <method> Whenever T_GSHAREDVT is a reference or value type is only known at runtime. Previously these were handled by passing the arguments to a JIT icall which computed the target method and did a runtime invoke. Added 2 optimizations: * Precompute the data which depends only on the type and the method, store it in an rgctx slot and pass it to the JIT icall. * Add a fastpath for simpler cases which makes an indirect call from generated code.
68b30bc
to
0033318
Compare
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
Failures are unrelated |
The calls are of the form:
.constrained T_GSHAREDVT
callvirt
Whenever T_GSHAREDVT is a reference or value type is only known at runtime.
Previously these were handled by passing the arguments to a JIT icall which computed the target method and did a runtime invoke.
Add 2 optimizations: