Skip to content

Basic multi-memory proposal support - #383

Open
MaxDesiatov wants to merge 1 commit into
mainfrom
maxd/multi-memory
Open

Basic multi-memory proposal support#383
MaxDesiatov wants to merge 1 commit into
mainfrom
maxd/multi-memory

Conversation

@MaxDesiatov

Copy link
Copy Markdown
Member

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.

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 MaxDesiatov changed the title Multi-memory support first pass Basic multi-memory proposal support Jul 21, 2026
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.
throw makeError(.zeroExpected(actual: zero))
}
return 0
try parseMemoryIndex()

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.

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)

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.

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

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.

Is this related to multi-memory proposal?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants