Basic multi-memory proposal support - #383
Open
MaxDesiatov wants to merge 1 commit into
Open
Conversation
Add the WebAssembly multi-memory proposal as an opt-in WasmFeatureSet feature. memory.init/copy/fill now carry an explicit memory index through the binary decoder, WAT text parser and encoder, instruction visitor, translator, and runtime; the validator permits multiple memories when `.multiMemory` is set. memory.copy supports two distinct memories with per-memory index-type widening. The VM instruction spec is regenerated via VMGen for the new memory-index operands. Also adds `(module definition ...)` WAST directive parsing and Module.validate() (decode-time validation without instantiation), covered by the new parser and execution tests. Enabling multi-memory for the vendored spec-test suite (which needs a testsuite pin bump) is deferred; default parsing and validation behavior is unchanged.
MaxDesiatov
force-pushed
the
maxd/multi-memory
branch
from
July 22, 2026 08:18
272bfdf to
2b0482d
Compare
| throw makeError(.zeroExpected(actual: zero)) | ||
| } | ||
| return 0 | ||
| try parseMemoryIndex() |
Member
There was a problem hiding this comment.
Should we gate behind the feature flag like what you do for visitMemoryInit?
Comment on lines
+530
to
+532
| // For memory 0, encoding the memory index yields the single 0x00 the pre-multi-memory reserved byte produced. | ||
| hasDataSegmentInstruction = true | ||
| encodeUnsigned(dataIndex) |
Member
There was a problem hiding this comment.
Suggested change
| // For memory 0, encoding the memory index yields the single 0x00 the pre-multi-memory reserved byte produced. | |
| hasDataSegmentInstruction = true | |
| encodeUnsigned(dataIndex) | |
| encodeImmediates(dataIndex: dataIndex) |
| /// The location of the module in the source | ||
| public let location: Location | ||
| /// The `(module definition ...)` form decodes and validates without instantiating. | ||
| public let isModuleDefinition: Bool |
Member
There was a problem hiding this comment.
Is this related to multi-memory proposal?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the WebAssembly multi-memory proposal as an opt-in WasmFeatureSet feature.
memory.init/copy/fillnow carry an explicit memory index through the binary decoder, WAT text parser and encoder, instruction visitor, translator, and runtime; the validator permits multiple memories when.multiMemoryis set.memory.copysupports two distinct memories with per-memory index-type widening. The VM instruction spec is regenerated via VMGen for the new memory-index operands.Enabling multi-memory for the vendored spec-test suite (which needs a testsuite pin bump) is deferred; default parsing and validation behavior is unchanged.