mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-30 04:09:28 +00:00
Make LLVM work with one-vmctx imported functions
This commit is contained in:
@ -34,7 +34,6 @@ impl FuncTrampoline {
|
||||
let trampoline_ty = intrinsics.void_ty.fn_type(
|
||||
&[
|
||||
intrinsics.ctx_ptr_ty.as_basic_type_enum(), // callee_vmctx ptr
|
||||
intrinsics.ctx_ptr_ty.as_basic_type_enum(), // caller_vmctx ptr
|
||||
callee_ty
|
||||
.ptr_type(AddressSpace::Generic)
|
||||
.as_basic_type_enum(), // callee function address
|
||||
@ -120,11 +119,10 @@ fn generate_trampoline<'ctx>(
|
||||
"");
|
||||
*/
|
||||
|
||||
let (callee_vmctx_ptr, caller_vmctx_ptr, func_ptr, args_rets_ptr) =
|
||||
match trampoline_func.get_params().as_slice() {
|
||||
&[callee_vmctx_ptr, caller_vmctx_ptr, func_ptr, args_rets_ptr] => (
|
||||
let (callee_vmctx_ptr, func_ptr, args_rets_ptr) = match trampoline_func.get_params().as_slice()
|
||||
{
|
||||
&[callee_vmctx_ptr, func_ptr, args_rets_ptr] => (
|
||||
callee_vmctx_ptr,
|
||||
caller_vmctx_ptr,
|
||||
func_ptr.into_pointer_value(),
|
||||
args_rets_ptr.into_pointer_value(),
|
||||
),
|
||||
@ -145,9 +143,8 @@ fn generate_trampoline<'ctx>(
|
||||
Type::FuncRef => unimplemented!("funcref unimplemented in trampoline"),
|
||||
};
|
||||
|
||||
let mut args_vec = Vec::with_capacity(func_sig.params().len() + 2);
|
||||
let mut args_vec = Vec::with_capacity(func_sig.params().len() + 1);
|
||||
args_vec.push(callee_vmctx_ptr);
|
||||
args_vec.push(caller_vmctx_ptr);
|
||||
|
||||
let mut i = 0;
|
||||
for param_ty in func_sig.params().iter() {
|
||||
|
@ -184,7 +184,7 @@ impl FuncTranslator {
|
||||
let ty = wasm_fn_type.params()[idx];
|
||||
let ty = type_to_llvm(&intrinsics, ty);
|
||||
let value = func
|
||||
.get_nth_param((idx as u32).checked_add(2).unwrap())
|
||||
.get_nth_param((idx as u32).checked_add(1).unwrap())
|
||||
.unwrap();
|
||||
// TODO: don't interleave allocas and stores.
|
||||
let alloca = cache_builder.build_alloca(ty, "param");
|
||||
@ -2247,7 +2247,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
};
|
||||
|
||||
let params: Vec<_> = std::iter::repeat(callee_vmctx)
|
||||
.take(2)
|
||||
.take(1)
|
||||
.chain(
|
||||
self.state
|
||||
.peekn_extra(func_type.params().len())?
|
||||
@ -2517,7 +2517,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
let pushed_args = self.state.popn_save_extra(func_type.params().len())?;
|
||||
|
||||
let args: Vec<_> = std::iter::repeat(ctx_ptr)
|
||||
.take(2)
|
||||
.take(1)
|
||||
.chain(pushed_args.into_iter().enumerate().map(|(i, (v, info))| {
|
||||
match func_type.params()[i] {
|
||||
Type::F32 => self.builder.build_bitcast(
|
||||
|
@ -1042,7 +1042,7 @@ pub fn func_type_to_llvm<'ctx>(
|
||||
.iter()
|
||||
.map(|&ty| type_to_llvm(intrinsics, ty));
|
||||
let param_types: Vec<_> = std::iter::repeat(intrinsics.ctx_ptr_ty.as_basic_type_enum())
|
||||
.take(2)
|
||||
.take(1)
|
||||
.chain(user_param_types)
|
||||
.collect();
|
||||
|
||||
|
Reference in New Issue
Block a user