Skip to content

Commit cf30f80

Browse files
committed
[mono][jit] Add some barriers to the delegate invoke code.
Re: dotnet#81123.
1 parent 61ce091 commit cf30f80

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/mono/mono/mini/mini-arm64.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,16 @@ get_delegate_invoke_impl (gboolean has_target, gboolean param_count, guint32 *co
168168
MINI_BEGIN_CODEGEN ();
169169

170170
if (has_target) {
171-
start = code = mono_global_codeman_reserve (12);
171+
int size = 16;
172+
start = code = mono_global_codeman_reserve (size);
172173

173174
/* Replace the this argument with the target */
175+
arm_dmb (code, ARM_DMB_ISHLD);
174176
arm_ldrx (code, ARMREG_IP0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr));
175177
arm_ldrx (code, ARMREG_R0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, target));
176178
code = mono_arm_emit_brx (code, ARMREG_IP0);
177179

178-
g_assert ((code - start) <= 12);
180+
g_assert ((code - start) <= size);
179181
} else {
180182
int size, i;
181183

src/mono/mono/mini/mini-trampolines.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ mono_delegate_trampoline (host_mgreg_t *regs, guint8 *code, gpointer *arg, guint
11221122
code = (guint8 *)mini_add_method_trampoline (m, code, mono_method_needs_static_rgctx_invoke (m, FALSE), FALSE);
11231123
}
11241124

1125+
mono_memory_barrier ();
1126+
11251127
delegate->invoke_impl = mono_get_addr_from_ftnptr (code);
11261128
if (enable_caching && !callvirt && tramp_info->method) {
11271129
tramp_info->method_ptr = delegate->method_ptr;

0 commit comments

Comments
 (0)