Repository navigation
wat-writer.cc: update text serialization of data memuse - #2501
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Are there not spec tests that cover this case ?
Unfortunately I don't think there's a spec test that would make us parse the Wasm 1.0 format when using multi-memory by itself. We could have caught this with a roundtrip test, but I don't think we roundtrip every spec test -- only the actual roundtrip tests. And I think it would have had to be a roundtrip test that uses multi-memory and has |
|
we probably should roundtrip every test - it's what the spec does, as far as we can tell. but that's a whole undertaking... |
|
I agree that would be great (at least for valid modules) -- if it doesn't blow up testing time too much. We could make it an optional test chosen by an environment variable and run it in CI. If we want to catch everything, ideally we'd be roundtripping with and without folding, with and without debug-names, with and without generate-names, with and without a roundtrip through the spec interpreter's (or wasm-tools's) text-to-binary and binary-to-text pipelines (since we sometimes have an out-of-date binary encoding of something that we don't catch because WABT's writer and reader are consistent). |
wat-writer.cc currently prints active data segments (targeting a non-0 memory) using the Wasm 1.0 format:
(data 𝑥:memidx_𝐼 ...)... but the multi-memory feature really requires the current format:
This PR adjusts wat-writer.cc to print data segments (that target a non-0 memory) with the post-1.0 syntax. This only affects modules that use multi-memory feature so I don't think it will break anything.
Before this PR, WABT wasn't able to roundtrip this module with debug-names enabled:
... because after round-tripping it would be printed like this (which is invalid because it's parsed so that the data segment itself has id $k but the memuse is memory 0 which is indexed by i32):
After this PR, it gets round-tripped like this: