Skip to content

Commit

Permalink
update(compiler) switched upstream Inkwell (for wasmerio#2645)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Nov 5, 2021
1 parent e389ad0 commit 7ccd6af
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/compiler-llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ rayon = "1.5"
loupe = "0.1"

[dependencies.inkwell]
package = "wasmer_inkwell"
version = "0.2.0-alpha.2"
package = "inkwell"
version = "0.1.0-beta.4"
default-features = false
features = ["llvm11-0", "target-x86", "target-aarch64"]

Expand Down
7 changes: 5 additions & 2 deletions lib/compiler-llvm/src/trampoline/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use inkwell::{
};
use std::cmp;
use std::convert::TryInto;
use std::convert::TryFrom;
use wasmer_compiler::{CompileError, FunctionBody, RelocationTarget};
use wasmer_types::{FunctionType, LocalFunctionIndex};

Expand Down Expand Up @@ -346,7 +347,8 @@ impl FuncTrampoline {
args_vec.push(arg.into());
}

let call_site = builder.build_call(func_ptr, args_vec.as_slice().into(), "call");
let callable_func = inkwell::values::CallableValue::try_from(func_ptr).unwrap();
let call_site = builder.build_call(callable_func, args_vec.as_slice().into(), "call");
for (attr, attr_loc) in func_attrs {
call_site.add_attribute(*attr_loc, *attr);
}
Expand Down Expand Up @@ -441,7 +443,8 @@ impl FuncTrampoline {
.into_pointer_value();

let values_ptr = builder.build_pointer_cast(values, intrinsics.i128_ptr_ty, "");
builder.build_call(callee, &[vmctx.into(), values_ptr.into()], "");
let callable_func = inkwell::values::CallableValue::try_from(callee).unwrap();
builder.build_call(callable_func, &[vmctx.into(), values_ptr.into()], "");

if func_sig.results().is_empty() {
builder.build_return(None);
Expand Down
13 changes: 9 additions & 4 deletions lib/compiler-llvm/src/translator/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use smallvec::SmallVec;
use crate::abi::{get_abi, Abi};
use crate::config::{CompiledKind, LLVM};
use crate::object_file::{load_object_file, CompiledFunction};
use std::convert::TryFrom;
use wasmer_compiler::wasmparser::{MemoryImmediate, Operator};
use wasmer_compiler::{
wptype_to_type, CompileError, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader,
Expand Down Expand Up @@ -2225,8 +2226,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
}
*/

let callable_func = inkwell::values::CallableValue::try_from(func).unwrap();
let call_site = self.builder.build_call(
func,
callable_func,
params
.iter()
.copied()
Expand Down Expand Up @@ -2517,8 +2519,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
}
}
*/
let callable_func = inkwell::values::CallableValue::try_from(typed_func_ptr).unwrap();
let call_site = self.builder.build_call(
typed_func_ptr,
callable_func,
params
.iter()
.copied()
Expand Down Expand Up @@ -10910,8 +10913,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let memory_index = MemoryIndex::from_u32(mem);
let delta = self.state.pop1()?;
let grow_fn_ptr = self.ctx.memory_grow(memory_index, self.intrinsics);
let callable_func = inkwell::values::CallableValue::try_from(grow_fn_ptr).unwrap();
let grow = self.builder.build_call(
grow_fn_ptr,
callable_func,
&[
vmctx.as_basic_value_enum().into(),
delta.into(),
Expand All @@ -10924,8 +10928,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
Operator::MemorySize { mem, mem_byte: _ } => {
let memory_index = MemoryIndex::from_u32(mem);
let size_fn_ptr = self.ctx.memory_size(memory_index, self.intrinsics);
let callable_func = inkwell::values::CallableValue::try_from(size_fn_ptr).unwrap();
let size = self.builder.build_call(
size_fn_ptr,
callable_func,
&[
vmctx.as_basic_value_enum().into(),
self.intrinsics.i32_ty.const_int(mem.into(), false).into(),
Expand Down

0 comments on commit 7ccd6af

Please sign in to comment.