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 (#101290)

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.

Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
  • Loading branch information
github-actions[bot] and BrzVlad committed May 2, 2024
1 parent 9f4259e commit a0411df
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4016,6 +4016,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 a0411df

Please sign in to comment.