Skip to content

Commit

Permalink
Unify the virtual/non-virtual case for llvmonly as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
vargaz committed Mar 12, 2023
1 parent 3a40300 commit 320236b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
16 changes: 6 additions & 10 deletions src/mono/mono/mini/llvmonly-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ mini_llvmonly_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo *info)
ERROR_DECL (error);
MonoFtnDesc *ftndesc;

if (info && info->is_virtual) {
del->method = mono_object_get_virtual_method_internal (del->target, info->method);
/* Create a new one below for the new class+method pair */
info = NULL;
}

if (!info && !del->method) {
// Multicast delegate init
// Have to set the invoke_impl field
Expand Down Expand Up @@ -823,16 +829,6 @@ mini_llvmonly_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo *info)
del->invoke_impl = ftndesc;
}

void
mini_llvmonly_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method)
{
g_assert (target);

del->method = mono_object_get_virtual_method_internal (target, method);

mini_llvmonly_init_delegate (del, NULL);
}

/*
* resolve_iface_call:
*
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/mini/llvmonly-runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ G_EXTERN_C MonoFtnDesc* mini_llvmonly_resolve_generic_virtual_call (MonoVTable *
G_EXTERN_C MonoFtnDesc* mini_llvmonly_resolve_generic_virtual_iface_call (MonoVTable *vt, int imt_slot, MonoMethod *imt_method);
G_EXTERN_C MonoFtnDesc* mini_llvmonly_resolve_vcall_gsharedvt_fast (MonoObject *this_obj, int slot);
G_EXTERN_C void mini_llvmonly_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo *info);
G_EXTERN_C void mini_llvmonly_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method);

/* Used for regular llvm as well */
G_EXTERN_C void mini_llvm_init_method (MonoAotFileInfo *info, gpointer aot_module, gpointer method_info, MonoVTable *vtable);
Expand Down
21 changes: 6 additions & 15 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3662,7 +3662,7 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
if (!obj)
return NULL;

/* Inline the contents of mono_delegate_ctor */
/* Inline the contents of mini_init_delegate */

/* Set target field */
/* Optimize away setting of NULL target */
Expand All @@ -3684,20 +3684,11 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
info_ins = emit_get_rgctx_dele_tramp_info (cfg, target_method_context_used | invoke_context_used, klass, method, is_virtual, MONO_RGCTX_INFO_DELEGATE_TRAMP_INFO);

if (cfg->llvm_only) {
if (is_virtual) {
MonoInst *args [ ] = {
obj,
target,
emit_get_rgctx_method (cfg, target_method_context_used, method, MONO_RGCTX_INFO_METHOD)
};
mono_emit_jit_icall (cfg, mini_llvmonly_init_delegate_virtual, args);
} else {
MonoInst *args [] = {
obj,
info_ins
};
mono_emit_jit_icall (cfg, mini_llvmonly_init_delegate, args);
}
MonoInst *args [] = {
obj,
info_ins
};
mono_emit_jit_icall (cfg, mini_llvmonly_init_delegate, args);
return obj;
}

Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5001,7 +5001,6 @@ register_icalls (void)
/* This needs a wrapper so it can have a preserveall cconv */
register_icall (mini_llvmonly_init_vtable_slot, mono_icall_sig_ptr_ptr_int, FALSE);
register_icall (mini_llvmonly_init_delegate, mono_icall_sig_void_object_ptr, TRUE);
register_icall (mini_llvmonly_init_delegate_virtual, mono_icall_sig_void_object_object_ptr, TRUE);
register_icall (mini_llvmonly_throw_nullref_exception, mono_icall_sig_void, TRUE);
register_icall (mini_llvmonly_throw_aot_failed_exception, mono_icall_sig_void_ptr, TRUE);
register_icall (mini_llvmonly_interp_entry_gsharedvt, mono_icall_sig_void_ptr_ptr_ptr, TRUE);
Expand Down

0 comments on commit 320236b

Please sign in to comment.