Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move the condition into is_direct_callable
  • Loading branch information
kotlarmilos committed Mar 1, 2023
commit 1a182a12095479f77bed47557d8febabdc5779ce
20 changes: 9 additions & 11 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -6287,6 +6287,8 @@ is_direct_callable (MonoAotCompile *acfg, MonoMethod *method, MonoJumpInfo *patc
if (direct_callable && !strcmp (callee_cfg->method->name, ".cctor"))
direct_callable = FALSE;

if (direct_callable && (m_class_has_cctor (method->klass) || !mono_aot_can_specialize (callee_cfg->method)))
direct_callable = FALSE;
//
// FIXME: Support inflated methods, it asserts in mini_llvm_init_gshared_method_this () because the method is not in
// amodule->extra_methods.
Expand Down Expand Up @@ -6589,18 +6591,14 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui
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)) {
MonoCompile *callee_cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, cmethod);
char *name = mono_aot_get_mangled_method_name (cmethod);
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);

// Enable direct call transformation where caller's class requires no initialization and callee can specialize
if (!m_class_has_cctor (method->klass) && mono_aot_can_specialize (cmethod)) {
char *name = mono_aot_get_mangled_method_name (cmethod);
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);

direct_call = TRUE;
direct_call_target = callee_cfg->asm_symbol;
patch_info->type = MONO_PATCH_INFO_NONE;
acfg->stats.direct_calls ++;
}
direct_call = TRUE;
direct_call_target = callee_cfg->asm_symbol;
patch_info->type = MONO_PATCH_INFO_NONE;
acfg->stats.direct_calls ++;
}

acfg->stats.all_calls ++;
Expand Down