Skip to content

Conversation

@stevenfontanella
Copy link
Member

@stevenfontanella stevenfontanella commented Jan 2, 2026

Part of #8165. Adds support for parsing and serializing the text and binary formats for memory orderings for loads. The C and JS apis are left unchanged, they'll be updated for all atomic operations in the same commit later. test/passes was updated using python3 scripts/auto_update_tests.py wasm-opt.

@stevenfontanella stevenfontanella linked an issue Jan 2, 2026 that may be closed by this pull request
stevenfontanella added a commit that referenced this pull request Jan 2, 2026
Supplement to #8169. We're adding a MemoryOrder field in Loads (as well
as other memory accesses) to support relaxed atomics in #8165. Only
touching loads here to get feedback before handling the remaining memory
operations.
@stevenfontanella stevenfontanella force-pushed the relaxed-atomics-cp branch 15 times, most recently from 5e2de8f to b92a217 Compare January 7, 2026 07:56
@stevenfontanella stevenfontanella marked this pull request as ready for review January 7, 2026 19:46
Copy link
Member Author

Choose a reason for hiding this comment

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

Will update this to match the structure that we chatted about. In the meantime, this should cover all of the logic from this PR.

Copy link
Member

Choose a reason for hiding this comment

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

It would be great to port this test to lit+FileCheck as a preliminary PR. scripts/port_passes_tests_to_lit.py can help.

void printMemoryOrder(MemoryOrder order) {

void
printMemoryOrder(MemoryOrder order, bool prependSpace, bool appendSpace) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should be able to update the callers of printMemoryOrder so it can just unconditionally prepend the space if it prints anything and never append a space afterward. That would be much simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

it can just unconditionally prepend the space if it prints anything

Do you mean to only prepend a space if something was printed, or to always prepend a space no matter what? I think the former doesn't work because here for example, we need a space between the memory ordering and the heap type name, but if printMemoryOrder didn't print anything, then the space is not needed, and we can't tell which one it is from the caller.

I think it would work to always prepend a space even for empty cases, and then only append a space for acqrel. It's just a little strange that it prints an empty space in the case of seqcst and unordered. Would that way be better?

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean to only prepend a space if something was printed, or to always prepend a space no matter what?

Only if we will print something. In the code you linked to, you would have to remove the spaces that are already printed before the memory ordering and newly print a space afterward. That space afterward will be the only space separating the heap type name from either the instruction name or the memory order, depending on what was last printed.

Copy link
Member

Choose a reason for hiding this comment

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

It would also be good to check basic parsing and printing and round-tripping in a new test in test/lit/basic. See e.g. test/lit/basic/exact-imports.wast for the standard RUN lines.

Once it is ready, landing the spec test here in test/spec is good, but as a follow-up at some point it would also be good to upstream the test. It should be added to the shared-everything-threads repo, then shared-everything-threads should be added to the list of repos pulled into the testsuite repo. Finally, our testsuite submodule can be updated and we can remove the version of the test in test/spec.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, upstreaming the spec test is my plan (I spoke with Rezvan about this as well). Thanks for the details! I'll also add the lit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for acquire/release semantics in atomics

3 participants