Skip to content

Commit

Permalink
[mono][interp] Fix concurrency issues with publishing transfomed imethod
Browse files Browse the repository at this point in the history
When publishing a transformed InterpMethod*, we first set all relevant fields (like `code`, `alloca_size` etc), we execute a write barrier and finally we set the `transformed` flag. On relaxed memory arches we need to have a read barrier on the consumer, since there is no data dependency between `transformed` and the other fields of `InterpMethod`.

On arm this change does a full barrier (we could get away with just a load acquire but we haven't yet added support for emitting this in the runtime). Still, this doesn't seem to introduce a heavy perf penalty (on my arm64 M1) but we can revisit if necessary. On x86/amd64 this is a compiler barrier so it should have no impact. WASM is single threaded for now.
  • Loading branch information
BrzVlad committed Jun 14, 2023
1 parent 6ad0764 commit 160301b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,8 @@ method_entry (ThreadContext *context, InterpFrame *frame,
frame->stack = (stackval*)context->stack_pointer;
return slow;
}
} else {
mono_memory_read_barrier ();
}

return slow;
Expand Down

0 comments on commit 160301b

Please sign in to comment.