Skip to content

Commit 7b82cdf

Browse files
authored
[mono][jit] Add some barriers to the delegate invoke code. (#83673)
Re: #81123.
1 parent e431c00 commit 7b82cdf

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
@@ -170,14 +170,16 @@ get_delegate_invoke_impl (gboolean has_target, gboolean param_count, guint32 *co
170170
MINI_BEGIN_CODEGEN ();
171171

172172
if (has_target) {
173-
start = code = mono_global_codeman_reserve (12);
173+
int size = 16;
174+
start = code = mono_global_codeman_reserve (size);
174175

175176
/* Replace the this argument with the target */
177+
arm_dmb (code, ARM_DMB_ISHLD);
176178
arm_ldrx (code, ARMREG_IP0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr));
177179
arm_ldrx (code, ARMREG_R0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoDelegate, target));
178180
code = mono_arm_emit_brx (code, ARMREG_IP0);
179181

180-
g_assert ((code - start) <= 12);
182+
g_assert ((code - start) <= size);
181183
} else {
182184
int size, i;
183185

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)