From 7f9049b9df84a748d0f7b4024e29b26014923c28 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Jan 2025 19:15:14 -0600 Subject: [PATCH] Replace `signals-based-traps` with auto-detection (#9941) * Replace `signals-based-traps` with auto-detection This commit refactors the platform support of the `wasmtime` crate itself to remove the previously added `signals-based-traps` feature in favor of auto-detecting whether it's there or not. The `build.rs` script for the `wasmtime` crate will now detect the target platform and auto-enable this feature as necessary. The `signals-based-traps` cargo feature is removed and split into two custom `#[cfg]` directives that the build script sets: * `has_virtual_memory` - this is used to gate mmap implementations for example. This is enabled on `unix || windows` and will be off for `no_std` targets for example. This is split out of "signals-based-traps" to better handle platforms like iOS which have virtual memory but don't execute native code (removing the need for native signals). * `has_native_signals` - gates signal handlers on Unix for example. This is disabled on MIRI but otherwise enabled for `unix || windows`. This is intended to in the future get disabled for iOS by default for example since it's not necessary when using Pulley. This is additionally off-by-default for `no_std` platforms. Two new crate features were added for `no_std` or "custom" platforms to opt-in to the `wasmtime-platform.h` C APIs for implementing virtual memory and signals. These are used in the `min-platform` embedding example. This commit additionally updates some various documentation here and there to be more up-to-date. * Update CI configuration * Fix compile warnings * Fix test on miri * Fix more tests on miri * Fix some warnings * Another round of miri/CI attempts/fixes prtest:full --- .github/workflows/main.yml | 4 -- Cargo.toml | 4 +- crates/cli-flags/Cargo.toml | 1 - crates/cli-flags/src/lib.rs | 48 +++++---------- crates/fuzzing/Cargo.toml | 2 +- crates/test-macros/src/lib.rs | 5 +- crates/wasi-nn/Cargo.toml | 2 +- crates/wasi/Cargo.toml | 2 +- crates/wasmtime/Cargo.toml | 35 +++++------ crates/wasmtime/build.rs | 49 +++++++++++---- crates/wasmtime/src/config.rs | 32 +++++----- crates/wasmtime/src/engine.rs | 4 +- crates/wasmtime/src/runtime/code_memory.rs | 6 +- crates/wasmtime/src/runtime/unix.rs | 8 +-- crates/wasmtime/src/runtime/vm.rs | 12 ++-- crates/wasmtime/src/runtime/vm/memory.rs | 16 ++--- crates/wasmtime/src/runtime/vm/mmap_vec.rs | 40 ++++++------- .../src/runtime/vm/sys/custom/capi.rs | 34 +++++------ .../wasmtime/src/runtime/vm/sys/custom/mod.rs | 8 +-- .../src/runtime/vm/sys/custom/traphandlers.rs | 6 +- .../wasmtime/src/runtime/vm/sys/unix/mod.rs | 8 +-- .../src/runtime/vm/sys/unix/traphandlers.rs | 2 +- .../src/runtime/vm/sys/unix/unwind.rs | 2 +- .../src/runtime/vm/sys/windows/mod.rs | 2 +- .../wasmtime/src/runtime/vm/traphandlers.rs | 14 ++--- .../src/runtime/vm/traphandlers/signals.rs | 2 +- crates/wasmtime/src/runtime/windows.rs | 4 +- docs/stability-platform-support.md | 60 ++++++++++++++----- examples/min-platform/Cargo.toml | 2 +- examples/min-platform/README.md | 54 ++++++----------- examples/min-platform/build.sh | 4 +- examples/min-platform/embedding/Cargo.toml | 2 +- examples/min-platform/embedding/cbindgen.toml | 3 +- examples/min-platform/embedding/src/lib.rs | 8 +-- .../embedding/wasmtime-platform.c | 12 ++-- .../embedding/wasmtime-platform.h | 28 ++++----- examples/min-platform/src/main.rs | 3 +- src/commands/serve.rs | 33 +++++----- tests/all/module.rs | 1 + tests/unload-engine.rs | 3 +- tests/wast.rs | 16 ++--- 41 files changed, 290 insertions(+), 291 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c4fda5ae0d02..b372721cbc8a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -371,8 +371,6 @@ jobs: -p wasmtime --no-default-features --features threads -p wasmtime --no-default-features --features runtime,threads -p wasmtime --no-default-features --features cranelift,threads - -p wasmtime --no-default-features --features runtime,signals-based-traps - -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps -p wasmtime --features incremental-cache -p wasmtime --all-features @@ -541,8 +539,6 @@ jobs: test: > cargo check -p wasmtime --no-default-features --features runtime,component-model && cargo check -p wasmtime --no-default-features --features runtime,gc,component-model && - cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps && - cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps && cargo check -p cranelift-control --no-default-features && cargo check -p pulley-interpreter --features encode,decode,disas,interp # Use `cross` for illumos to have a C compiler/linker available. diff --git a/Cargo.toml b/Cargo.toml index 5da2cb346441..8ba776b37b6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ rustix = { workspace = true, features = ["mm", "param", "process"] } [dev-dependencies] # depend again on wasmtime to activate its default features for tests -wasmtime = { workspace = true, features = ['default', 'winch', 'pulley', 'all-arch', 'call-hook', 'memory-protection-keys', 'signals-based-traps'] } +wasmtime = { workspace = true, features = ['default', 'winch', 'pulley', 'all-arch', 'call-hook', 'memory-protection-keys'] } env_logger = { workspace = true } log = { workspace = true } filecheck = { workspace = true } @@ -416,7 +416,6 @@ default = [ "addr2line", "debug-builtins", "component-model", - "signals-based-traps", "threads", "gc", "gc-drc", @@ -475,7 +474,6 @@ threads = ["wasmtime-cli-flags/threads"] gc = ["wasmtime-cli-flags/gc", "wasmtime/gc"] gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"] gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"] -signals-based-traps = ["wasmtime/signals-based-traps", "wasmtime-cli-flags/signals-based-traps"] pulley = ["wasmtime-cli-flags/pulley"] # CLI subcommands for the `wasmtime` executable. See `wasmtime $cmd --help` diff --git a/crates/cli-flags/Cargo.toml b/crates/cli-flags/Cargo.toml index c91b8cec2c9d..c3ecfed086cf 100644 --- a/crates/cli-flags/Cargo.toml +++ b/crates/cli-flags/Cargo.toml @@ -35,5 +35,4 @@ gc-drc = ["gc", "wasmtime/gc-drc"] gc-null = ["gc", "wasmtime/gc-null"] threads = ["wasmtime/threads"] memory-protection-keys = ["wasmtime/memory-protection-keys"] -signals-based-traps = ["wasmtime/signals-based-traps"] pulley = ["wasmtime/pulley"] diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index ca14440d95cd..30f5c594701a 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -661,21 +661,15 @@ impl CommonOptions { .opts .memory_reservation .or(self.opts.static_memory_maximum_size); - match_feature! { - ["signals-based-traps" : memory_reservation] - size => config.memory_reservation(size), - _ => err, + if let Some(size) = memory_reservation { + config.memory_reservation(size); } - match_feature! { - ["signals-based-traps" : self.opts.static_memory_forced] - enable => config.memory_may_move(!enable), - _ => err, + if let Some(enable) = self.opts.static_memory_forced { + config.memory_may_move(!enable); } - match_feature! { - ["signals-based-traps" : self.opts.memory_may_move] - enable => config.memory_may_move(enable), - _ => err, + if let Some(enable) = self.opts.memory_may_move { + config.memory_may_move(enable); } let memory_guard_size = self @@ -683,25 +677,19 @@ impl CommonOptions { .static_memory_guard_size .or(self.opts.dynamic_memory_guard_size) .or(self.opts.memory_guard_size); - match_feature! { - ["signals-based-traps" : memory_guard_size] - size => config.memory_guard_size(size), - _ => err, + if let Some(size) = memory_guard_size { + config.memory_guard_size(size); } let mem_for_growth = self .opts .memory_reservation_for_growth .or(self.opts.dynamic_memory_reserved_for_growth); - match_feature! { - ["signals-based-traps" : mem_for_growth] - size => config.memory_reservation_for_growth(size), - _ => err, + if let Some(size) = mem_for_growth { + config.memory_reservation_for_growth(size); } - match_feature! { - ["signals-based-traps" : self.opts.guard_before_linear_memory] - enable => config.guard_before_linear_memory(enable), - _ => err, + if let Some(enable) = self.opts.guard_before_linear_memory { + config.guard_before_linear_memory(enable); } if let Some(enable) = self.opts.table_lazy_init { config.table_lazy_init(enable); @@ -718,15 +706,11 @@ impl CommonOptions { if let Some(enable) = self.debug.address_map { config.generate_address_map(enable); } - match_feature! { - ["signals-based-traps" : self.opts.memory_init_cow] - enable => config.memory_init_cow(enable), - _ => err, + if let Some(enable) = self.opts.memory_init_cow { + config.memory_init_cow(enable); } - match_feature! { - ["signals-based-traps" : self.opts.signals_based_traps] - enable => config.signals_based_traps(enable), - _ => err, + if let Some(enable) = self.opts.signals_based_traps { + config.signals_based_traps(enable); } if let Some(enable) = self.codegen.native_unwind_info { config.native_unwind_info(enable); diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml index 8882682ccb59..7774d5c2a759 100644 --- a/crates/fuzzing/Cargo.toml +++ b/crates/fuzzing/Cargo.toml @@ -26,7 +26,7 @@ target-lexicon = { workspace = true } tempfile = "3.3.0" wasmparser = { workspace = true } wasmprinter = { workspace = true } -wasmtime = { workspace = true, features = ['default', 'winch', 'gc', 'memory-protection-keys', 'signals-based-traps', 'pulley'] } +wasmtime = { workspace = true, features = ['default', 'winch', 'gc', 'memory-protection-keys', 'pulley'] } wasmtime-wast = { workspace = true, features = ['component-model'] } wasm-encoder = { workspace = true } wasm-smith = { workspace = true } diff --git a/crates/test-macros/src/lib.rs b/crates/test-macros/src/lib.rs index 5a9c8c89a12c..43b21855c8b1 100644 --- a/crates/test-macros/src/lib.rs +++ b/crates/test-macros/src/lib.rs @@ -210,9 +210,10 @@ fn expand(test_config: &TestConfig, func: Fn) -> Result { for strategy in &test_config.strategies { let strategy_name = format!("{strategy:?}"); - // Winch currently only offers support for x64. + // Winch currently only offers support for x64, and it requires + // signals-based-traps which MIRI disables so disable winch tests on MIRI let target = if *strategy == Compiler::Winch { - quote! { #[cfg(target_arch = "x86_64")] } + quote! { #[cfg(all(target_arch = "x86_64", not(miri)))] } } else { quote! {} }; diff --git a/crates/wasi-nn/Cargo.toml b/crates/wasi-nn/Cargo.toml index b05be0bcea88..272289298946 100644 --- a/crates/wasi-nn/Cargo.toml +++ b/crates/wasi-nn/Cargo.toml @@ -61,7 +61,7 @@ cap-std = { workspace = true } libtest-mimic = { workspace = true } test-programs-artifacts = { workspace = true } wasmtime-wasi = { workspace = true, features = ["preview1"] } -wasmtime = { workspace = true, features = ["cranelift", 'signals-based-traps'] } +wasmtime = { workspace = true, features = ["cranelift"] } tracing-subscriber = { workspace = true } [features] diff --git a/crates/wasi/Cargo.toml b/crates/wasi/Cargo.toml index 2f903e6a0b4f..db02061ce315 100644 --- a/crates/wasi/Cargo.toml +++ b/crates/wasi/Cargo.toml @@ -42,7 +42,7 @@ test-log = { workspace = true } tracing-subscriber = { workspace = true } test-programs-artifacts = { workspace = true } tempfile = { workspace = true } -wasmtime = { workspace = true, features = ['cranelift', 'incremental-cache', 'signals-based-traps'] } +wasmtime = { workspace = true, features = ['cranelift', 'incremental-cache'] } [target.'cfg(unix)'.dependencies] rustix = { workspace = true, features = ["event", "fs", "net"] } diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 2e3be1e60c27..24bacf9a5dc0 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -138,7 +138,6 @@ default = [ 'component-model', 'threads', 'std', - 'signals-based-traps', ] # An on-by-default feature enabling runtime compilation of WebAssembly modules @@ -193,7 +192,6 @@ async = [ pooling-allocator = [ "runtime", "std", # not ported to no_std yet - "signals-based-traps", # pooling allocation always uses mmap at this time ] # Enables support for all architectures in Cranelift, allowing @@ -250,6 +248,7 @@ runtime = [ "dep:rustix", "rustix/mm", "pulley-interpreter?/interp", + "dep:wasmtime-jit-icache-coherence", ] # Enable support for garbage collection-related things. @@ -273,7 +272,6 @@ gc = [ "wasmtime-environ/gc", "wasmtime-cranelift?/gc", "wasmtime-winch?/gc", - "signals-based-traps", # not ported to non-mmap schemes yet ] # Enable the deferred reference counting garbage collector. @@ -297,7 +295,6 @@ threads = [ "wasmtime-cranelift?/threads", "wasmtime-winch?/threads", "std", - "signals-based-traps", ] # Controls whether backtraces will attempt to parse DWARF information in @@ -319,13 +316,6 @@ std = [ 'wasmtime-fiber?/std', 'pulley-interpreter?/std', 'wasmtime-math/std', - # technically this isn't necessary but once you have the standard library you - # probably want things to go fast in which case you've probably got signal - # handlers and such so implicitly enable this. This also helps reduce the - # verbosity of others depending on `wasmtime` with `default-features = false` - # where frequently `std` is enabled and this feature will typically want to be - # enabled by default as well. - 'signals-based-traps', ] # Enables support for the `Store::call_hook` API which enables injecting custom @@ -357,14 +347,17 @@ reexport-wasmparser = [] # provides a human-readable text format for component values. wave = ["dep:wasm-wave"] -# Gates compile-time support for host signals-based-traps. +# For platforms that Wasmtime does not have support for Wasmtime will disable +# the use of virtual memory by default, for example allocating linear memories +# with `malloc` instead. This feature can be used, for these platforms, to +# instead use a C API defined in `wasmtime-platform.h` instead. # -# Traps based on signals, such as SIGSEGV, are useful for accelerating -# WebAssembly by removing explicit checks and letting the hardware deliver -# signals instead. This feature is enabled by default and gates a number -# of implementations within Wasmtime that may rely on virtual memory, for -# example. Embedded systems or smaller systems may wish to disable this feature -# to reduce the runtime requirements of Wasmtime. -signals-based-traps = [ - "dep:wasmtime-jit-icache-coherence", -] +# For some more information see +# https://docs.wasmtime.dev/stability-platform-support.html#support-for-no_std +# +# This feature is not necessary for supported platforms like Unix and Windows as +# virtual memory is always enabled there. +custom-virtual-memory = [] + +# Same as `custom-virtual-memory` above, but for custom signal-handling APIs. +custom-native-signals = [] diff --git a/crates/wasmtime/build.rs b/crates/wasmtime/build.rs index 78ad92f4443b..20c3af5b2085 100644 --- a/crates/wasmtime/build.rs +++ b/crates/wasmtime/build.rs @@ -1,27 +1,52 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); + // NB: duplicating a workaround in the wasmtime-fiber build script. + println!("cargo:rustc-check-cfg=cfg(asan)"); + if cfg_is("sanitize", "address") { + println!("cargo:rustc-cfg=asan"); + } + + let unix = cfg("unix"); + let windows = cfg("windows"); + let miri = cfg("miri"); + let supported_platform = unix || windows; + + let has_native_signals = + !miri && (supported_platform || cfg!(feature = "custom-native-signals")); + let has_virtual_memory = supported_platform || cfg!(feature = "custom-virtual-memory"); + + println!("cargo:rustc-check-cfg=cfg(has_native_signals, has_virtual_memory)"); + if has_native_signals { + println!("cargo:rustc-cfg=has_native_signals"); + } + if has_virtual_memory { + println!("cargo:rustc-cfg=has_virtual_memory"); + } + #[cfg(feature = "runtime")] build_c_helpers(); } +fn cfg(key: &str) -> bool { + std::env::var(&format!("CARGO_CFG_{}", key.to_uppercase())).is_ok() +} + +fn cfg_is(key: &str, val: &str) -> bool { + std::env::var(&format!("CARGO_CFG_{}", key.to_uppercase())) + .ok() + .as_deref() + == Some(val) +} + #[cfg(feature = "runtime")] fn build_c_helpers() { use wasmtime_versioned_export_macros::versioned_suffix; - // NB: duplicating a workaround in the wasmtime-fiber build script. - println!("cargo:rustc-check-cfg=cfg(asan)"); - match std::env::var("CARGO_CFG_SANITIZE") { - Ok(s) if s == "address" => { - println!("cargo:rustc-cfg=asan"); - } - _ => {} - } - // If this platform is neither unix nor windows then there's no default need // for a C helper library since `helpers.c` is tailored for just these // platforms currently. - if std::env::var("CARGO_CFG_UNIX").is_err() && std::env::var("CARGO_CFG_WINDOWS").is_err() { + if !cfg("unix") && !cfg("windows") { return; } @@ -38,9 +63,7 @@ fn build_c_helpers() { // On MinGW targets work around a bug in the MinGW compiler described at // https://github.com/bytecodealliance/wasmtime/pull/9688#issuecomment-2573367719 - if std::env::var("CARGO_CFG_WINDOWS").is_ok() - && std::env::var("CARGO_CFG_TARGET_ENV").ok().as_deref() == Some("gnu") - { + if cfg("windows") && cfg_is("target_env", "gnu") { build.define("__USE_MINGW_SETJMP_NON_SEH", None); } diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index f3a9087d26ac..9943e45954d5 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -1553,7 +1553,6 @@ impl Config { /// /// For 32-bit platforms this value defaults to 10MiB. This means that /// bounds checks will be required on 32-bit platforms. - #[cfg(feature = "signals-based-traps")] pub fn memory_reservation(&mut self, bytes: u64) -> &mut Self { self.tunables.memory_reservation = Some(bytes); self @@ -1589,7 +1588,6 @@ impl Config { /// the memory configuration works at runtime. /// /// The default value for this option is `true`. - #[cfg(feature = "signals-based-traps")] pub fn memory_may_move(&mut self, enable: bool) -> &mut Self { self.tunables.memory_may_move = Some(enable); self @@ -1638,7 +1636,6 @@ impl Config { /// allows eliminating almost all bounds checks on loads/stores with an /// immediate offset of less than 32MiB. On 32-bit platforms this defaults /// to 64KiB. - #[cfg(feature = "signals-based-traps")] pub fn memory_guard_size(&mut self, bytes: u64) -> &mut Self { self.tunables.memory_guard_size = Some(bytes); self @@ -1728,7 +1725,6 @@ impl Config { /// ## Default /// /// This value defaults to `true`. - #[cfg(feature = "signals-based-traps")] pub fn guard_before_linear_memory(&mut self, enable: bool) -> &mut Self { self.tunables.guard_before_linear_memory = Some(enable); self @@ -1844,7 +1840,6 @@ impl Config { /// [`Module::deserialize_file`]: crate::Module::deserialize_file /// [`Module`]: crate::Module /// [IPI]: https://en.wikipedia.org/wiki/Inter-processor_interrupt - #[cfg(feature = "signals-based-traps")] pub fn memory_init_cow(&mut self, enable: bool) -> &mut Self { self.tunables.memory_init_cow = Some(enable); self @@ -2113,13 +2108,19 @@ impl Config { let mut tunables = Tunables::default_for_target(&self.compiler_target())?; - // When signals-based traps are disabled use slightly different defaults + // If this platform doesn't have native signals then change some + // defaults to account for that. Note that VM guards are turned off here + // because that's primarily a feature of eliding bounds-checks. + if !cfg!(has_native_signals) { + tunables.signals_based_traps = cfg!(has_native_signals); + tunables.memory_guard_size = 0; + } + + // When virtual memory is not available use slightly different defaults // for tunables to be more amenable to `MallocMemory`. Note that these // can still be overridden by config options. - if !cfg!(feature = "signals-based-traps") { - tunables.signals_based_traps = false; + if !cfg!(has_virtual_memory) { tunables.memory_reservation = 0; - tunables.memory_guard_size = 0; tunables.memory_reservation_for_growth = 1 << 20; // 1MB tunables.memory_init_cow = false; } @@ -2148,11 +2149,13 @@ impl Config { None }; - // These `Config` accessors are disabled at compile time so double-check - // the defaults here. - if !cfg!(feature = "signals-based-traps") { - assert!(!tunables.signals_based_traps); - assert!(!tunables.memory_init_cow); + // Double-check that this configuration isn't requesting capabilities + // that this build of Wasmtime doesn't support. + if !cfg!(has_native_signals) && tunables.signals_based_traps { + bail!("signals-based-traps disabled at compile time -- cannot be enabled"); + } + if !cfg!(has_virtual_memory) && tunables.memory_init_cow { + bail!("virtual memory disabled at compile time -- cannot enable CoW"); } Ok((tunables, features)) @@ -2500,7 +2503,6 @@ impl Config { /// are enabled by default. /// /// **Note** Disabling this option is not compatible with the Winch compiler. - #[cfg(feature = "signals-based-traps")] pub fn signals_based_traps(&mut self, enable: bool) -> &mut Self { self.tunables.signals_based_traps = Some(enable); self diff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs index 833b7cfb9f23..e20a6840d1b4 100644 --- a/crates/wasmtime/src/engine.rs +++ b/crates/wasmtime/src/engine.rs @@ -99,7 +99,7 @@ impl Engine { // configured. This is the per-program initialization required for // handling traps, such as configuring signals, vectored exception // handlers, etc. - #[cfg(all(feature = "signals-based-traps", not(miri)))] + #[cfg(has_native_signals)] crate::runtime::vm::init_traps(config.macos_use_mach_ports); if !cfg!(miri) { #[cfg(feature = "debug-builtins")] @@ -842,7 +842,7 @@ impl Engine { /// If other crashes are seen from using this method please feel free to /// file an issue to update the documentation here with more preconditions /// that must be met. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] pub unsafe fn unload_process_handlers(self) { assert_eq!(Arc::weak_count(&self.inner), 0); assert_eq!(Arc::strong_count(&self.inner), 1); diff --git a/crates/wasmtime/src/runtime/code_memory.rs b/crates/wasmtime/src/runtime/code_memory.rs index 390e851cac26..eacde7ae30d6 100644 --- a/crates/wasmtime/src/runtime/code_memory.rs +++ b/crates/wasmtime/src/runtime/code_memory.rs @@ -315,13 +315,13 @@ impl CodeMemory { // Note that if virtual memory is disabled this is skipped because // we aren't able to make it readonly, but this is just a // defense-in-depth measure and isn't required for correctness. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] self.mmap.make_readonly(0..self.mmap.len())?; // Switch the executable portion from readonly to read/execute. if self.needs_executable { if !self.custom_publish()? { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] { let text = self.text(); @@ -341,7 +341,7 @@ impl CodeMemory { // Flush any in-flight instructions from the pipeline icache_coherence::pipeline_flush_mt().expect("Failed pipeline flush"); } - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] bail!("this target requires virtual memory to be enabled"); } } diff --git a/crates/wasmtime/src/runtime/unix.rs b/crates/wasmtime/src/runtime/unix.rs index 5bbcf19cba0b..0d1c9cd75e64 100644 --- a/crates/wasmtime/src/runtime/unix.rs +++ b/crates/wasmtime/src/runtime/unix.rs @@ -9,9 +9,9 @@ //! throughout the `wasmtime` crate with extra functionality that's only //! available on Unix. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] use crate::prelude::*; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] use crate::AsContextMut; use crate::Store; @@ -20,7 +20,7 @@ pub trait StoreExt { // TODO: needs more docs? /// The signal handler must be /// [async-signal-safe](http://man7.org/linux/man-pages/man7/signal-safety.7.html). - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] unsafe fn set_signal_handler(&mut self, handler: H) where H: 'static @@ -30,7 +30,7 @@ pub trait StoreExt { } impl StoreExt for Store { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] unsafe fn set_signal_handler(&mut self, handler: H) where H: 'static diff --git a/crates/wasmtime/src/runtime/vm.rs b/crates/wasmtime/src/runtime/vm.rs index 31949a5423b6..f986a6348854 100644 --- a/crates/wasmtime/src/runtime/vm.rs +++ b/crates/wasmtime/src/runtime/vm.rs @@ -95,17 +95,17 @@ pub use send_sync_unsafe_cell::SendSyncUnsafeCell; mod module_id; pub use module_id::CompiledModuleId; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] mod byte_count; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] mod cow; -#[cfg(not(feature = "signals-based-traps"))] +#[cfg(not(has_virtual_memory))] mod cow_disabled; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] mod mmap; cfg_if::cfg_if! { - if #[cfg(feature = "signals-based-traps")] { + if #[cfg(has_virtual_memory)] { pub use crate::runtime::vm::byte_count::*; pub use crate::runtime::vm::mmap::{Mmap, MmapOffset}; pub use self::cow::{MemoryImage, MemoryImageSlot, ModuleMemoryImages}; @@ -362,7 +362,7 @@ impl ModuleRuntimeInfo { } /// Returns the host OS page size, in bytes. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub fn host_page_size() -> usize { static PAGE_SIZE: AtomicUsize = AtomicUsize::new(0); diff --git a/crates/wasmtime/src/runtime/vm/memory.rs b/crates/wasmtime/src/runtime/vm/memory.rs index 7d5e23760abb..277e3cee5f68 100644 --- a/crates/wasmtime/src/runtime/vm/memory.rs +++ b/crates/wasmtime/src/runtime/vm/memory.rs @@ -76,7 +76,7 @@ use crate::prelude::*; use crate::runtime::vm::vmcontext::VMMemoryDefinition; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] use crate::runtime::vm::{HostAlignedByteCount, MmapOffset}; use crate::runtime::vm::{MemoryImage, MemoryImageSlot, SendSyncPtr, VMStore, WaitResult}; use alloc::sync::Arc; @@ -84,9 +84,9 @@ use core::time::Duration; use core::{ops::Range, ptr::NonNull}; use wasmtime_environ::{Trap, Tunables}; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] mod mmap; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub use self::mmap::MmapMemory; mod malloc; @@ -129,7 +129,7 @@ impl RuntimeMemoryCreator for DefaultMemoryCreator { minimum: usize, maximum: Option, ) -> Result> { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] if tunables.signals_based_traps || tunables.memory_guard_size > 0 || tunables.memory_reservation > 0 @@ -187,7 +187,7 @@ pub enum MemoryBase { Raw(SendSyncPtr), /// An mmap along with an offset into it. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] Mmap(MmapOffset), } @@ -203,7 +203,7 @@ impl MemoryBase { pub fn as_mut_ptr(&self) -> *mut u8 { match self { Self::Raw(ptr) => ptr.as_ptr(), - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] Self::Mmap(mmap_offset) => mmap_offset.as_mut_ptr(), } } @@ -508,7 +508,7 @@ impl LocalMemory { // If a memory image was specified, try to create the MemoryImageSlot on // top of our mmap. let memory_image = match memory_image { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] Some(image) => { // We currently don't support memory_image if // `RuntimeLinearMemory::byte_size` is not a multiple of the host page @@ -554,7 +554,7 @@ impl LocalMemory { None } } - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] Some(_) => unreachable!(), None => None, }; diff --git a/crates/wasmtime/src/runtime/vm/mmap_vec.rs b/crates/wasmtime/src/runtime/vm/mmap_vec.rs index 33040642384e..9cd2a1d91722 100644 --- a/crates/wasmtime/src/runtime/vm/mmap_vec.rs +++ b/crates/wasmtime/src/runtime/vm/mmap_vec.rs @@ -1,13 +1,13 @@ use crate::prelude::*; -#[cfg(not(feature = "signals-based-traps"))] +#[cfg(not(has_virtual_memory))] use crate::runtime::vm::send_sync_ptr::SendSyncPtr; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] use crate::runtime::vm::{mmap::UnalignedLength, Mmap}; -#[cfg(not(feature = "signals-based-traps"))] +#[cfg(not(has_virtual_memory))] use alloc::alloc::Layout; use alloc::sync::Arc; use core::ops::{Deref, Range}; -#[cfg(not(feature = "signals-based-traps"))] +#[cfg(not(has_virtual_memory))] use core::ptr::NonNull; #[cfg(feature = "std")] use std::fs::File; @@ -34,13 +34,13 @@ use std::fs::File; /// executable permissions on parts of this storage. pub enum MmapVec { #[doc(hidden)] - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] Alloc { base: SendSyncPtr, layout: Layout, }, #[doc(hidden)] - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] Mmap { mmap: Mmap, len: usize, @@ -53,7 +53,7 @@ impl MmapVec { /// The returned `MmapVec` will have the `size` specified, which can be /// smaller than the region mapped by the `Mmap`. The returned `MmapVec` /// will only have at most `size` bytes accessible. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] fn new_mmap(mmap: M, len: usize) -> MmapVec where M: Into>, @@ -63,7 +63,7 @@ impl MmapVec { MmapVec::Mmap { mmap, len } } - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] fn new_alloc(len: usize, alignment: usize) -> MmapVec { let layout = Layout::from_size_align(len, alignment) .expect("Invalid size or alignment for MmapVec allocation"); @@ -81,12 +81,12 @@ impl MmapVec { /// bytes. All bytes will be initialized to zero since this is a fresh OS /// page allocation. pub fn with_capacity_and_alignment(size: usize, alignment: usize) -> Result { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] { assert!(alignment <= crate::runtime::vm::host_page_size()); return Ok(MmapVec::new_mmap(Mmap::with_at_least(size)?, size)); } - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] { return Ok(MmapVec::new_alloc(size, alignment)); } @@ -140,7 +140,7 @@ impl MmapVec { } /// Makes the specified `range` within this `mmap` to be read/execute. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub unsafe fn make_executable( &self, range: Range, @@ -155,7 +155,7 @@ impl MmapVec { } /// Makes the specified `range` within this `mmap` to be read-only. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub unsafe fn make_readonly(&self, range: Range) -> Result<()> { let (mmap, len) = match self { MmapVec::Mmap { mmap, len } => (mmap, *len), @@ -169,9 +169,9 @@ impl MmapVec { #[cfg(feature = "std")] pub fn original_file(&self) -> Option<&Arc> { match self { - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] MmapVec::Alloc { .. } => None, - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] MmapVec::Mmap { mmap, .. } => mmap.original_file(), } } @@ -192,11 +192,11 @@ impl MmapVec { /// ensure that the memory is indeed writable pub unsafe fn as_mut_slice(&mut self) -> &mut [u8] { match self { - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] MmapVec::Alloc { base, layout } => { core::slice::from_raw_parts_mut(base.as_mut(), layout.size()) } - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] MmapVec::Mmap { mmap, len } => mmap.slice_mut(0..*len), } } @@ -208,11 +208,11 @@ impl Deref for MmapVec { #[inline] fn deref(&self) -> &[u8] { match self { - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] MmapVec::Alloc { base, layout } => unsafe { core::slice::from_raw_parts(base.as_ptr(), layout.size()) }, - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] MmapVec::Mmap { mmap, len } => { // SAFETY: all bytes for this mmap, which is owned by // `MmapVec`, are always at least readable. @@ -225,11 +225,11 @@ impl Deref for MmapVec { impl Drop for MmapVec { fn drop(&mut self) { match self { - #[cfg(not(feature = "signals-based-traps"))] + #[cfg(not(has_virtual_memory))] MmapVec::Alloc { base, layout, .. } => unsafe { alloc::alloc::dealloc(base.as_mut(), layout.clone()); }, - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] MmapVec::Mmap { .. } => { // Drop impl on the `mmap` takes care of this case. } diff --git a/crates/wasmtime/src/runtime/vm/sys/custom/capi.rs b/crates/wasmtime/src/runtime/vm/sys/custom/capi.rs index 9c99631a4293..98c1e756cf94 100644 --- a/crates/wasmtime/src/runtime/vm/sys/custom/capi.rs +++ b/crates/wasmtime/src/runtime/vm/sys/custom/capi.rs @@ -3,20 +3,20 @@ // Flags to either `wasmtime_mmap_{new,remap}` or `wasmtime_mprotect`. /// Indicates that the memory region should be readable. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub const WASMTIME_PROT_READ: u32 = 1 << 0; /// Indicates that the memory region should be writable. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub const WASMTIME_PROT_WRITE: u32 = 1 << 1; /// Indicates that the memory region should be executable. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub const WASMTIME_PROT_EXEC: u32 = 1 << 2; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub use WASMTIME_PROT_EXEC as PROT_EXEC; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub use WASMTIME_PROT_READ as PROT_READ; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub use WASMTIME_PROT_WRITE as PROT_WRITE; /// Handler function for traps in Wasmtime passed to `wasmtime_init_traps`. @@ -43,13 +43,13 @@ pub use WASMTIME_PROT_WRITE as PROT_WRITE; /// /// When this function does not return it's because `wasmtime_longjmp` is /// used to handle a Wasm-based trap. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] pub type wasmtime_trap_handler_t = extern "C" fn(ip: usize, fp: usize, has_faulting_addr: bool, faulting_addr: usize); /// Abstract pointer type used in the `wasmtime_memory_image_*` APIs which /// is defined by the embedder. -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub enum wasmtime_memory_image {} unsafe extern "C" { @@ -63,7 +63,7 @@ unsafe extern "C" { /// Returns 0 on success and an error code on failure. /// /// Similar to `mmap(0, size, prot_flags, MAP_PRIVATE, 0, -1)` on Linux. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_mmap_new(size: usize, prot_flags: u32, ret: &mut *mut u8) -> i32; /// Remaps the virtual memory starting at `addr` going for `size` bytes to @@ -76,7 +76,7 @@ unsafe extern "C" { /// Returns 0 on success and an error code on failure. /// /// Similar to `mmap(addr, size, prot_flags, MAP_PRIVATE | MAP_FIXED, 0, -1)` on Linux. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_mmap_remap(addr: *mut u8, size: usize, prot_flags: u32) -> i32; /// Unmaps memory at the specified `ptr` for `size` bytes. @@ -87,7 +87,7 @@ unsafe extern "C" { /// Returns 0 on success and an error code on failure. /// /// Similar to `munmap` on Linux. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_munmap(ptr: *mut u8, size: usize) -> i32; /// Configures the protections associated with a region of virtual memory @@ -96,11 +96,11 @@ unsafe extern "C" { /// Returns 0 on success and an error code on failure. /// /// Similar to `mprotect` on Linux. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_mprotect(ptr: *mut u8, size: usize, prot_flags: u32) -> i32; /// Returns the page size, in bytes, of the current system. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_page_size() -> usize; /// Used to setup a frame on the stack to longjmp back to in the future. @@ -147,7 +147,7 @@ unsafe extern "C" { /// the system. /// /// Returns 0 on success and an error code on failure. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] pub fn wasmtime_init_traps(handler: wasmtime_trap_handler_t) -> i32; /// Attempts to create a new in-memory image of the `ptr`/`len` combo which @@ -169,7 +169,7 @@ unsafe extern "C" { /// `NULL` into `ret` is not considered a failure, and failure is used to /// indicate that something fatal has happened and Wasmtime will propagate /// the error upwards. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_memory_image_new( ptr: *const u8, len: usize, @@ -190,7 +190,7 @@ unsafe extern "C" { /// the future. /// /// Aborts the process on failure. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_memory_image_map_at( image: *mut wasmtime_memory_image, addr: *mut u8, @@ -201,7 +201,7 @@ unsafe extern "C" { /// /// Note that mappings created from this image are not guaranteed to be /// deallocated and/or unmapped before this is called. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] pub fn wasmtime_memory_image_free(image: *mut wasmtime_memory_image); /// Wasmtime requires a single pointer's space of TLS to be used at runtime, diff --git a/crates/wasmtime/src/runtime/vm/sys/custom/mod.rs b/crates/wasmtime/src/runtime/vm/sys/custom/mod.rs index a810764df590..ea1a0a1807ed 100644 --- a/crates/wasmtime/src/runtime/vm/sys/custom/mod.rs +++ b/crates/wasmtime/src/runtime/vm/sys/custom/mod.rs @@ -10,18 +10,18 @@ #![warn(dead_code, unused_imports)] -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] use crate::prelude::*; pub mod capi; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub mod mmap; pub mod traphandlers; pub mod unwind; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub mod vm; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] fn cvt(rc: i32) -> Result<()> { match rc { 0 => Ok(()), diff --git a/crates/wasmtime/src/runtime/vm/sys/custom/traphandlers.rs b/crates/wasmtime/src/runtime/vm/sys/custom/traphandlers.rs index ec3781c238ab..24d033ac9837 100644 --- a/crates/wasmtime/src/runtime/vm/sys/custom/traphandlers.rs +++ b/crates/wasmtime/src/runtime/vm/sys/custom/traphandlers.rs @@ -20,10 +20,10 @@ pub unsafe fn wasmtime_setjmp( capi::wasmtime_setjmp(jmp_buf, callback, payload, callee.cast()) } -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] pub struct TrapHandler; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] impl TrapHandler { pub unsafe fn new(_macos_use_mach_ports: bool) -> TrapHandler { capi::wasmtime_init_traps(handle_trap); @@ -33,7 +33,7 @@ impl TrapHandler { pub fn validate_config(&self, _macos_use_mach_ports: bool) {} } -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] extern "C" fn handle_trap(pc: usize, fp: usize, has_faulting_addr: bool, faulting_addr: usize) { use crate::runtime::vm::traphandlers::{tls, TrapRegisters, TrapTest}; diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs b/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs index 8c6d90240aa8..a0241127234c 100644 --- a/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs +++ b/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs @@ -5,16 +5,16 @@ use core::cell::Cell; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub mod mmap; pub mod traphandlers; pub mod unwind; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub mod vm; -#[cfg(all(feature = "signals-based-traps", target_vendor = "apple"))] +#[cfg(all(has_native_signals, target_vendor = "apple"))] pub mod machports; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_native_signals)] pub mod signals; std::thread_local!(static TLS: Cell<*mut u8> = const { Cell::new(std::ptr::null_mut()) }); diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/traphandlers.rs b/crates/wasmtime/src/runtime/vm/sys/unix/traphandlers.rs index da9ab20ece9d..667aad675425 100644 --- a/crates/wasmtime/src/runtime/vm/sys/unix/traphandlers.rs +++ b/crates/wasmtime/src/runtime/vm/sys/unix/traphandlers.rs @@ -16,7 +16,7 @@ unsafe extern "C" { } cfg_if::cfg_if! { - if #[cfg(not(feature = "signals-based-traps"))] { + if #[cfg(not(has_native_signals))] { // If signals-based traps are disabled statically then there's no // platform signal handler and no per-thread init, so stub these both // out. diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/unwind.rs b/crates/wasmtime/src/runtime/vm/sys/unix/unwind.rs index 7939a95ecc87..35c7451130b5 100644 --- a/crates/wasmtime/src/runtime/vm/sys/unix/unwind.rs +++ b/crates/wasmtime/src/runtime/vm/sys/unix/unwind.rs @@ -72,7 +72,7 @@ impl UnwindRegistration { unwind_info: *const u8, unwind_len: usize, ) -> Result { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_virtual_memory)] debug_assert_eq!( unwind_info as usize % crate::runtime::vm::host_page_size(), 0, diff --git a/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs b/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs index 90af767f30be..8e0dca032c9f 100644 --- a/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs +++ b/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs @@ -2,7 +2,7 @@ use std::cell::Cell; -#[cfg(feature = "signals-based-traps")] +#[cfg(has_virtual_memory)] pub mod mmap; pub mod traphandlers; pub mod vm; diff --git a/crates/wasmtime/src/runtime/vm/traphandlers.rs b/crates/wasmtime/src/runtime/vm/traphandlers.rs index 9e12cdc9716f..94a080d60436 100644 --- a/crates/wasmtime/src/runtime/vm/traphandlers.rs +++ b/crates/wasmtime/src/runtime/vm/traphandlers.rs @@ -10,9 +10,9 @@ mod coredump; #[path = "traphandlers/coredump_disabled.rs"] mod coredump; -#[cfg(all(feature = "signals-based-traps", not(miri)))] +#[cfg(all(has_native_signals))] mod signals; -#[cfg(all(feature = "signals-based-traps", not(miri)))] +#[cfg(all(has_native_signals))] pub use self::signals::*; use crate::prelude::*; @@ -414,7 +414,7 @@ mod call_thread_state { pub struct CallThreadState { pub(super) unwind: Cell, Option)>>, pub(super) jmp_buf: Cell<*const u8>, - #[cfg(all(feature = "signals-based-traps", not(miri)))] + #[cfg(all(has_native_signals))] pub(super) signal_handler: Option<*const SignalHandler>, pub(super) capture_backtrace: bool, #[cfg(feature = "coredump")] @@ -424,7 +424,7 @@ mod call_thread_state { pub(crate) unwinder: &'static dyn Unwind, pub(super) prev: Cell, - #[cfg(all(feature = "signals-based-traps", unix, not(miri)))] + #[cfg(all(has_native_signals, unix))] pub(crate) async_guard_range: Range<*mut u8>, // The values of `VMRuntimeLimits::last_wasm_{exit_{pc,fp},entry_sp}` @@ -469,13 +469,13 @@ mod call_thread_state { unwind: Cell::new(None), unwinder: store.unwinder(), jmp_buf: Cell::new(ptr::null()), - #[cfg(all(feature = "signals-based-traps", not(miri)))] + #[cfg(all(has_native_signals))] signal_handler: store.signal_handler(), capture_backtrace: store.engine().config().wasm_backtrace, #[cfg(feature = "coredump")] capture_coredump: store.engine().config().coredump_on_trap, limits, - #[cfg(all(feature = "signals-based-traps", unix, not(miri)))] + #[cfg(all(has_native_signals, unix))] async_guard_range: store.async_guard_range(), prev: Cell::new(ptr::null()), old_last_wasm_exit_fp: Cell::new(unsafe { *(*limits).last_wasm_exit_fp.get() }), @@ -658,7 +658,7 @@ impl CallThreadState { // in which case run them all. If anything handles the trap then we // return that the trap was handled. let _ = &call_handler; - #[cfg(all(feature = "signals-based-traps", not(miri)))] + #[cfg(all(has_native_signals, not(miri)))] if let Some(handler) = self.signal_handler { if unsafe { call_handler(&*handler) } { return TrapTest::HandledByEmbedder; diff --git a/crates/wasmtime/src/runtime/vm/traphandlers/signals.rs b/crates/wasmtime/src/runtime/vm/traphandlers/signals.rs index ac5d6a3409a7..bc2e5aef7d56 100644 --- a/crates/wasmtime/src/runtime/vm/traphandlers/signals.rs +++ b/crates/wasmtime/src/runtime/vm/traphandlers/signals.rs @@ -1,4 +1,4 @@ -//! Trap handling support when `feature = "signals-based-traps"` is enabled. +//! Trap handling support when `has_native_signals` is enabled. //! //! This module is conditionally included in the above `traphandlers` module and //! contains support and shared routines for working with signals-based traps. diff --git a/crates/wasmtime/src/runtime/windows.rs b/crates/wasmtime/src/runtime/windows.rs index b1c018b211d1..3e8aa15466e1 100644 --- a/crates/wasmtime/src/runtime/windows.rs +++ b/crates/wasmtime/src/runtime/windows.rs @@ -18,14 +18,14 @@ pub trait StoreExt { /// Configures a custom signal handler to execute. /// /// TODO: needs more documentation. - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] unsafe fn set_signal_handler(&mut self, handler: H) where H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync; } impl StoreExt for Store { - #[cfg(feature = "signals-based-traps")] + #[cfg(has_native_signals)] unsafe fn set_signal_handler(&mut self, handler: H) where H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync, diff --git a/docs/stability-platform-support.md b/docs/stability-platform-support.md index bdd2428158f2..b81d125aa2db 100644 --- a/docs/stability-platform-support.md +++ b/docs/stability-platform-support.md @@ -7,17 +7,10 @@ information about what's supported in Wasmtime on a per-matrix-combination basis. Wasmtime strives to support hardware that anyone wants to run WebAssembly on. -Maintainers of Wasmtime support a number of "major" platforms themselves but -porting work may be required to support platforms that maintainers are not -themselves familiar with. Out-of-the box Wasmtime supports: - -* Linux x86\_64, aarch64, s390x, and riscv64 -* macOS x86\_64, aarch64 -* Windows x86\_64 - -Other platforms such as Android, iOS, and the BSD family of OSes are not -built-in yet. PRs for porting are welcome and maintainers are happy to add more -entries to the CI matrix for these platforms. +Wasmtime is intended to work out-of-the-box on most platforms by having +platform-specific defaults for the runtime. For example the native Cranelift +backend is enabled by default if supported, but otherwise the Pulley +interpreter backend is used if it's not supported. ## Compiler Support @@ -45,11 +38,40 @@ Cranelift. ## Interpreter support -At this time `wasmtime` does not have a mode in which it simply interprets -WebAssembly code. It is desired to add support for an interpreter, however, and -this will have minimal system dependencies. It is planned that the system will -need to support some form of dynamic memory allocation, but other than that not -much else will be needed. +The `wasmtime` crate provides an implementation of a WebAssembly interpreter +named "Pulley" which is a portable implementation of executing WebAssembly +code. Pulley uses a custom bytecode which is created from input WebAssembly +similarly to how native architectures are supported. Pulley's bytecode is +created via a Cranelift backend for Pulley, so compile times for the interpreter +are expected to be similar to natively compiled code. + +The main advantage of Pulley is that the bytecode can be executed on any +platform with the same pointer-width and endianness. For example to execute +Pulley on a 32-bit ARM platform you'd use the target `pulley32`. Similarly if +you wanted to run Pulley on x86\_64 you'd use the target `pulley64` for +Wasmtime. + +Pulley's platform requirements are no greater than that of Wasmtime itself, +meaning that the goal is that if you can compile Wasmtime for a Rust target then +Pulley can run on that target. + +Finally, note that while Pulley is optimized to be an efficient interpreter it +will never be as fast as native Cranelift backends. A performance penalty should +be expected when using Pulley. + +## OS Support + +Wasmtime with Pulley should work out-of-the-box on any Rust target, but for +optimal runtime performance of WebAssembly OS integration is required. In the +same way that Pulley is slower than a native Cranelift backend Wasmtime will be +slower on Rust targets it has no OS support for. Wasmtime will for example use +virtual memory when possible to implement WebAssembly linear memories to +efficiently allocate/grow/deallocate. + +OS support at this time primarily includes Windows, macOS, and Linux. Other +OSes such as iOS, Android, and Illumos are supported but less well tested. +PRs to the Wasmtime repository are welcome for new OSes for better native +platform support of a runtime environment. ## Support for `#![no_std]` @@ -60,6 +82,7 @@ Cargo features are: * `runtime` * `gc` * `component-model` +* `pulley` This notably does not include the `default` feature which means that when depending on Wasmtime you'll need to specify `default-features = false`. This @@ -79,3 +102,8 @@ Wasmtime's runtime will use the symbols defined in this file meaning that if they're not defined then a link-time error will be generated. Embedders are required to implement these functions in accordance with their documentation to enable Wasmtime to run on custom platforms. + +Note that many functions in this header file are gated behind off-by-default +`#ifdef` directives indicating that Wasmtime doesn't require them by default. +The `wasmtime` crate features `custom-{virtual-memory,native-signals}` can be +used to enable usage of these APIs if desired. diff --git a/examples/min-platform/Cargo.toml b/examples/min-platform/Cargo.toml index 9db575077390..8f6028520efc 100644 --- a/examples/min-platform/Cargo.toml +++ b/examples/min-platform/Cargo.toml @@ -15,4 +15,4 @@ object = { workspace = true, features = ['std'] } wasmtime = { workspace = true, features = ['cranelift', 'wat'] } [features] -signals-based-traps = [] +custom = [] diff --git a/examples/min-platform/README.md b/examples/min-platform/README.md index 14eac757df96..d951e2cf0cf8 100644 --- a/examples/min-platform/README.md +++ b/examples/min-platform/README.md @@ -13,17 +13,16 @@ The example is organized into a few locations: embedding of Wasmtime itself. This is compiled to the target architecture and will have a minimal set of dependencies. -* `examples/min-platform/embedding/*.json` - custom Rust target definitions - which are used when compiling this example. These are the custom target files - that are the compilation target of the `embedding` crate. This is a feature - of nightly Rust to be able to use these. Note that the contents can be - customized and these files are only examples. - * `examples/min-platform/embedding/wasmtime-platform.{h,c}` - an example implementation of the platform dependencies that Wasmtime requires. This is defined and documented in `crates/wasmtime/src/runtime/vm/sys/custom/capi.rs`. The example here - implements the required functions with Linux syscalls. + implements the required functions with Linux syscalls. Note that by default + most of the file is not necessary to implement and is gated by + `WASMTIME_VIRTUAL_MEMORY` and `WASMTIME_NATIVE_SIGNALS`. These correspond + to the `custom-virtual-memory` and `custom-native-signals` crate features of + `wasmtime` which are off-by-default and are optional performance + optimizations. * `examples/min-platform/{Cargo.toml,src}` - an example "host embedding" which loads and runs the `embedding` from above. This is a bit contrived and mostly @@ -35,43 +34,24 @@ The example is organized into a few locations: Taken together this example is unlikely to satisfy any one individual use case but should set up the scaffolding to show how Wasmtime can be built for a -nonstandard platform. Wasmtime effectively only has one requirement from the -system which is management of virtual memory, and beyond that everything else -can be internalized. - -Note that at this time this support all relies on the fact that the Rust -standard library can be built for a custom target. Most of the Rust standard -library will be "stubbed out" however and won't work (e.g. opening a file would -return an error). This means that not all of the `wasmtime` crate will work, nor -will all features of the `wasmtime` crate, but the set of features activated -here should suffice. +nonstandard platform. Wasmtime effectively requires one pointer of thread-local +memory and otherwise all other dependencies can be internalized. ## Description -This example will compile Wasmtime to a custom Rust target specified in -`*.json` files. This custom target, for the example, is modeled after Linux -except for the fact that Rust won't be able to know that (e.g. the `#[cfg]` -directives aren't set so code won't know it actually runs on Linux). The -embedding will run a few small examples of WebAssembly modules and then return. +This example will compile Wasmtime to any Rust target specified. The embedding +will run a few small examples of WebAssembly modules and then return. This +example is built in Wasmtime's CI with `x86_64-unknown-none` for example as a +Rust target. The host for this is a Linux program which supplies the platform dependencies that the embedding requires, for example the `wasmtime_*` symbols. This host -program will load the embedding and execute it. - -## Points of Note - -* Due to the usage of custom `*.json` targets, this example requires a nightly - Rust compiler. -* Compiling the embedding requires `--cfg wasmtime_custom_platform` in the - `RUSTFLAGS` environment variable. to indicate that Wasmtime's custom C - API-based definition of platform support is desired. -* Due to the usage of a custom target most of libstd doesn't work. For example - panics can't print anything and the process can only abort. -* Due to the custom target not all features of Wasmtime can be enabled because - some crates may require platform functionality which can't be defined due to - the lack of knowledge of what platform is being targeted. +program will load the embedding and execute it. This is mostly specific to +executing this example in CI and is not necessarily representative of a "real" +embedding where you'd probably use static linking instead of dynamic linking +for example at the very least. ## Running this example This example can be built and run with the `./build.sh` script in this -directory. Example output looks like. +directory. diff --git a/examples/min-platform/build.sh b/examples/min-platform/build.sh index be4e8d06bcb6..897a1d84b83c 100755 --- a/examples/min-platform/build.sh +++ b/examples/min-platform/build.sh @@ -22,8 +22,8 @@ EMBEDDING_DIR=$HOST_DIR/embedding set -ex if [ "$WASMTIME_SIGNALS_BASED_TRAPS" = "1" ]; then - cflags="$cflags -DWASMTIME_SIGNALS_BASED_TRAPS" - features="$features,signals-based-traps" + cflags="$cflags -DWASMTIME_VIRTUAL_MEMORY -DWASMTIME_NATIVE_SIGNALS" + features="$features,custom" fi # First compile the C implementation of the platform symbols that will be diff --git a/examples/min-platform/embedding/Cargo.toml b/examples/min-platform/embedding/Cargo.toml index 8e7818a1ff28..2144d126988e 100644 --- a/examples/min-platform/embedding/Cargo.toml +++ b/examples/min-platform/embedding/Cargo.toml @@ -25,4 +25,4 @@ test = false doctest = false [features] -signals-based-traps = ['wasmtime/signals-based-traps'] +custom = ['wasmtime/custom-virtual-memory', 'wasmtime/custom-native-signals'] diff --git a/examples/min-platform/embedding/cbindgen.toml b/examples/min-platform/embedding/cbindgen.toml index 707879653e60..e0602eb1c820 100644 --- a/examples/min-platform/embedding/cbindgen.toml +++ b/examples/min-platform/embedding/cbindgen.toml @@ -27,4 +27,5 @@ header = """ """ [defines] -'feature = signals-based-traps' = 'WASMTIME_SIGNALS_BASED_TRAPS' +has_virtual_memory = 'WASMTIME_VIRTUAL_MEMORY' +has_native_signals = 'WASMTIME_NATIVE_SIGNALS' diff --git a/examples/min-platform/embedding/src/lib.rs b/examples/min-platform/embedding/src/lib.rs index 9e064fbba4ce..9651196ec43d 100644 --- a/examples/min-platform/embedding/src/lib.rs +++ b/examples/min-platform/embedding/src/lib.rs @@ -94,12 +94,12 @@ fn deserialize(engine: &Engine, module: &[u8]) -> Result> { match unsafe { Module::deserialize(engine, module) } { Ok(module) => Ok(Some(module)), Err(e) => { - // Currently if signals-based-traps are disabled then this example - // is expected to fail to load since loading native code requires - // virtual memory. In the future this will go away as when + // Currently if custom signals/virtual memory are disabled then this + // example is expected to fail to load since loading native code + // requires virtual memory. In the future this will go away as when // signals-based-traps is disabled then that means that the // interpreter should be used which should work here. - if !cfg!(feature = "signals-based-traps") + if !cfg!(feature = "custom") && e.to_string() .contains("requires virtual memory to be enabled") { diff --git a/examples/min-platform/embedding/wasmtime-platform.c b/examples/min-platform/embedding/wasmtime-platform.c index 023aa3da9778..deb4631d32e6 100644 --- a/examples/min-platform/embedding/wasmtime-platform.c +++ b/examples/min-platform/embedding/wasmtime-platform.c @@ -9,7 +9,7 @@ #include "wasmtime-platform.h" -#ifdef WASMTIME_SIGNALS_BASED_TRAPS +#ifdef WASMTIME_VIRTUAL_MEMORY static int wasmtime_to_mmap_prot_flags(uint32_t prot_flags) { int flags = 0; @@ -55,7 +55,7 @@ int wasmtime_mprotect(uint8_t *ptr, uintptr_t size, uint32_t prot_flags) { uintptr_t wasmtime_page_size(void) { return sysconf(_SC_PAGESIZE); } -#endif // WASMTIME_SIGNALS_BASED_TRAPS +#endif // WASMTIME_VIRTUAL_MEMORY bool wasmtime_setjmp(const uint8_t **jmp_buf_out, bool (*callback)(uint8_t *, uint8_t *), uint8_t *payload, @@ -71,7 +71,7 @@ void wasmtime_longjmp(const uint8_t *jmp_buf_ptr) { longjmp(*(jmp_buf *)jmp_buf_ptr, 1); } -#ifdef WASMTIME_SIGNALS_BASED_TRAPS +#ifdef WASMTIME_NATIVE_SIGNALS static wasmtime_trap_handler_t g_handler = NULL; @@ -124,6 +124,10 @@ int wasmtime_init_traps(wasmtime_trap_handler_t handler) { return 0; } +#endif // WASMTIME_NATIVE_SIGNALS + +#ifdef WASMTIME_VIRTUAL_MEMORY + int wasmtime_memory_image_new(const uint8_t *ptr, uintptr_t len, struct wasmtime_memory_image **ret) { *ret = NULL; @@ -139,7 +143,7 @@ void wasmtime_memory_image_free(struct wasmtime_memory_image *image) { abort(); } -#endif // WASMTIME_SIGNALS_BASED_TRAPS +#endif // WASMTIME_VIRTUAL_MEMORY // Pretend that this platform doesn't have threads where storing in a static is // ok. diff --git a/examples/min-platform/embedding/wasmtime-platform.h b/examples/min-platform/embedding/wasmtime-platform.h index 9d6afa6dc01c..706262e40034 100644 --- a/examples/min-platform/embedding/wasmtime-platform.h +++ b/examples/min-platform/embedding/wasmtime-platform.h @@ -30,28 +30,28 @@ #include #include -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Indicates that the memory region should be readable. */ #define WASMTIME_PROT_READ (1 << 0) #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Indicates that the memory region should be writable. */ #define WASMTIME_PROT_WRITE (1 << 1) #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Indicates that the memory region should be executable. */ #define WASMTIME_PROT_EXEC (1 << 2) #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Abstract pointer type used in the `wasmtime_memory_image_*` APIs which * is defined by the embedder. @@ -59,7 +59,7 @@ typedef struct wasmtime_memory_image wasmtime_memory_image; #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_NATIVE_SIGNALS) /** * Handler function for traps in Wasmtime passed to `wasmtime_init_traps`. * @@ -96,7 +96,7 @@ typedef void (*wasmtime_trap_handler_t)(uintptr_t ip, extern "C" { #endif // __cplusplus -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Creates a new virtual memory mapping of the `size` specified with * protection bits specified in `prot_flags`. @@ -112,7 +112,7 @@ extern "C" { extern int32_t wasmtime_mmap_new(uintptr_t size, uint32_t prot_flags, uint8_t **ret); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Remaps the virtual memory starting at `addr` going for `size` bytes to * the protections specified with a new blank mapping. @@ -128,7 +128,7 @@ extern int32_t wasmtime_mmap_new(uintptr_t size, uint32_t prot_flags, uint8_t ** extern int32_t wasmtime_mmap_remap(uint8_t *addr, uintptr_t size, uint32_t prot_flags); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Unmaps memory at the specified `ptr` for `size` bytes. * @@ -142,7 +142,7 @@ extern int32_t wasmtime_mmap_remap(uint8_t *addr, uintptr_t size, uint32_t prot_ extern int32_t wasmtime_munmap(uint8_t *ptr, uintptr_t size); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Configures the protections associated with a region of virtual memory * starting at `ptr` and going to `size`. @@ -154,7 +154,7 @@ extern int32_t wasmtime_munmap(uint8_t *ptr, uintptr_t size); extern int32_t wasmtime_mprotect(uint8_t *ptr, uintptr_t size, uint32_t prot_flags); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Returns the page size, in bytes, of the current system. */ @@ -195,7 +195,7 @@ extern bool wasmtime_setjmp(const uint8_t **jmp_buf, */ extern void wasmtime_longjmp(const uint8_t *jmp_buf); -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_NATIVE_SIGNALS) /** * Initializes trap-handling logic for this platform. * @@ -213,7 +213,7 @@ extern void wasmtime_longjmp(const uint8_t *jmp_buf); extern int32_t wasmtime_init_traps(wasmtime_trap_handler_t handler); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Attempts to create a new in-memory image of the `ptr`/`len` combo which * can be mapped to virtual addresses in the future. @@ -240,7 +240,7 @@ extern int32_t wasmtime_memory_image_new(const uint8_t *ptr, struct wasmtime_memory_image **ret); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Maps the `image` provided to the virtual address at `addr` and `len`. * @@ -262,7 +262,7 @@ extern int32_t wasmtime_memory_image_map_at(struct wasmtime_memory_image *image, uintptr_t len); #endif -#if defined(WASMTIME_SIGNALS_BASED_TRAPS) +#if defined(WASMTIME_VIRTUAL_MEMORY) /** * Deallocates the provided `wasmtime_memory_image`. * diff --git a/examples/min-platform/src/main.rs b/examples/min-platform/src/main.rs index 3aab4c4169f0..faebbd499e7e 100644 --- a/examples/min-platform/src/main.rs +++ b/examples/min-platform/src/main.rs @@ -69,7 +69,8 @@ fn main() -> Result<()> { // If signals-based-traps are disabled then that additionally means that // some configuration knobs need to be turned to match the expectations of // the guest program being loaded. - if !cfg!(feature = "signals-based-traps") { + if !cfg!(feature = "custom") { + config.memory_init_cow(false); config.memory_reservation(0); config.memory_guard_size(0); config.memory_reservation_for_growth(0); diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 73a7867b81e1..5f13d391feff 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -663,24 +663,19 @@ impl wasmtime_wasi::Subscribe for LogStream { /// if it fails then the pooling allocator is not used and the normal mmap-based /// implementation is used instead. fn use_pooling_allocator_by_default() -> Result> { - #[cfg(feature = "signals-based-traps")] - { - use wasmtime::{Config, Memory, MemoryType}; - const BITS_TO_TEST: u32 = 42; - let mut config = Config::new(); - config.wasm_memory64(true); - config.memory_reservation(1 << BITS_TO_TEST); - let engine = Engine::new(&config)?; - let mut store = Store::new(&engine, ()); - // NB: the maximum size is in wasm pages to take out the 16-bits of wasm - // page size here from the maximum size. - let ty = MemoryType::new64(0, Some(1 << (BITS_TO_TEST - 16))); - if Memory::new(&mut store, ty).is_ok() { - Ok(Some(true)) - } else { - Ok(None) - } + use wasmtime::{Config, Memory, MemoryType}; + const BITS_TO_TEST: u32 = 42; + let mut config = Config::new(); + config.wasm_memory64(true); + config.memory_reservation(1 << BITS_TO_TEST); + let engine = Engine::new(&config)?; + let mut store = Store::new(&engine, ()); + // NB: the maximum size is in wasm pages to take out the 16-bits of wasm + // page size here from the maximum size. + let ty = MemoryType::new64(0, Some(1 << (BITS_TO_TEST - 16))); + if Memory::new(&mut store, ty).is_ok() { + Ok(Some(true)) + } else { + Ok(None) } - #[cfg(not(feature = "signals-based-traps"))] - return Ok(Some(false)); } diff --git a/tests/all/module.rs b/tests/all/module.rs index 683a93fae5b7..5dfbd6a519fe 100644 --- a/tests/all/module.rs +++ b/tests/all/module.rs @@ -255,6 +255,7 @@ fn compile_a_component() -> Result<()> { } #[test] +#[cfg_attr(miri, ignore)] fn tail_call_defaults() -> Result<()> { let wasm_with_tail_calls = "(module (func $a return_call $a))"; diff --git a/tests/unload-engine.rs b/tests/unload-engine.rs index c59af4f9ad31..788453c4ce05 100644 --- a/tests/unload-engine.rs +++ b/tests/unload-engine.rs @@ -3,10 +3,11 @@ //! //! It's not safe for this binary to contain any other tests. +#![cfg(not(miri))] + use wasmtime::*; #[test] -#[cfg_attr(miri, ignore)] fn test_unload_engine() { for _ in 0..3 { std::thread::spawn(|| { diff --git a/tests/wast.rs b/tests/wast.rs index fc062c39fc45..9b7c8110bfca 100644 --- a/tests/wast.rs +++ b/tests/wast.rs @@ -159,14 +159,11 @@ fn run_wast(test: &WastTest, config: WastConfig) -> anyhow::Result<()> { // Don't use 4gb address space reservations when not hogging memory, and // also don't reserve lots of memory after dynamic memories for growth // (makes growth slower). - #[cfg(feature = "signals-based-traps")] - { - cfg.memory_reservation(2 * u64::from(wasmtime_environ::Memory::DEFAULT_PAGE_SIZE)); - cfg.memory_reservation_for_growth(0); + cfg.memory_reservation(2 * u64::from(wasmtime_environ::Memory::DEFAULT_PAGE_SIZE)); + cfg.memory_reservation_for_growth(0); - let small_guard = 64 * 1024; - cfg.memory_guard_size(small_guard); - } + let small_guard = 64 * 1024; + cfg.memory_guard_size(small_guard); } let _pooling_lock = if config.pooling { @@ -177,10 +174,6 @@ fn run_wast(test: &WastTest, config: WastConfig) -> anyhow::Result<()> { return Ok(()); } - if !cfg!(feature = "signals-based-traps") { - return Ok(()); - } - // Reduce the virtual memory required to run multi-memory-based tests. // // The configuration parameters below require that a bare minimum @@ -192,7 +185,6 @@ fn run_wast(test: &WastTest, config: WastConfig) -> anyhow::Result<()> { // force the usage of static memories without guards to reduce the VM // impact. let max_memory_size = limits::MEMORY_SIZE; - #[cfg(feature = "signals-based-traps")] if multi_memory { cfg.memory_reservation(max_memory_size as u64); cfg.memory_reservation_for_growth(0);