Skip to content

Commit

Permalink
[mono] Fix delegate invokes to dynamic methods in mixed mode. (#50547)
Browse files Browse the repository at this point in the history
In mixed mode, when compiling a call to a delegate invoke, add
an interp entry wrapper for the signature used by the actual method
which is called by the invoke, which might be a dynamic method whose
signature is otherwise not present in the program.
  • Loading branch information
vargaz authored Apr 5, 2021
1 parent 240fcec commit 59c592c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mono/mono/mini/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,17 @@ mini_emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMeth
int offset;
gboolean special_array_interface = m_class_is_array_special_interface (cmethod->klass);

if (cfg->interp && can_enter_interp (cfg, cmethod, TRUE))
if (cfg->interp && can_enter_interp (cfg, cmethod, TRUE)) {
/* Need wrappers for this signature to be able to enter interpreter */
cfg->interp_in_signatures = g_slist_prepend_mempool (cfg->mempool, cfg->interp_in_signatures, fsig);

if (m_class_is_delegate (cmethod->klass) && !strcmp (cmethod->name, "Invoke")) {
/* To support dynamically generated code, add a signature for the actual method called by the delegate as well. */
MonoMethodSignature *nothis_sig = mono_metadata_signature_dup_add_this (m_class_get_image (cmethod->klass), fsig, mono_get_object_class ());
cfg->interp_in_signatures = g_slist_prepend_mempool (cfg->mempool, cfg->interp_in_signatures, nothis_sig);
}
}

/*
* In llvm-only mode, vtables contain function descriptors instead of
* method addresses/trampolines.
Expand Down

0 comments on commit 59c592c

Please sign in to comment.