Browse Source

Update the consequences of disabling the `gc` crate feature (#9162)

* Update the consequences of disabling the `gc` crate feature

This commit updates what happens when the `gc` Cargo feature is disabled
at compile time when compiling Wasmtime itself. Previously this would
disable the reference-types proposal (and eventually once finished the
gc/function-references proposal). This has the downside, however, of
additionally disabling non-gc-related features that were bundled into
the `reference-types` proposal such as multi-table and the encodings of
table indices as LEBs in `call_indirect` instructions for example.

The change in this commit is to instead toggle the newly-added
`GC_TYPES` feature in `wasmparser`. This feature does not correspond to
upstream wasm proposals and instead only gates types such as `externref`
or `anyref`. The `funcref` and `exnref` types are not gated as they're
not expected to require a full GC.

This means that in Wasmtime the `reference-types` feature is now always
active by default regardless of crate features. If the `gc` crate
feature is disabled then only `externref` values are disallowed.

This additionally flags `GC_TYPES` as unsupported in Winch due to no
support for `externref` yet. This means, though, that Winch can be
considered as supporting the `reference-types` proposal (and things like
multi-table) as expected. Disabling `externref` support switched a few
tests to failing so those exceptions are now listed in `tests/wast.rs`

* Fix aarch64 tests

* Fix older invocations of `check_cfg_bool`
pull/9168/head
Alex Crichton 3 months ago
committed by GitHub
parent
commit
94236eb55b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      crates/wasmtime/src/config.rs
  2. 17
      crates/wasmtime/src/engine/serialization.rs
  3. 10
      tests/wast.rs

16
crates/wasmtime/src/config.rs

@ -1750,16 +1750,16 @@ impl Config {
| WasmFeatures::FUNCTION_REFERENCES
| WasmFeatures::THREADS
| WasmFeatures::RELAXED_SIMD
| WasmFeatures::TAIL_CALL;
| WasmFeatures::TAIL_CALL
| WasmFeatures::GC_TYPES;
match self.compiler_target().architecture {
target_lexicon::Architecture::Aarch64(_) => {
// no support for simd on aarch64
unsupported |= WasmFeatures::SIMD;
// technically this is mostly supported in the sense of
// multi-tables work well enough but enough of MVP wasm
// currently panics that this is used here instead to
// disable most spec tests which require reference
// types.
// things like multi-table are technically supported on
// winch on aarch64 but this helps gate most spec tests
// by default which otherwise currently cause panics.
unsupported |= WasmFeatures::REFERENCE_TYPES;
}
@ -1791,7 +1791,6 @@ impl Config {
// subject to the criteria at
// https://docs.wasmtime.dev/contributing-implementing-wasm-proposals.html
features |= WasmFeatures::FLOATS;
features |= WasmFeatures::GC_TYPES;
features |= WasmFeatures::MULTI_VALUE;
features |= WasmFeatures::BULK_MEMORY;
features |= WasmFeatures::SIGN_EXTENSION;
@ -1802,8 +1801,9 @@ impl Config {
features |= WasmFeatures::RELAXED_SIMD;
features |= WasmFeatures::TAIL_CALL;
features |= WasmFeatures::EXTENDED_CONST;
if cfg!(feature = "gc") {
features |= WasmFeatures::REFERENCE_TYPES;
if cfg!(feature = "gc") {
features |= WasmFeatures::GC_TYPES;
}
if cfg!(feature = "threads") {
features |= WasmFeatures::THREADS;

17
crates/wasmtime/src/engine/serialization.rs

@ -484,28 +484,21 @@ impl Metadata<'_> {
} = self.features;
use wasmparser::WasmFeatures as F;
Self::check_cfg_bool(
cfg!(feature = "gc"),
"gc",
Self::check_bool(
reference_types,
other.contains(F::REFERENCE_TYPES),
"WebAssembly reference types support",
)?;
Self::check_cfg_bool(
cfg!(feature = "gc"),
"gc",
Self::check_bool(
function_references,
other.contains(F::FUNCTION_REFERENCES),
"WebAssembly function-references support",
)?;
Self::check_cfg_bool(
cfg!(feature = "gc"),
"gc",
Self::check_bool(
gc,
other.contains(F::GC),
"WebAssembly garbage collection support",
)?;
Self::check_bool(
multi_value,
other.contains(F::MULTI_VALUE),
@ -572,7 +565,9 @@ impl Metadata<'_> {
other.contains(F::COMPONENT_MODEL_MULTIPLE_RETURNS),
"WebAssembly component model support for multiple returns",
)?;
Self::check_bool(
Self::check_cfg_bool(
cfg!(feature = "gc"),
"gc",
gc_types,
other.contains(F::GC_TYPES),
"support for WebAssembly gc types",

10
tests/wast.rs

@ -73,9 +73,15 @@ fn should_fail(test: &Path, strategy: Strategy) -> bool {
if strategy == Strategy::Winch {
let unsupported = [
// externref/reference-types related
"component-model/modules.wast",
"extended-const/elem.wast",
"extended-const/global.wast",
"memory64/threads.wast",
"misc_testsuite/externref-id-function.wast",
"misc_testsuite/externref-segment.wast",
"misc_testsuite/externref-segments.wast",
"misc_testsuite/externref-table-dropped-segment-issue-8281.wast",
"misc_testsuite/linking-errors.wast",
"misc_testsuite/many_table_gets_lead_to_gc.wast",
"misc_testsuite/mutable_externref_globals.wast",
"misc_testsuite/no-mixup-stack-maps.wast",
@ -86,18 +92,18 @@ fn should_fail(test: &Path, strategy: Strategy) -> bool {
"spec_testsuite/data-invalid.wast",
"spec_testsuite/elem.wast",
"spec_testsuite/global.wast",
"spec_testsuite/linking.wast",
"spec_testsuite/ref_func.wast",
"spec_testsuite/ref_is_null.wast",
"spec_testsuite/ref_null.wast",
"spec_testsuite/select.wast",
"spec_testsuite/table-sub.wast",
"spec_testsuite/table_fill.wast",
"spec_testsuite/table_get.wast",
"spec_testsuite/table_grow.wast",
"spec_testsuite/table_set.wast",
"spec_testsuite/table_size.wast",
"spec_testsuite/unreached-invalid.wast",
"extended-const/elem.wast",
"extended-const/global.wast",
// simd-related failures
"annotations/simd_lane.wast",
"memory64/simd.wast",

Loading…
Cancel
Save