Skip to content

Commit

Permalink
[mono][interp] Resolve virtual method on delegates created by compile…
Browse files Browse the repository at this point in the history
…d code (#101168)

Creating a delegate would normally end up calling into the runtime via ves_icall_mono_delegate_ctor. However, jit/aot backand have a fastpath where the delegate is not fully initialized (relying on the delegate trampoline to resolve the actual method to be called when the delegate is first called). Interp delegate initialization therefore doesn't take place. If this is the case and the delegate method is virtual, we would need to resolve it based on the target object.
  • Loading branch information
BrzVlad committed Apr 17, 2024
1 parent 81ca1c4 commit 2fe9b3b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Expand Up @@ -4098,6 +4098,8 @@ mono_interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClause
// Not created from interpreted code
g_assert (del->method);
del_imethod = mono_interp_get_imethod (del->method);
if (del->target && m_method_is_virtual (del->method))
del_imethod = get_virtual_method (del_imethod, del->target->vtable);
del->interp_method = del_imethod;
del->interp_invoke_impl = del_imethod;
} else {
Expand Down

0 comments on commit 2fe9b3b

Please sign in to comment.