wasmtime_test_util/
wasmtime_wast.rs1use crate::wast;
2use wasmtime::Config;
3
4pub fn apply_wast_config(config: &mut Config, wast_config: &wast::WastConfig) {
6 use wasmtime_environ::TripleExt;
7 use wast::{Collector, Compiler};
8
9 config.strategy(match wast_config.compiler {
10 Compiler::CraneliftNative | Compiler::CraneliftPulley => wasmtime::Strategy::Cranelift,
11 Compiler::Winch => wasmtime::Strategy::Winch,
12 });
13 if let Compiler::CraneliftPulley = wast_config.compiler {
14 config
15 .target(&target_lexicon::Triple::pulley_host().to_string())
16 .unwrap();
17 }
18 config.collector(match wast_config.collector {
19 Collector::Auto => wasmtime::Collector::Auto,
20 Collector::Null => wasmtime::Collector::Null,
21 Collector::DeferredReferenceCounting => wasmtime::Collector::DeferredReferenceCounting,
22 });
23}
24
25pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
27 let wast::TestConfig {
28 memory64,
29 custom_page_sizes,
30 multi_memory,
31 threads,
32 shared_everything_threads,
33 gc,
34 function_references,
35 relaxed_simd,
36 reference_types,
37 tail_call,
38 extended_const,
39 wide_arithmetic,
40 component_model_async,
41 component_model_async_builtins,
42 component_model_async_stackful,
43 component_model_threading,
44 component_model_error_context,
45 component_model_gc,
46 component_model_map,
47 component_model_fixed_length_lists,
48 nan_canonicalization,
49 simd,
50 exceptions,
51 legacy_exceptions,
52 stack_switching,
53 custom_descriptors,
54
55 hogs_memory: _,
56 gc_types: _,
57 spec_test: _,
58 } = *test_config;
59 let memory64 = memory64.unwrap_or(false);
63 let custom_page_sizes = custom_page_sizes.unwrap_or(false);
64 let multi_memory = multi_memory.unwrap_or(false);
65 let threads = threads.unwrap_or(false);
66 let shared_everything_threads = shared_everything_threads.unwrap_or(false);
67 let gc = gc.unwrap_or(false);
68 let tail_call = tail_call.unwrap_or(false);
69 let extended_const = extended_const.unwrap_or(false);
70 let wide_arithmetic = wide_arithmetic.unwrap_or(false);
71 let component_model_async = component_model_async.unwrap_or(false);
72 let component_model_async_builtins = component_model_async_builtins.unwrap_or(false);
73 let component_model_async_stackful = component_model_async_stackful.unwrap_or(false);
74 let component_model_threading = component_model_threading.unwrap_or(false);
75 let component_model_error_context = component_model_error_context.unwrap_or(false);
76 let component_model_gc = component_model_gc.unwrap_or(false);
77 let component_model_map = component_model_map.unwrap_or(false);
78 let component_model_fixed_length_lists = component_model_fixed_length_lists.unwrap_or(false);
79 let nan_canonicalization = nan_canonicalization.unwrap_or(false);
80 let relaxed_simd = relaxed_simd.unwrap_or(false);
81 let legacy_exceptions = legacy_exceptions.unwrap_or(false);
82 let stack_switching = stack_switching.unwrap_or(false);
83
84 let function_references = gc || function_references.unwrap_or(false);
90 let reference_types = function_references || reference_types.unwrap_or(false);
91 let simd = relaxed_simd || simd.unwrap_or(false);
92
93 let exceptions = stack_switching || exceptions.unwrap_or(false);
94
95 let _custom_descriptors = custom_descriptors.unwrap_or(false);
97
98 config
99 .wasm_multi_memory(multi_memory)
100 .wasm_threads(threads)
101 .wasm_shared_everything_threads(shared_everything_threads)
102 .wasm_memory64(memory64)
103 .wasm_function_references(function_references)
104 .wasm_gc(gc)
105 .wasm_reference_types(reference_types)
106 .wasm_relaxed_simd(relaxed_simd)
107 .wasm_simd(simd)
108 .wasm_tail_call(tail_call)
109 .wasm_custom_page_sizes(custom_page_sizes)
110 .wasm_extended_const(extended_const)
111 .wasm_wide_arithmetic(wide_arithmetic)
112 .wasm_component_model_async(component_model_async)
113 .wasm_component_model_async_builtins(component_model_async_builtins)
114 .wasm_component_model_async_stackful(component_model_async_stackful)
115 .wasm_component_model_threading(component_model_threading)
116 .wasm_component_model_error_context(component_model_error_context)
117 .wasm_component_model_gc(component_model_gc)
118 .wasm_component_model_map(component_model_map)
119 .wasm_component_model_fixed_length_lists(component_model_fixed_length_lists)
120 .wasm_exceptions(exceptions)
121 .wasm_stack_switching(stack_switching)
122 .cranelift_nan_canonicalization(nan_canonicalization);
123 #[expect(deprecated, reason = "forwarding legacy-exceptions")]
124 config.wasm_legacy_exceptions(legacy_exceptions);
125}