(
&self,
translation: &ModuleTranslation<'_>,
key: FuncKey,
data: FunctionBodyData<'_>,
types: &ModuleTypesBuilder,
symbol: &str,
)
| 111 | } |
| 112 | |
| 113 | fn compile_function( |
| 114 | &self, |
| 115 | translation: &ModuleTranslation<'_>, |
| 116 | key: FuncKey, |
| 117 | data: FunctionBodyData<'_>, |
| 118 | types: &ModuleTypesBuilder, |
| 119 | symbol: &str, |
| 120 | ) -> Result<CompiledFunctionBody, CompileError> { |
| 121 | log::trace!("compiling function: {key:?} = {symbol:?}"); |
| 122 | |
| 123 | let (module_index, def_func_index) = key.unwrap_defined_wasm_function(); |
| 124 | debug_assert_eq!(module_index, translation.module_index()); |
| 125 | |
| 126 | let index = translation.module.func_index(def_func_index); |
| 127 | let sig = translation.module.functions[index] |
| 128 | .signature |
| 129 | .unwrap_module_type_index(); |
| 130 | let ty = types[sig].unwrap_func(); |
| 131 | let FunctionBodyData { |
| 132 | body, validator, .. |
| 133 | } = data; |
| 134 | let mut context = self.get_context(translation); |
| 135 | let mut validator = validator.into_validator(mem::take(&mut context.allocations)); |
| 136 | let func = self |
| 137 | .isa |
| 138 | .compile_function( |
| 139 | ty, |
| 140 | &body, |
| 141 | translation, |
| 142 | types, |
| 143 | &mut context.builtins, |
| 144 | &mut validator, |
| 145 | &self.tunables, |
| 146 | ) |
| 147 | .map_err(|e| CompileError::Codegen(format!("{e:?}"))); |
| 148 | self.save_context(context, validator.into_allocations()); |
| 149 | let mut func = func?; |
| 150 | |
| 151 | let reader = body.get_binary_reader(); |
| 152 | func.set_address_map( |
| 153 | reader.original_position() as u32, |
| 154 | reader.bytes_remaining() as u32, |
| 155 | self.tunables.generate_address_map, |
| 156 | ); |
| 157 | |
| 158 | if self.isa.flags().unwind_info() { |
| 159 | self.emit_unwind_info(&mut func)?; |
| 160 | } |
| 161 | |
| 162 | Ok(CompiledFunctionBody { |
| 163 | code: box_dyn_any_compiled_function(func), |
| 164 | // TODO: Winch doesn't support GC objects and stack maps and all that yet. |
| 165 | needs_gc_heap: false, |
| 166 | }) |
| 167 | } |
| 168 | |
| 169 | fn compile_trampoline( |
| 170 | &self, |
no test coverage detected