Skip to content

Support multi-memory in all memory ops and in apply/resolve-names - #1962

Merged
keithw merged 3 commits into
WebAssembly:mainfrom
fix-project:simd-mm-fix
Aug 15, 2022
Merged

keithw merged 3 commits into
WebAssembly:mainfrom
fix-project:simd-mm-fix

Conversation

@keithw

@keithw keithw commented Aug 15, 2022

Copy link
Copy Markdown
Member

Previously, wabt could parse multi-memory SIMD loads/stores but not write them. (The testsuite for the multi-memory proposal doesn't currently test writing or execution of multi-memory SIMD ops, so this is untested. However, it does appear to roundtrip its own output on the "memory-multi" test.)

Closes #1958.

Comment thread src/binary-writer.cc Resolved
@keithw keithw changed the title Support multi-memory SIMD loads/stores in writers and apply-names Support multi-memory in all memory ops (including SIMD loads/stores/splats/etc. and atomics) and in apply/resolve-names Aug 15, 2022
@keithw
keithw marked this pull request as ready for review August 15, 2022 18:51
@keithw keithw changed the title Support multi-memory in all memory ops (including SIMD loads/stores/splats/etc. and atomics) and in apply/resolve-names Support multi-memory in all memory ops and in apply/resolve-names Aug 15, 2022
@keithw

keithw commented Aug 15, 2022 •

Copy link
Copy Markdown
Member Author

Further inspection revealed a large number of additional memory ops (atomics, SIMD splat and zero, etc.) that weren't parsing memidx when the memarg flag was set. The validator also had memidx=0 hardcoded for several of these (including memory.fill).

Just pushed a second commit that tries to handle this comprehensively by always parsing alignment and memidx in the same place, and carrying them together through the binary readers. This should get reviewed again before merging because it's a much bigger change now.

(Edited to add: this also now reflects the updated order of immediates in the binary format in the multi-memory proposal.)

@keithw
keithw requested a review from sbc100 August 15, 2022 18:54
Comment thread src/binary-reader.h Resolved
Comment thread test/spec/memory_fill.txt Resolved
Comment thread src/binary-reader.cc Outdated
CALLBACK(OnAtomicStoreExpr, opcode, alignment_log2, offset);
CALLBACK(OnOpcodeUint32Uint32, alignment_log2, offset);
CALLBACK(OnAtomicStoreExpr, opcode, memidx, alignment_log2, offset);
CHECK_RESULT(CallbackAlignMemOffset(memidx, alignment_log2, offset));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! This change certainly looks like a step in the right direction.

What do you think about combining ReadAlignMem with ReadAddress into a single function ReadMemroyLocation which would replace ReadAlignMem and include the reading of the offset? Could that function also include CallbackAlignMemOffset (removing the need for that new function)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. I couldn't quite combine it with the CallbackAlignMemOffset because that needs to happen after the callback for the actual expression (otherwise all the opcnts and dumps are off), but I was able to clean it up a little.

(The multi-memory proposal tests don't currently test writing or
execution of multi-memory SIMD ops or atomics.)
@keithw
keithw enabled auto-merge (squash) August 15, 2022 21:14

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this!

@keithw
keithw merged commit 8c50fd5 into WebAssembly:main Aug 15, 2022
@keithw
keithw deleted the simd-mm-fix branch August 15, 2022 21:41
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.

Wrong encoding WAT format with the multiple memories proposal

2 participants