feat(other): support bulk memory operations proposal (interpreter mode)#432
feat(other): support bulk memory operations proposal (interpreter mode)#432ys8888john wants to merge 2 commits intoDTVMStack:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds interpreter-mode support for WebAssembly bulk memory operations (0xFC-prefixed instructions) and introduces proposal WAST coverage, while explicitly skipping these tests in JIT modes.
Changes:
- Implement decode/validation/execution paths for bulk-memory ops (memory.init/copy/fill, data.drop, table.init/copy, elem.drop) in the interpreter and validators.
- Extend module loading/instantiation to understand active vs passive data/element segments and track dropped segments at runtime.
- Add proposal WAST tests and adjust the spec test generation/runner behavior to accommodate the new proposal.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/wast/spec.patch | Updates upstream spec test patching to align with new element/data segment expectations. |
| tests/wast/proposals/table_init.wast | Adds table.init coverage (bounds, drop behavior, zero-length cases). |
| tests/wast/proposals/table_copy.wast | Adds table.copy coverage (including overlap and bounds). |
| tests/wast/proposals/memory_init.wast | Adds memory.init coverage (bounds, partial init, zero-length). |
| tests/wast/proposals/memory_fill.wast | Adds memory.fill coverage (truncation, bounds, zero-length). |
| tests/wast/proposals/memory_copy.wast | Adds memory.copy coverage (overlap, bounds, zero-length). |
| tests/wast/proposals/elem_drop.wast | Adds elem.drop + post-drop table.init trapping coverage. |
| tests/wast/proposals/data_drop.wast | Adds data.drop + post-drop memory.init trapping coverage. |
| src/utils/wasm.cpp | Extends block-skipping logic to recognize 0xFC-prefixed instructions. |
| src/tests/spec_unit_tests.cpp | Skips bulk-memory proposal tests when disabled or in non-interpreter modes. |
| src/tests/CMakeLists.txt | Stops passing --disable-bulk-memory to wast2json so proposal syntax can be generated. |
| src/runtime/module.h | Adds segment mode tracking and new validation helpers/accessors for elem/data segments. |
| src/runtime/instance.h | Adds dropped-segment tracking APIs/state (guarded by ZEN_ENABLE_BULK_MEMORY). |
| src/runtime/instance.cpp | Frees dropped-segment tracking arrays in Instance destructor. |
| src/common/wasm_defs/opcode.def | Adds symbolic names for bulk-memory operations (project-internal). |
| src/common/errors.def | Adds Unknown*Segment load errors and OutOfBoundsTable execution error. |
| src/common/enums.h | Introduces 0xFC prefix and sub-opcode constants (bulk-memory). |
| src/action/module_loader.cpp | Parses new element/data segment encodings (flags-based) and assigns segment modes. |
| src/action/interpreter.cpp | Executes 0xFC bulk-memory operations in interpreter mode. |
| src/action/instantiator.cpp | Skips passive segments during instantiation and initializes dropped-segment state. |
| src/action/function_loader.cpp | Validates 0xFC instructions during function validation (bulk-memory enabled only). |
| src/action/bytecode_visitor.h | Rejects 0xFC ops in JIT path with a targeted “unsupported” error. |
| src/CMakeLists.txt | Wires ZEN_ENABLE_BULK_MEMORY into compilation defines. |
| CMakeLists.txt | Adds ZEN_ENABLE_BULK_MEMORY option (default ON). |
| .github/workflows/dtvm_wasm_test_x86.yml | Enables bulk-memory in CI test workflow via env var. |
| .ci/run_test_suite.sh | Adds CMake toggle plumbing for ZEN_ENABLE_BULK_MEMORY. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ;; The data segment is active (format 0 with no explicit offset means passive | ||
| ;; in this case since there's no offset expression). Actually this is passive | ||
| ;; because there's no (i32.const X) offset. |
There was a problem hiding this comment.
The comment above the test cases mischaracterizes (data "...") as an active segment. Under the bulk-memory syntax, (data "...") is a passive data segment (active segments have an explicit offset expr). Please update/remove this comment to avoid confusing future maintainers reading these tests.
| ;; The data segment is active (format 0 with no explicit offset means passive | |
| ;; in this case since there's no offset expression). Actually this is passive | |
| ;; because there's no (i32.const X) offset. | |
| ;; The module above declares a passive data segment using `(data "...")`. | |
| ;; Under the bulk-memory proposal, segments without an explicit offset | |
| ;; expression are passive; active segments have an offset expression. |
⚡ Performance Regression Check Results✅ Performance Check Passed (interpreter)Performance Benchmark Results (threshold: 25%)
Summary: 194 benchmarks, 0 regressions ✅ Performance Check Passed (multipass)Performance Benchmark Results (threshold: 25%)
Summary: 194 benchmarks, 0 regressions |
c6e163a to
54fa211
Compare
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
6. Release note