(
&self,
translation: &ModuleTranslation<'_>,
key: FuncKey,
input: FunctionBodyData<'_>,
types: &ModuleTypesBuilder,
symbol: &str,
)
| 450 | } |
| 451 | |
| 452 | fn compile_function( |
| 453 | &self, |
| 454 | translation: &ModuleTranslation<'_>, |
| 455 | key: FuncKey, |
| 456 | input: FunctionBodyData<'_>, |
| 457 | types: &ModuleTypesBuilder, |
| 458 | symbol: &str, |
| 459 | ) -> Result<CompiledFunctionBody, CompileError> { |
| 460 | log::trace!("compiling Wasm function: {key:?} = {symbol:?}"); |
| 461 | |
| 462 | let isa = &*self.isa; |
| 463 | let module = &translation.module; |
| 464 | |
| 465 | let (module_index, def_func_index) = key.unwrap_defined_wasm_function(); |
| 466 | debug_assert_eq!(translation.module_index(), module_index); |
| 467 | |
| 468 | let func_index = module.func_index(def_func_index); |
| 469 | let sig = translation.module.functions[func_index] |
| 470 | .signature |
| 471 | .unwrap_module_type_index(); |
| 472 | let wasm_func_ty = types[sig].unwrap_func(); |
| 473 | |
| 474 | let mut compiler = self.function_compiler(); |
| 475 | |
| 476 | let context = &mut compiler.cx.codegen_context; |
| 477 | context.func.signature = wasm_call_signature(isa, wasm_func_ty, &self.tunables); |
| 478 | let (namespace, index) = key.into_raw_parts(); |
| 479 | context.func.name = UserFuncName::User(UserExternalName { namespace, index }); |
| 480 | |
| 481 | if self.tunables.debug_native { |
| 482 | context.func.collect_debug_info(); |
| 483 | } |
| 484 | |
| 485 | // Branch hints are keyed by function-body-relative offset, so the body's |
| 486 | // module-relative start is needed to convert source locations later. |
| 487 | let FunctionBodyData { validator, body } = input; |
| 488 | let func_body_offset = body.get_binary_reader().original_position(); |
| 489 | |
| 490 | let mut func_env = FuncEnvironment::new( |
| 491 | self, |
| 492 | translation, |
| 493 | types, |
| 494 | wasm_func_ty, |
| 495 | key, |
| 496 | Some(func_index), |
| 497 | func_body_offset, |
| 498 | ); |
| 499 | |
| 500 | // The `stack_limit` global value below is the implementation of stack |
| 501 | // overflow checks in Wasmtime. |
| 502 | // |
| 503 | // The Wasm spec defines that stack overflows will raise a trap, and |
| 504 | // there's also an added constraint where as an embedder you frequently |
| 505 | // are running host-provided code called from wasm. WebAssembly and |
| 506 | // native code currently share the same call stack, so Wasmtime needs to |
| 507 | // make sure that host-provided code will have enough call-stack |
| 508 | // available to it. |
| 509 | // |
nothing calls this directly
no test coverage detected