Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/wasmparser/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ define_wasm_features! {
/// Corresponds to the 🚝 character in
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
pub cm_async_builtins: CM_ASYNC_BUILTINS(1 << 29) = false;
/// Gates some intrinsics being marked with `error-context` in the component
/// model async proposal.
///
/// Corresponds to the 📝 character in
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
pub cm_error_context: CM_ERROR_CONTEXT(1 << 30) = false;
}
}

Expand Down
16 changes: 8 additions & 8 deletions crates/wasmparser/src/validator/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,10 +1736,10 @@ impl ComponentState {
offset: usize,
features: &WasmFeatures,
) -> Result<()> {
if !features.cm_async() {
if !features.cm_error_context() {
bail!(
offset,
"`error-context.new` requires the component model async feature"
"`error-context.new` requires the component model error-context feature"
)
}

Expand All @@ -1760,10 +1760,10 @@ impl ComponentState {
offset: usize,
features: &WasmFeatures,
) -> Result<()> {
if !features.cm_async() {
if !features.cm_error_context() {
bail!(
offset,
"`error-context.debug-message` requires the component model async feature"
"`error-context.debug-message` requires the component model error-context feature"
)
}

Expand All @@ -1783,10 +1783,10 @@ impl ComponentState {
offset: usize,
features: &WasmFeatures,
) -> Result<()> {
if !features.cm_async() {
if !features.cm_error_context() {
bail!(
offset,
"`error-context.drop` requires the component model async feature"
"`error-context.drop` requires the component model error-context feature"
)
}

Expand Down Expand Up @@ -3566,10 +3566,10 @@ impl ComponentState {
) -> Result<ComponentDefinedType> {
match ty {
crate::ComponentDefinedType::Primitive(ty) => {
if ty == crate::PrimitiveValType::ErrorContext && !features.cm_async() {
if ty == crate::PrimitiveValType::ErrorContext && !features.cm_error_context() {
bail!(
offset,
"`error-context` requires the component model async feature"
"`error-context` requires the component model error-context feature"
)
}
Ok(ComponentDefinedType::Primitive(ty))
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/component-model-async/task-builtins.wast
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async,cm-async-builtins,cm-async-stackful
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async,cm-async-builtins,cm-async-stackful,cm-error-context

;; backpressure.set
(component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-error-context

;; error-context.new
(component
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/dummy-async-export-future-with-named-type.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: component embed % --dummy-names legacy --async-callback | \
// component new | \
// validate -f cm-async
// validate -f cm-async,cm-error-context

package a:b;

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/dummy-async-export-using-export.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: component embed % --dummy-names legacy --async-callback | \
// component new | \
// validate -f cm-async
// validate -f cm-async,cm-error-context

package a:b;

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/dummy-async-future-with-flags.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: component embed % --dummy-names legacy --async-callback | \
// component new | \
// validate -f cm-async
// validate -f cm-async,cm-error-context

package y:name;

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/dummy-async-resource-with-stream.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: component embed % --dummy-names legacy --async-callback | \
// component new | \
// validate -f cm-async
// validate -f cm-async,cm-error-context

package a:b;

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/dummy-async-resource.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: component embed % --dummy-names legacy --async-callback | \
// component new | \
// validate -f cm-async
// validate -f cm-async,cm-error-context

package a:b;

Expand Down
47 changes: 0 additions & 47 deletions tests/cli/missing-features/component-model/async.wast
Original file line number Diff line number Diff line change
Expand Up @@ -314,49 +314,6 @@
"requires the component model async feature"
)

;; error-context.new
(assert_invalid
(component
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(core module $m
(import "" "error-context.new" (func $error-context-new (param i32 i32) (result i32)))
)
(core func $error-context-new (canon error-context.new (memory $libc "memory")))
(core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new))))))
)
"`error-context.new` requires the component model async feature"
)

;; error-context.debug-message
(assert_invalid
(component
(core module $libc
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
(memory (export "memory") 1)
)
(core instance $libc (instantiate $libc))
(core module $m
(import "" "error-context.debug-message" (func $error-context-debug-message (param i32 i32)))
)
(core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc"))))
(core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message))))))
)
"`error-context.debug-message` requires the component model async feature"
)

;; error-context.drop
(assert_invalid
(component
(core module $m
(import "" "error-context.drop" (func $error-context-drop (param i32)))
)
(core func $error-context-drop (canon error-context.drop))
(core instance $i (instantiate $m (with "" (instance (export "error-context.drop" (func $error-context-drop))))))
)
"`error-context.drop` requires the component model async feature"
)

;; various types
(assert_invalid
(component (type (future)))
Expand All @@ -366,10 +323,6 @@
(component (type (stream)))
"requires the component model async feature"
)
(assert_invalid
(component (type error-context))
"requires the component model async feature"
)
(assert_invalid
(component
(type $t (resource (rep i32)))
Expand Down
50 changes: 50 additions & 0 deletions tests/cli/missing-features/component-model/error-context.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
;; RUN: wast --assert default --snapshot tests/snapshots % -f=-cm-error-context

;; error-context.new
(assert_invalid
(component
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(core module $m
(import "" "error-context.new" (func $error-context-new (param i32 i32) (result i32)))
)
(core func $error-context-new (canon error-context.new (memory $libc "memory")))
(core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new))))))
)
"`error-context.new` requires the component model error-context feature"
)

