diff --git a/lib/compiler-llvm/src/translator/code.rs b/lib/compiler-llvm/src/translator/code.rs index 0b078ab65..5305435e4 100644 --- a/lib/compiler-llvm/src/translator/code.rs +++ b/lib/compiler-llvm/src/translator/code.rs @@ -1,6 +1,7 @@ use super::{ intrinsics::{ - func_type_to_llvm, tbaa_label, type_to_llvm, CtxType, GlobalCache, Intrinsics, MemoryCache, + func_type_to_llvm, tbaa_label, type_to_llvm, CtxType, FunctionCache, GlobalCache, + Intrinsics, MemoryCache, }, read_info::blocktype_to_type, // stackmap::{StackmapEntry, StackmapEntryKind, StackmapRegistry, ValueSemantic}, @@ -1929,7 +1930,10 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { let func_type = &self.wasm_module.signatures[*sigindex]; let func_name = &self.func_names[func_index]; - let (func, callee_vmctx) = self.ctx.func( + let FunctionCache { + func, + vmctx: callee_vmctx, + } = self.ctx.func( func_index, self.intrinsics, self.module, diff --git a/lib/compiler-llvm/src/translator/intrinsics.rs b/lib/compiler-llvm/src/translator/intrinsics.rs index d7ddbfdf2..0cd141db0 100644 --- a/lib/compiler-llvm/src/translator/intrinsics.rs +++ b/lib/compiler-llvm/src/translator/intrinsics.rs @@ -501,9 +501,9 @@ pub enum GlobalCache<'ctx> { } #[derive(Clone, Copy)] -struct FunctionCache<'ctx> { - func: PointerValue<'ctx>, - vmctx: BasicValueEnum<'ctx>, +pub struct FunctionCache<'ctx> { + pub func: PointerValue<'ctx>, + pub vmctx: BasicValueEnum<'ctx>, } pub struct CtxType<'ctx, 'a> { @@ -882,7 +882,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> { context: &'ctx Context, func_name: &String, func_type: &FuncType, - ) -> (PointerValue<'ctx>, BasicValueEnum<'ctx>) { + ) -> FunctionCache<'ctx> { let (cached_functions, wasm_module, ctx_ptr_value, cache_builder, offsets) = ( &mut self.cached_functions, self.wasm_module, @@ -890,7 +890,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> { &self.cache_builder, &self.offsets, ); - let cached = *cached_functions.entry(function_index).or_insert_with(|| { + *cached_functions.entry(function_index).or_insert_with(|| { let llvm_func_type = func_type_to_llvm(context, intrinsics, func_type); if wasm_module.local_func_index(function_index).is_some() { // TODO: assuming names are unique, we don't need the @@ -939,8 +939,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> { vmctx: vmctx_ptr, } } - }); - (cached.func, cached.vmctx) + }) } pub fn memory_grow(