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

[wasm] Implement MONO_MEMORY_BARRIER in jiterpreter #107325

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
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: 5 additions & 1 deletion src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3977,8 +3977,12 @@ function emit_atomics (
builder: WasmBuilder, ip: MintOpcodePtr, opcode: number
) {
if (opcode === MintOpcode.MINT_MONO_MEMORY_BARRIER) {
if (WasmEnableThreads)
if (WasmEnableThreads) {
builder.appendAtomic(WasmAtomicOpcode.atomic_fence);
// The text format and other parts of the spec say atomic.fence has no operands,
// but the binary encoding requires a dummy zero byte for some reason
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for the memory ordering. See this part of the shared everythign threads proposal. 0 means sequential consistency, 1 will mean acquire-release https://github.com/WebAssembly/shared-everything-threads/blob/main/proposals/shared-everything-threads/Overview.md#memory-orderings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And sync_synchronize is sequential consistency, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And sync_synchronize is sequential consistency, right?

It's a "full barrier" which presumably means seq cst. https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html

builder.appendU8(0);
}
return true;
}

Expand Down