feat: Component Model Proposal and WASI Preview 2 in WasmEdge
Currently, all component model PRs will be merged into dev/component after reviewing.
Contribution
To contribute the component-model implmentation, please follow the steps, or the PR would be closed directly.
- PR should base on the
dev/componentbranch. - Follow the contribution requirements: linting pass and DCO.
Summary
This issue is for tracking the implmentation status of Component Model proposal and WASI preview 2.
Component Model Implementation
Current implementation status
✅ Full · Partial · ❌ None · — N/A
| Partition | Load | Validate | Instantiate | Execute |
|---|---|---|---|---|
| CoreModuleSection | ||||
| └ Module | ✅ | ✅ | ✅ | ✅ |
| CoreInstanceSection | ||||
| └ Instantiate | ✅ | ✅ | ✅ | — |
| └ InlineExports | ✅ | ✅ | ✅ | — |
| CoreTypeSection | ||||
| └ RecType | ✅ | ✅ | ✅ | — |
| └ ModuleType | ✅ | ✅ | ✅ | — |
| ComponentSection | ||||
| └ Component (recursive) | ✅ | ✅ | ✅ | ✅ |
| InstanceSection | ||||
| └ Instantiate | ✅ | ✅ | ✅ | — |
| └ InlineExports | ✅ | ✅ | ✅ | — |
| AliasSection | ||||
| └ Export | ✅ | ✅ | ✅ | — |
| └ CoreExport | ✅ | ✅ | ✅ | — |
| └ Outer | ✅ | ✅ | ✅ | — |
| TypeSection | ||||
| └ PrimValType | ✅ | ✅ | ✅ | ✅ |
| └ RecordTy | ✅ | ✅ | ✅ | ✅ |
| └ VariantTy | ✅ | ✅ | ✅ | ✅ |
| └ ListTy | ✅ | ✅ | ✅ | ✅ |
| └ TupleTy | ✅ | ✅ | ✅ | ✅ |
| └ FlagsTy | ✅ | ✅ | ✅ | ✅ |
| └ EnumTy | ✅ | ✅ | ✅ | ✅ |
| └ OptionTy | ✅ | ✅ | ✅ | ✅ |
| └ ResultTy | ✅ | ✅ | ✅ | ✅ |
| └ OwnTy | ✅ | ✅ | ✅ | ✅ |
| └ BorrowTy | ✅ | ✅ | ✅ | ✅ |
| └ MapTy | ✅ | ✅ | ✅ | ✅ |
| └ StreamTy | ✅ | ✅ | ✅ | ✅ |
| └ FutureTy | ✅ | ✅ | ✅ | ✅ |
| └ FuncType | ✅ | ✅ | ✅ | — |
| └ ComponentType | ✅ | ✅ | ✅ | — |
| └ InstanceType | ✅ | ✅ | ✅ | — |
| └ ResourceType | ✅ | ✅ | ✅ | — |
| CanonSection | ||||
| └ lift | ✅ | ✅ | ✅ ¹ | ✅ |
| └ lower | ✅ | ✅ | ✅ ¹ | ✅ |
| └ resource.new | ✅ | ✅ | ✅ | ✅ |
| └ resource.drop | ✅ | ✅ | ✅ | ✅ |
| └ resource.rep | ✅ | ✅ | ✅ | ✅ |
| └ backpressure.inc / backpressure.dec | ✅ | ✅ | ✅ | ✅ |
| └ task.return / task.cancel | ✅ | ✅ | ✅ | ✅ |
| └ context.get / context.set | ✅ | ✅ | ✅ | ✅ |
| └ yield | ✅ | ✅ | ✅ | ✅ |
| └ subtask.* | ✅ | ✅ | ✅ | ✅ |
| └ stream.* | ✅ | ✅ | ✅ | ✅ |
| └ future.* | ✅ | ✅ | ✅ | ✅ |
| └ error-context.* | ✅ | ✅ | ✅ | ✅ |
| └ waitable-set.* | ✅ | ✅ | ✅ | ✅ |
| └ waitable.join | ✅ | ✅ | ✅ | ✅ |
| └ thread.index / thread.new-indirect / thread.resume-later | ✅ | ✅ | ✅ | ✅ |
| └ thread.suspend / thread.{suspend,yield}-then-{resume,promote} | ✅ | ✅ | ✅ | ✅ |
| └ thread.spawn_ref / thread.spawn_indirect / thread.available_parallelism | ✅ | ❌ ² | ❌ ² | ❌ ² |
| StartSection | ||||
| └ Start | ✅ | ✅ | ✅ | ✅ |
| ImportSection | ||||
| └ Import | ✅ | ✅ | ³ | — |
| ExportSection | ||||
| └ Export | ✅ | ✅ | ✅ | — |
| ValueSection | ||||
| └ Value | ✅ | ✅ | ✅ | ✅ |
¹ The canonical ABI over a 64-bit linear memory validates, but instantiation still rejects it with "canonical ABI over a 64-bit memory is not implemented". ² The shared-everything-threads (②) built-ins are decoded by the loader, and the validator rejects them as not supported yet. That proposal is out of scope for this PR. ³ Every sort is wired at runtime — func, type, instance, component, and core module — and an abstract resource import mints a fresh opaque host identity. The value sort has no host-side provider, so a value import is still rejected as not found.
Current spec tests passing status (base on PR 5170)
WasmEdge used the tests from wasm-tools on component-model proposal repo for the spec tests. The test suites are converted into the json+wasm files under the component-model folder of WasmEdge-spectest repo.
✅ Pass · — Not covered by this suite · ❌ Fail
¹ Listed in the upstream test/nyi.txt: no engine implements these yet. They need a spawned thread to stay alive across two separate host calls, which the teardown at the outermost embedder invoke does not support.
Tracking issues for phases
- Spec tests architecture
- #4695
- #4712
- Loader
- #4276
- #4702
- Validator
- #4441
- Instantiation and Executor
- #4711
WASI Preview2
We are working on architecture tests for the WASI 0.2 API. We plan to implement wasi-random and wasi-clocks first for validation before rolling out the full implementation.
| WASI 0.2 APIs | Status |
|---|---|
| wasi-io | ❌ |
| wasi-clocks | ❌ |
| wasi-random | ❌ |
| wasi-filesystem | ❌ |
| wasi-sockets | ❌ |
| wasi-cli | ❌ |
| wasi-http | ❌ |
Appendix
Links
- Previous component model issue: #2943
- Previous WASI preview2 issue: #2939
- Working branch:
proposal/component,proposal/wasi_preview2
Previous issues:
- Loader:
- #4123
- #4127
- #4148
- #4162
- #4173
- Validator:
- #4044
- #3150
- #4173
- #4268
- #4442
- #4528
- #4529
- #4601
- #4612
- Executor
- #3151
- #4275
- #4321
- #4333
- #4334
- Fix or related PRs
- #4287
- Tests
- #4444
- #4625
- #4666
- #4667
Source: WasmEdge/WasmEdge