Add dereferenceable attribute to the vmctx pointer.

This commit is contained in:
Nick Lewycky
2021-01-27 11:08:13 -08:00
parent dabc454ee3
commit 657d3a52dd
6 changed files with 52 additions and 12 deletions

View File

@ -34,7 +34,7 @@ use wasmer_types::{
FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, MemoryIndex, SignatureIndex,
TableIndex, Type,
};
use wasmer_vm::{MemoryStyle, ModuleInfo, TableStyle};
use wasmer_vm::{MemoryStyle, ModuleInfo, TableStyle, VMOffsets};
const FUNCTION_SECTION: &str = "__TEXT,wasmer_function";
@ -101,10 +101,12 @@ impl FuncTranslator {
.get(wasm_module.functions[func_index])
.unwrap();
// TODO: pointer width
let offsets = VMOffsets::new(8, &wasm_module);
let intrinsics = Intrinsics::declare(&module, &self.ctx);
let (func_type, func_attrs) =
self.abi
.func_type_to_llvm(&self.ctx, &intrinsics, wasm_fn_type)?;
.func_type_to_llvm(&self.ctx, &intrinsics, Some(&offsets), wasm_fn_type)?;
let func = module.add_function(&function_name, func_type, Some(Linkage::External));
for (attr, attr_loc) in &func_attrs {
@ -2350,9 +2352,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
self.builder.build_unreachable();
self.builder.position_at_end(continue_block);
let (llvm_func_type, llvm_func_attrs) =
self.abi
.func_type_to_llvm(&self.context, &self.intrinsics, func_type)?;
let (llvm_func_type, llvm_func_attrs) = self.abi.func_type_to_llvm(
&self.context,
&self.intrinsics,
Some(self.ctx.get_offsets()),
func_type,
)?;
let params = self.state.popn_save_extra(func_type.params().len())?;