mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-24 17:29:26 +00:00
Use abi::args_to_call
when placing a direct call.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use super::{
|
||||
abi,
|
||||
intrinsics::{
|
||||
func_type_to_llvm, tbaa_label, type_to_llvm, CtxType, FunctionCache, GlobalCache,
|
||||
Intrinsics, MemoryCache,
|
||||
@ -1942,35 +1943,42 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
func_type,
|
||||
);
|
||||
|
||||
let params: Vec<_> = std::iter::once(callee_vmctx)
|
||||
.chain(
|
||||
self.state
|
||||
.peekn_extra(func_type.params().len())?
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, (v, info))| match func_type.params()[i] {
|
||||
Type::F32 => self.builder.build_bitcast(
|
||||
self.apply_pending_canonicalization(*v, *info),
|
||||
self.intrinsics.f32_ty,
|
||||
"",
|
||||
),
|
||||
Type::F64 => self.builder.build_bitcast(
|
||||
self.apply_pending_canonicalization(*v, *info),
|
||||
self.intrinsics.f64_ty,
|
||||
"",
|
||||
),
|
||||
Type::V128 => self.apply_pending_canonicalization(*v, *info),
|
||||
_ => *v,
|
||||
}),
|
||||
)
|
||||
.collect();
|
||||
|
||||
/*
|
||||
let func_ptr = self.llvm.functions.borrow_mut()[&func_index];
|
||||
|
||||
(params, func_ptr.as_global_value().as_pointer_value())
|
||||
*/
|
||||
self.state.popn(func_type.params().len())?;
|
||||
let params = self.state.popn_save_extra(func_type.params().len())?;
|
||||
|
||||
// Apply pending canonicalizations.
|
||||
let params =
|
||||
params
|
||||
.iter()
|
||||
.zip(func_type.params().iter())
|
||||
.map(|((v, info), wasm_ty)| match wasm_ty {
|
||||
Type::F32 => self.builder.build_bitcast(
|
||||
self.apply_pending_canonicalization(*v, *info),
|
||||
self.intrinsics.f32_ty,
|
||||
"",
|
||||
),
|
||||
Type::F64 => self.builder.build_bitcast(
|
||||
self.apply_pending_canonicalization(*v, *info),
|
||||
self.intrinsics.f64_ty,
|
||||
"",
|
||||
),
|
||||
Type::V128 => self.apply_pending_canonicalization(*v, *info),
|
||||
_ => *v,
|
||||
});
|
||||
|
||||
let params = abi::args_to_call(
|
||||
// TODO: should be an alloca_builder.
|
||||
&self.builder,
|
||||
func_type,
|
||||
callee_vmctx.into_pointer_value(),
|
||||
&func.get_type().get_element_type().into_function_type(),
|
||||
params.collect::<Vec<_>>().as_slice(),
|
||||
);
|
||||
|
||||
/*
|
||||
if self.track_state {
|
||||
if let Some(offset) = opcode_offset {
|
||||
|
Reference in New Issue
Block a user