Path: blob/main/crates/test-util/src/wasmtime_wast.rs
3069 views
use crate::wast;1use wasmtime::Config;23/// Helper method to apply `wast_config` to `config`.4pub fn apply_wast_config(config: &mut Config, wast_config: &wast::WastConfig) {5use wasmtime_environ::TripleExt;6use wast::{Collector, Compiler};78config.strategy(match wast_config.compiler {9Compiler::CraneliftNative | Compiler::CraneliftPulley => wasmtime::Strategy::Cranelift,10Compiler::Winch => wasmtime::Strategy::Winch,11});12if let Compiler::CraneliftPulley = wast_config.compiler {13config14.target(&target_lexicon::Triple::pulley_host().to_string())15.unwrap();16}17config.collector(match wast_config.collector {18Collector::Auto => wasmtime::Collector::Auto,19Collector::Null => wasmtime::Collector::Null,20Collector::DeferredReferenceCounting => wasmtime::Collector::DeferredReferenceCounting,21});22}2324/// Helper method to apply `test_config` to `config`.25pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {26let wast::TestConfig {27memory64,28custom_page_sizes,29multi_memory,30threads,31shared_everything_threads,32gc,33function_references,34relaxed_simd,35reference_types,36tail_call,37extended_const,38wide_arithmetic,39component_model_async,40component_model_async_builtins,41component_model_async_stackful,42component_model_threading,43component_model_error_context,44component_model_gc,45component_model_fixed_length_lists,46nan_canonicalization,47simd,48exceptions,49legacy_exceptions,50stack_switching,51custom_descriptors,5253hogs_memory: _,54gc_types: _,55spec_test: _,56} = *test_config;57// Note that all of these proposals/features are currently default-off to58// ensure that we annotate all tests accurately with what features they59// need, even in the future when features are stabilized.60let memory64 = memory64.unwrap_or(false);61let custom_page_sizes = custom_page_sizes.unwrap_or(false);62let multi_memory = multi_memory.unwrap_or(false);63let threads = threads.unwrap_or(false);64let shared_everything_threads = shared_everything_threads.unwrap_or(false);65let gc = gc.unwrap_or(false);66let tail_call = tail_call.unwrap_or(false);67let extended_const = extended_const.unwrap_or(false);68let wide_arithmetic = wide_arithmetic.unwrap_or(false);69let component_model_async = component_model_async.unwrap_or(false);70let component_model_async_builtins = component_model_async_builtins.unwrap_or(false);71let component_model_async_stackful = component_model_async_stackful.unwrap_or(false);72let component_model_threading = component_model_threading.unwrap_or(false);73let component_model_error_context = component_model_error_context.unwrap_or(false);74let component_model_gc = component_model_gc.unwrap_or(false);75let component_model_fixed_length_lists = component_model_fixed_length_lists.unwrap_or(false);76let nan_canonicalization = nan_canonicalization.unwrap_or(false);77let relaxed_simd = relaxed_simd.unwrap_or(false);78let legacy_exceptions = legacy_exceptions.unwrap_or(false);79let stack_switching = stack_switching.unwrap_or(false);8081// Some proposals in wasm depend on previous proposals. For example the gc82// proposal depends on function-references which depends on reference-types.83// To avoid needing to enable all of them at once implicitly enable84// downstream proposals once the end proposal is enabled (e.g. when enabling85// gc that also enables function-references and reference-types).86let function_references = gc || function_references.unwrap_or(false);87let reference_types = function_references || reference_types.unwrap_or(false);88let simd = relaxed_simd || simd.unwrap_or(false);8990let exceptions = stack_switching || exceptions.unwrap_or(false);9192// Not implemented in Wasmtime yet.93let _custom_descriptors = custom_descriptors.unwrap_or(false);9495config96.wasm_multi_memory(multi_memory)97.wasm_threads(threads)98.wasm_shared_everything_threads(shared_everything_threads)99.wasm_memory64(memory64)100.wasm_function_references(function_references)101.wasm_gc(gc)102.wasm_reference_types(reference_types)103.wasm_relaxed_simd(relaxed_simd)104.wasm_simd(simd)105.wasm_tail_call(tail_call)106.wasm_custom_page_sizes(custom_page_sizes)107.wasm_extended_const(extended_const)108.wasm_wide_arithmetic(wide_arithmetic)109.wasm_component_model_async(component_model_async)110.wasm_component_model_async_builtins(component_model_async_builtins)111.wasm_component_model_async_stackful(component_model_async_stackful)112.wasm_component_model_threading(component_model_threading)113.wasm_component_model_error_context(component_model_error_context)114.wasm_component_model_gc(component_model_gc)115.wasm_component_model_fixed_length_lists(component_model_fixed_length_lists)116.wasm_exceptions(exceptions)117.wasm_stack_switching(stack_switching)118.cranelift_nan_canonicalization(nan_canonicalization);119#[expect(deprecated, reason = "forwarding legacy-exceptions")]120config.wasm_legacy_exceptions(legacy_exceptions);121}122123124