Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][jit] Add some barriers to the delegate invoke code. #83673

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/mono/mono/mini/mini-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/mini-trampolines.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down