;; error-context.debug-message
(assert_invalid
(component
(core module $libc
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
(memory (export "memory") 1)
)
(core instance $libc (instantiate $libc))
(core module $m
(import "" "error-context.debug-message" (func $error-context-debug-message (param i32 i32)))
)
(core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc"))))
(core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message))))))
)
"`error-context.debug-message` requires the component model error-context feature"
)

;; error-context.drop
(assert_invalid
(component
(core module $m
(import "" "error-context.drop" (func $error-context-drop (param i32)))
)
(core func $error-context-drop (canon error-context.drop))
(core instance $i (instantiate $m (with "" (instance (export "error-context.drop" (func $error-context-drop))))))
)
"`error-context.drop` requires the component model error-context feature"
)

;; various types
(assert_invalid
(component (type error-context))
"requires the component model error-context feature"
)
2 changes: 1 addition & 1 deletion tests/cli/validate-unknown-features.wat.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: invalid value 'unknown' for '--features <FEATURES>': unknown feature `unknown`
Valid features: mutable-global, saturating-float-to-int, sign-extension, reference-types, multi-value, bulk-memory, simd, relaxed-simd, threads, shared-everything-threads, tail-call, floats, multi-memory, exceptions, memory64, extended-const, component-model, function-references, memory-control, gc, custom-page-sizes, legacy-exceptions, gc-types, stack-switching, wide-arithmetic, cm-values, cm-nested-names, cm-async, cm-async-stackful, cm-async-builtins, mvp, wasm1, wasm2, wasm3, all
Valid features: mutable-global, saturating-float-to-int, sign-extension, reference-types, multi-value, bulk-memory, simd, relaxed-simd, threads, shared-everything-threads, tail-call, floats, multi-memory, exceptions, memory64, extended-const, component-model, function-references, memory-control, gc, custom-page-sizes, legacy-exceptions, gc-types, stack-switching, wide-arithmetic, cm-values, cm-nested-names, cm-async, cm-async-stackful, cm-async-builtins, cm-error-context, mvp, wasm1, wasm2, wasm3, all

For more information, try '--help'.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"source_filename": "tests/cli/component-model-async/error-context.wast",
"source_filename": "tests/cli/component-model-error-context/error-context.wast",
"commands": [
{
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,68 +181,40 @@
"line": 319,
"filename": "async.25.wasm",
"module_type": "binary",
"text": "`error-context.new` requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 333,
"filename": "async.26.wasm",
"module_type": "binary",
"text": "`error-context.debug-message` requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 350,
"filename": "async.27.wasm",
"module_type": "binary",
"text": "`error-context.drop` requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 362,
"filename": "async.28.wasm",
"module_type": "binary",
"text": "requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 366,
"filename": "async.29.wasm",
"module_type": "binary",
"text": "requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 370,
"filename": "async.30.wasm",
"line": 323,
"filename": "async.26.wasm",
"module_type": "binary",
"text": "requires the component model async feature"
},
{
"type": "assert_invalid",
"line": 374,
"filename": "async.31.wasm",
"line": 327,
"filename": "async.27.wasm",
"module_type": "binary",
"text": "requires the component model async builtins feature"
},
{
"type": "assert_invalid",
"line": 382,
"filename": "async.32.wasm",
"line": 335,
"filename": "async.28.wasm",
"module_type": "binary",
"text": "require the component model async feature"
},
{
"type": "assert_invalid",
"line": 387,
"filename": "async.33.wasm",
"line": 340,
"filename": "async.29.wasm",
"module_type": "binary",
"text": "require the component model async feature"
},
{
"type": "assert_invalid",
"line": 392,
"filename": "async.34.wasm",
"line": 345,
"filename": "async.30.wasm",
"module_type": "binary",
"text": "require the component model async feature"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"source_filename": "tests/cli/missing-features/component-model/error-context.wast",
"commands": [
{
"type": "assert_invalid",
"line": 5,
"filename": "error-context.0.wasm",
"module_type": "binary",
"text": "`error-context.new` requires the component model error-context feature"
},
{
"type": "assert_invalid",
"line": 19,
"filename": "error-context.1.wasm",
"module_type": "binary",
"text": "`error-context.debug-message` requires the component model error-context feature"
},
{
"type": "assert_invalid",
"line": 36,
"filename": "error-context.2.wasm",
"module_type": "binary",
"text": "`error-context.drop` requires the component model error-context feature"
},
{
"type": "assert_invalid",
"line": 48,
"filename": "error-context.3.wasm",
"module_type": "binary",
"text": "requires the component model error-context feature"
}
]
}