chore(compiler-cranelift) It's cheaper to copy TargetFrontendConfig rather than ref.

Learn more at https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref.
This commit is contained in:
Ivan Enderlin
2020-06-09 14:39:06 +02:00
parent 05261d4094
commit ce2379622a
6 changed files with 8 additions and 8 deletions

View File

@ -81,7 +81,7 @@ impl Compiler for CraneliftCompiler {
let signatures = module
.signatures
.iter()
.map(|(_sig_index, func_type)| signature_to_cranelift_ir(func_type, &frontend_config))
.map(|(_sig_index, func_type)| signature_to_cranelift_ir(func_type, frontend_config))
.collect::<PrimaryMap<SignatureIndex, ir::Signature>>();
let functions = function_body_inputs

View File

@ -715,7 +715,7 @@ impl<'module_environment> BaseFuncEnvironment for FuncEnvironment<'module_enviro
Ok(GlobalVariable::Memory {
gv: ptr,
offset: offset.into(),
ty: type_to_irtype(self.module.globals[index].ty, &self.target_config())?,
ty: type_to_irtype(self.module.globals[index].ty, self.target_config())?,
})
}

View File

@ -26,7 +26,7 @@ pub fn make_trampoline_dynamic_function(
) -> Result<FunctionBody, CompileError> {
let pointer_type = isa.pointer_type();
let frontend_config = isa.frontend_config();
let signature = signature_to_cranelift_ir(func_type, &frontend_config);
let signature = signature_to_cranelift_ir(func_type, frontend_config);
let mut stub_sig = ir::Signature::new(frontend_config.default_call_conv);
// Add the caller `vmctx` parameter.
stub_sig.params.push(ir::AbiParam::special(

View File

@ -27,7 +27,7 @@ pub fn make_trampoline_function_call(
) -> Result<FunctionBody, CompileError> {
let pointer_type = isa.pointer_type();
let frontend_config = isa.frontend_config();
let signature = signature_to_cranelift_ir(func_type, &frontend_config);
let signature = signature_to_cranelift_ir(func_type, frontend_config);
let mut wrapper_sig = ir::Signature::new(frontend_config.default_call_conv);
// Add the callee `vmctx` parameter.

View File

@ -66,7 +66,7 @@ pub trait TargetEnvironment {
///
/// This returns `R64` for 64-bit architectures and `R32` for 32-bit architectures.
fn reference_type(&self) -> ir::Type {
reference_type(&self.target_config()).expect("expected reference type")
reference_type(self.target_config()).expect("expected reference type")
}
}

View File

@ -18,7 +18,7 @@ use wasmer_runtime::libcalls::LibCall;
/// Helper function translate a Function signature into Cranelift Ir
pub fn signature_to_cranelift_ir(
signature: &FunctionType,
target_config: &TargetFrontendConfig,
target_config: TargetFrontendConfig,
) -> ir::Signature {
let mut sig = ir::Signature::new(target_config.default_call_conv);
sig.params.extend(signature.params().iter().map(|&ty| {
@ -40,7 +40,7 @@ pub fn signature_to_cranelift_ir(
}
/// Helper function translating wasmparser types to Cranelift types when possible.
pub fn reference_type(target_config: &TargetFrontendConfig) -> WasmResult<ir::Type> {
pub fn reference_type(target_config: TargetFrontendConfig) -> WasmResult<ir::Type> {
match target_config.pointer_type() {
ir::types::I32 => Ok(ir::types::R32),
ir::types::I64 => Ok(ir::types::R64),
@ -51,7 +51,7 @@ pub fn reference_type(target_config: &TargetFrontendConfig) -> WasmResult<ir::Ty
}
/// Helper function translating wasmparser types to Cranelift types when possible.
pub fn type_to_irtype(ty: Type, target_config: &TargetFrontendConfig) -> WasmResult<ir::Type> {
pub fn type_to_irtype(ty: Type, target_config: TargetFrontendConfig) -> WasmResult<ir::Type> {
match ty {
Type::I32 => Ok(ir::types::I32),
Type::I64 => Ok(ir::types::I64),