diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index d54b3137a0f77..5125541551b1d 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -168,14 +168,16 @@ get_delegate_invoke_impl (gboolean has_target, gboolean param_count, guint32 *co MINI_BEGIN_CODEGEN (); if (has_target) { - start = code = mono_global_codeman_reserve (12); + int size = 16; + start = code = mono_global_codeman_reserve (size); /* Replace the this argument with the target */ + arm_dmb (code, ARM_DMB_ISHLD); arm_ldrx (code, ARMREG_IP0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); arm_ldrx (code, ARMREG_R0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, target)); code = mono_arm_emit_brx (code, ARMREG_IP0); - g_assert ((code - start) <= 12); + g_assert ((code - start) <= size); } else { int size, i; diff --git a/src/mono/mono/mini/mini-trampolines.c b/src/mono/mono/mini/mini-trampolines.c index ebb21872aa232..d4506c347812d 100644 --- a/src/mono/mono/mini/mini-trampolines.c +++ b/src/mono/mono/mini/mini-trampolines.c @@ -1122,6 +1122,8 @@ mono_delegate_trampoline (host_mgreg_t *regs, guint8 *code, gpointer *arg, guint code = (guint8 *)mini_add_method_trampoline (m, code, mono_method_needs_static_rgctx_invoke (m, FALSE), FALSE); } + mono_memory_barrier (); + delegate->invoke_impl = mono_get_addr_from_ftnptr (code); if (enable_caching && !callvirt && tramp_info->method) { tramp_info->method_ptr = delegate->method_ptr;