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
9 changes: 9 additions & 0 deletions crates/c-api/include/wasmtime/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,15 @@ WASMTIME_CONFIG_PROP(void, wasm_component_model_implements, bool)
*/
WASMTIME_CONFIG_PROP(void, wasm_component_model_canonical_names, bool)

/**
* \brief Configures whether the WebAssembly component-model accessors
* (`[get]` and `[set]`) support will be enabled for compilation.
*
* For more information see the Rust documentation at
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model_accessors.
*/
WASMTIME_CONFIG_PROP(void, wasm_component_model_accessors, bool)

#endif // WASMTIME_FEATURE_COMPONENT_MODEL

#ifdef WASMTIME_FEATURE_COMPONENT_MODEL_ASYNC
Expand Down
8 changes: 8 additions & 0 deletions crates/c-api/src/component/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ pub extern "C" fn wasmtime_config_wasm_component_model_canonical_names_set(
c.config.wasm_component_model_canonical_names(enable);
}

#[unsafe(no_mangle)]
pub extern "C" fn wasmtime_config_wasm_component_model_accessors_set(
c: &mut wasm_config_t,
enable: bool,
) {
c.config.wasm_component_model_accessors(enable);
}

#[unsafe(no_mangle)]
#[cfg(feature = "component-model-async")]
pub extern "C" fn wasmtime_config_wasm_component_model_async_set(
Expand Down
5 changes: 5 additions & 0 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ wasmtime_option_group! {
/// Component model support for canonical names, corresponds to the
/// 🔗 emoji in the upstream spec.
pub component_model_canonical_names: Option<bool>,
/// Component model support for `[get]` and `[set]` accessors,
/// corresponds to the 📡 emoji in the upstream spec.
pub component_model_accessors: Option<bool>,
/// Whether or not any concurrency infrastructure in Wasmtime is
/// enabled or not.
pub concurrency_support: Option<bool>,
Expand Down Expand Up @@ -1358,6 +1361,7 @@ impl CommonOptions {
("component-model", component_model_fixed_length_lists, wasm_component_model_fixed_length_lists)
("component-model", component_model_implements, wasm_component_model_implements)
("component-model", component_model_canonical_names, wasm_component_model_canonical_names)
("component-model", component_model_accessors, wasm_component_model_accessors)
("component-model", component_model_memory64, wasm_component_model_memory64)
("threads", threads, wasm_threads)
("gc", gc, wasm_gc)
Expand Down Expand Up @@ -1536,6 +1540,7 @@ impl CommonOptions {
component_model_canonical_names: Some(
features.contains(WasmFeatures::CM_CANON_NAMES),
),
component_model_accessors: Some(features.contains(WasmFeatures::CM_ACCESSORS)),
component_model_map: Some(features.contains(WasmFeatures::CM_MAP)),
component_model_memory64: Some(features.contains(WasmFeatures::CM64)),
component_model_more_async_builtins: Some(
Expand Down
3 changes: 3 additions & 0 deletions crates/fuzzing/src/generators/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl Config {
component_model_fixed_length_lists,
component_model_implements,
component_model_canonical_names,
component_model_accessors,
simd,
exceptions,
legacy_exceptions: _,
Expand Down Expand Up @@ -183,6 +184,7 @@ impl Config {
self.module_config.component_model_implements = component_model_implements.unwrap_or(false);
self.module_config.component_model_canonical_names =
component_model_canonical_names.unwrap_or(false);
self.module_config.component_model_accessors = component_model_accessors.unwrap_or(false);
self.module_config.stack_switching = stack_switching.unwrap_or(false);
self.wasmtime.branch_hinting = branch_hinting.unwrap_or(false);

Expand Down Expand Up @@ -344,6 +346,7 @@ impl Config {
cfg.wasm.component_model_implements = Some(self.module_config.component_model_implements);
cfg.wasm.component_model_canonical_names =
Some(self.module_config.component_model_canonical_names);
cfg.wasm.component_model_accessors = Some(self.module_config.component_model_accessors);
cfg.wasm.custom_page_sizes = Some(self.module_config.config.custom_page_sizes_enabled);
cfg.wasm.compact_imports = Some(self.module_config.config.compact_imports_enabled);
cfg.wasm.epoch_interruption = Some(self.wasmtime.epoch_interruption);
Expand Down
2 changes: 2 additions & 0 deletions crates/fuzzing/src/generators/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct ModuleConfig {
pub component_model_fixed_length_lists: bool,
pub component_model_implements: bool,
pub component_model_canonical_names: bool,
pub component_model_accessors: bool,
pub legacy_exceptions: bool,
pub shared_memory: bool,
pub stack_switching: bool,
Expand Down Expand Up @@ -91,6 +92,7 @@ impl<'a> Arbitrary<'a> for ModuleConfig {
component_model_fixed_length_lists: false,
component_model_implements: false,
component_model_canonical_names: false,
component_model_accessors: false,
legacy_exceptions: false,
shared_memory: false,
stack_switching: false,
Expand Down
3 changes: 3 additions & 0 deletions crates/test-util/src/wasmtime_wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
component_model_fixed_length_lists,
component_model_implements,
component_model_canonical_names,
component_model_accessors,
nan_canonicalization,
simd,
exceptions,
Expand Down Expand Up @@ -89,6 +90,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
let component_model_fixed_length_lists = component_model_fixed_length_lists.unwrap_or(false);
let component_model_implements = component_model_implements.unwrap_or(false);
let component_model_canonical_names = component_model_canonical_names.unwrap_or(false);
let component_model_accessors = component_model_accessors.unwrap_or(false);
let nan_canonicalization = nan_canonicalization.unwrap_or(false);
let relaxed_simd = relaxed_simd.unwrap_or(false);
let legacy_exceptions = legacy_exceptions.unwrap_or(false);
Expand Down Expand Up @@ -138,6 +140,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
.wasm_component_model_fixed_length_lists(component_model_fixed_length_lists)
.wasm_component_model_implements(component_model_implements)
.wasm_component_model_canonical_names(component_model_canonical_names)
.wasm_component_model_accessors(component_model_accessors)
.wasm_exceptions(exceptions)
.wasm_stack_switching(stack_switching)
.gc_support(gc_types)
Expand Down
2 changes: 2 additions & 0 deletions crates/test-util/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ fn component_test_config(test: &Path) -> TestConfig {
ret.multi_memory = Some(true);
ret.component_model_implements = Some(true);
ret.component_model_canonical_names = Some(true);
ret.component_model_accessors = Some(true);
ret.bulk_memory = Some(true);
ret.component_model_async = Some(true);
ret.component_model_more_async_builtins = Some(true);
Expand Down Expand Up @@ -363,6 +364,7 @@ macro_rules! foreach_config_option {
component_model_fixed_length_lists
component_model_implements
component_model_canonical_names
component_model_accessors
simd
gc_types
exceptions
Expand Down
13 changes: 12 additions & 1 deletion crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,16 @@ impl Config {
self
}

/// This corresponds to the 📡 emoji in the component model specification.
///
/// Please note that Wasmtime's support for this feature is a work in
/// progress.
#[cfg(feature = "component-model")]
pub fn wasm_component_model_accessors(&mut self, enable: bool) -> &mut Self {
self.wasm_features(WasmFeatures::CM_ACCESSORS, enable);
self
}

/// Configures whether the [Exception-handling proposal][proposal] is enabled or not.
///
/// This is `true` by default, except when using [`Strategy::Winch`] where
Expand Down Expand Up @@ -2467,7 +2477,8 @@ impl Config {
| WasmFeatures::CM64
| WasmFeatures::CM_FIXED_LENGTH_LISTS
| WasmFeatures::CM_IMPLEMENTS
| WasmFeatures::CM_CANON_NAMES;
| WasmFeatures::CM_CANON_NAMES
| WasmFeatures::CM_ACCESSORS;

#[allow(unused_mut, reason = "easier to avoid #[cfg]")]
let mut unsupported = !features_known_to_wasmtime;
Expand Down
Loading