@@ -17,6 +17,7 @@ mod snapshot;
1717mod stack_ext;
1818mod translate;
1919
20+ use wasmparser:: WasmFeatures ;
2021/// Re-export wasmtime so users can align with our version. This is
2122/// especially useful when providing a custom Linker.
2223pub use wasmtime;
@@ -673,59 +674,30 @@ impl Wizer {
673674
674675 // NB: keep this in sync with the Wasmtime config.
675676 fn wasm_features ( & self ) -> wasmparser:: WasmFeatures {
676- wasmparser:: WasmFeatures {
677- mutable_global : true ,
678- saturating_float_to_int : true ,
679- sign_extension : true ,
680- floats : true ,
681- component_model_values : false ,
682- component_model_nested_names : false ,
683-
684- // Proposals that we support.
685- multi_memory : self . wasm_multi_memory . unwrap_or ( DEFAULT_WASM_MULTI_MEMORY ) ,
686- multi_value : self . wasm_multi_value . unwrap_or ( DEFAULT_WASM_MULTI_VALUE ) ,
687-
688- // Proposals that we should add support for.
689- reference_types : self
690- . wasm_reference_types
677+ let mut features = WasmFeatures :: WASM2 ;
678+
679+ features. set (
680+ WasmFeatures :: REFERENCE_TYPES ,
681+ self . wasm_reference_types
691682 . unwrap_or ( DEFAULT_WASM_REFERENCE_TYPES ) ,
692- simd : self . wasm_simd . unwrap_or ( DEFAULT_WASM_SIMD ) ,
693- threads : false ,
694- tail_call : false ,
695- memory64 : false ,
696- exceptions : false ,
697- extended_const : false ,
698- relaxed_simd : false ,
699- component_model : false ,
700- memory_control : false ,
701- function_references : false ,
702- gc : false ,
703-
704- // XXX: Though we don't fully support bulk memory yet, we
705- // unconditionally turn it on.
706- //
707- // Many parsers, notably our own `wasmparser`, assume that which
708- // Wasm features are enabled or disabled cannot affect parsing, only
709- // validation. That assumption is incorrect when it comes to data
710- // segments, the multi-memory proposal, and the bulk memory
711- // proposal. A `0x01` prefix of a data segment can either mean "this
712- // is a passive segment" if bulk memory is enabled or "this segment
713- // is referring to memory index 1" if both bulk memory is disabled
714- // and multi-memory is enabled. `wasmparser` fails to handle this
715- // edge case, which means that everything built on top of it, like
716- // Wasmtime, also fail to handle this edge case. However, because
717- // bulk memory is merged into the spec proper and is no longer
718- // technically a "proposal", and because a fix would require
719- // significant refactoring and API changes to give a
720- // `wasmparser::Parser` a `wasmparser::WasmFeatures`, we won't ever
721- // resolve this discrepancy in `wasmparser`.
722- //
723- // So we enable bulk memory during parsing, validation, and
724- // execution, but we add our own custom validation pass to ensure
725- // that no table-mutating instructions exist in our input modules
726- // until we *actually* support bulk memory.
727- bulk_memory : true ,
728- }
683+ ) ;
684+ features. set (
685+ WasmFeatures :: MULTI_VALUE ,
686+ self . wasm_multi_value . unwrap_or ( DEFAULT_WASM_MULTI_VALUE ) ,
687+ ) ;
688+ features. set (
689+ WasmFeatures :: SIMD ,
690+ self . wasm_simd . unwrap_or ( DEFAULT_WASM_SIMD ) ,
691+ ) ;
692+ features. set (
693+ WasmFeatures :: MULTI_MEMORY ,
694+ self . wasm_multi_memory . unwrap_or ( DEFAULT_WASM_MULTI_MEMORY ) ,
695+ ) ;
696+
697+ features. set ( WasmFeatures :: TAIL_CALL , true ) ;
698+ features. set ( WasmFeatures :: EXTENDED_CONST , true ) ;
699+
700+ return features;
729701 }
730702
731703 fn wasm_validate ( & self , wasm : & [ u8 ] ) -> anyhow:: Result < ( ) > {
0 commit comments