-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[mono][aot] Enable direct call transformation for MONO_PATCH_INFO_METHOD #82711
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
Changes from 2 commits
9c91a8e
8f995a1
882353e
1a182a1
282fb7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6588,12 +6588,10 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui | |
| direct_call_target = symbol; | ||
| patch_info->type = MONO_PATCH_INFO_NONE; | ||
| } else if ((m_class_get_image (patch_info->data.method->klass) == acfg->image) && !got_only && is_direct_callable (acfg, method, patch_info)) { | ||
| #if 0 | ||
| // FIXME: Currently not used. It fails as some callees require initialization. | ||
| MonoCompile *callee_cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, cmethod); | ||
|
|
||
| // Don't compile inflated methods if we're doing dedup | ||
| if (acfg->aot_opts.dedup && !mono_aot_can_dedup (cmethod)) { | ||
| // Enable direct call transformation where caller's class requires no initialization and callee can specialize | ||
| if (!m_class_has_static_refs (method->klass) && mono_aot_can_specialize (cmethod)) { | ||
| char *name = mono_aot_get_mangled_method_name (cmethod); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looked into why this was not enabled before, and i don't think this is going to work. The callee method might use GOT slots etc. which are not initialized if the method is directly called. So before this can be enabled, the AOTed code needs to be changed to init itself, the same way the llvm compiled code does.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Let's first try to enable method initialization during the invocation before proceeding with this and other direct call transformations. |
||
| mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "DIRECT CALL: %s by %s", name, method ? mono_method_full_name (method, TRUE) : ""); | ||
| g_free (name); | ||
|
|
@@ -6603,7 +6601,6 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui | |
| patch_info->type = MONO_PATCH_INFO_NONE; | ||
| acfg->stats.direct_calls ++; | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| acfg->stats.all_calls ++; | ||
|
|
||
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.
has_static_refs () means the class has static reference fields, not that it has an initializer.
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 assumption is that if a caller method has static reference fields it requires initialization. Is there a better way to check if the caller method has to be initialized?
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.
m_class_has_cctor (method->klass) will return whenever the class has a static ctor.
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.
Why is this condition required ?
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 PR enables direct call transformation for
MONO_PATCH_INFO_METHOD. If a caller requires initialization but got transformed, it fails withSIGSEGVas static fields are null. If a called method is invoked by reflection or can be invoked externally, it can't be transformed.m_class_has_cctorchecks if the caller requires no initialization, whilemono_aot_can_specializechecks if the called method isn't called externally or by using reflection.Does that make sense?
Uh oh!
There was an error while loading. Please reload this page.
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.
Actually it might be good to add it tois_direct_callable.