mirror of
https://github.com/mii443/wasmer.git
synced 2025-09-04 08:29:16 +00:00
Merge #2656
2656: update(compiler) switched upstream Inkwell (for #2645) r=Amanieu a=ptitSeb # Description Use upstream Inkwell instead of custom version Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
This commit is contained in:
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -1001,10 +1001,25 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inkwell_internals"
|
name = "inkwell"
|
||||||
version = "0.3.0"
|
version = "0.1.0-beta.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2e1f71330ccec54ee62533ae88574c4169b67fb4b95cbb1196a1322582abd11"
|
checksum = "2223d0eba0ae6d40a3e4680c6a3209143471e1f38b41746ea309aa36dde9f90b"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"inkwell_internals",
|
||||||
|
"libc",
|
||||||
|
"llvm-sys",
|
||||||
|
"once_cell",
|
||||||
|
"parking_lot",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inkwell_internals"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3c7090af3d300424caa81976b8c97bca41cd70e861272c072e188ae082fb49f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1141,9 +1156,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "llvm-sys"
|
name = "llvm-sys"
|
||||||
version = "110.0.1"
|
version = "110.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "21ede189444b8c78907e5d36da5dabcf153170fcff9c1dba48afc4b33c7e19f0"
|
checksum = "3b7cc88ba864d592f52132ed3a19a97118fe16c92a63961f54b0ab7279c5407f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@ -2820,6 +2835,7 @@ version = "2.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cc",
|
"cc",
|
||||||
|
"inkwell",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
@ -2834,7 +2850,6 @@ dependencies = [
|
|||||||
"wasmer-compiler",
|
"wasmer-compiler",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
"wasmer_inkwell",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3141,21 +3156,6 @@ dependencies = [
|
|||||||
"wasmer-wast",
|
"wasmer-wast",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasmer_inkwell"
|
|
||||||
version = "0.2.0-alpha.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5eca826323f39b29a38cd31c8eb33de76945c6193f30a2806c6cde6f6cd42cb1"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"inkwell_internals",
|
|
||||||
"libc",
|
|
||||||
"llvm-sys",
|
|
||||||
"once_cell",
|
|
||||||
"parking_lot",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmparser"
|
name = "wasmparser"
|
||||||
version = "0.78.2"
|
version = "0.78.2"
|
||||||
|
@ -25,8 +25,8 @@ rayon = "1.5"
|
|||||||
loupe = "0.1"
|
loupe = "0.1"
|
||||||
|
|
||||||
[dependencies.inkwell]
|
[dependencies.inkwell]
|
||||||
package = "wasmer_inkwell"
|
package = "inkwell"
|
||||||
version = "0.2.0-alpha.2"
|
version = "0.1.0-beta.4"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["llvm11-0", "target-x86", "target-aarch64"]
|
features = ["llvm11-0", "target-x86", "target-aarch64"]
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use inkwell::{
|
|||||||
AddressSpace, DLLStorageClass,
|
AddressSpace, DLLStorageClass,
|
||||||
};
|
};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
use std::convert::TryFrom;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use wasmer_compiler::{CompileError, FunctionBody, RelocationTarget};
|
use wasmer_compiler::{CompileError, FunctionBody, RelocationTarget};
|
||||||
use wasmer_types::{FunctionType, LocalFunctionIndex};
|
use wasmer_types::{FunctionType, LocalFunctionIndex};
|
||||||
@ -346,7 +347,8 @@ impl FuncTrampoline {
|
|||||||
args_vec.push(arg.into());
|
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 {
|
for (attr, attr_loc) in func_attrs {
|
||||||
call_site.add_attribute(*attr_loc, *attr);
|
call_site.add_attribute(*attr_loc, *attr);
|
||||||
}
|
}
|
||||||
@ -441,7 +443,8 @@ impl FuncTrampoline {
|
|||||||
.into_pointer_value();
|
.into_pointer_value();
|
||||||
|
|
||||||
let values_ptr = builder.build_pointer_cast(values, intrinsics.i128_ptr_ty, "");
|
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() {
|
if func_sig.results().is_empty() {
|
||||||
builder.build_return(None);
|
builder.build_return(None);
|
||||||
|
@ -24,6 +24,7 @@ use smallvec::SmallVec;
|
|||||||
use crate::abi::{get_abi, Abi};
|
use crate::abi::{get_abi, Abi};
|
||||||
use crate::config::{CompiledKind, LLVM};
|
use crate::config::{CompiledKind, LLVM};
|
||||||
use crate::object_file::{load_object_file, CompiledFunction};
|
use crate::object_file::{load_object_file, CompiledFunction};
|
||||||
|
use std::convert::TryFrom;
|
||||||
use wasmer_compiler::wasmparser::{MemoryImmediate, Operator};
|
use wasmer_compiler::wasmparser::{MemoryImmediate, Operator};
|
||||||
use wasmer_compiler::{
|
use wasmer_compiler::{
|
||||||
wptype_to_type, CompileError, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader,
|
wptype_to_type, CompileError, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader,
|
||||||
@ -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(
|
let call_site = self.builder.build_call(
|
||||||
func,
|
callable_func,
|
||||||
params
|
params
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
@ -2517,8 +2519,10 @@ 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(
|
let call_site = self.builder.build_call(
|
||||||
typed_func_ptr,
|
callable_func,
|
||||||
params
|
params
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
@ -10910,8 +10914,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
|||||||
let memory_index = MemoryIndex::from_u32(mem);
|
let memory_index = MemoryIndex::from_u32(mem);
|
||||||
let delta = self.state.pop1()?;
|
let delta = self.state.pop1()?;
|
||||||
let grow_fn_ptr = self.ctx.memory_grow(memory_index, self.intrinsics);
|
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(
|
let grow = self.builder.build_call(
|
||||||
grow_fn_ptr,
|
callable_func,
|
||||||
&[
|
&[
|
||||||
vmctx.as_basic_value_enum().into(),
|
vmctx.as_basic_value_enum().into(),
|
||||||
delta.into(),
|
delta.into(),
|
||||||
@ -10924,8 +10929,9 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
|||||||
Operator::MemorySize { mem, mem_byte: _ } => {
|
Operator::MemorySize { mem, mem_byte: _ } => {
|
||||||
let memory_index = MemoryIndex::from_u32(mem);
|
let memory_index = MemoryIndex::from_u32(mem);
|
||||||
let size_fn_ptr = self.ctx.memory_size(memory_index, self.intrinsics);
|
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(
|
let size = self.builder.build_call(
|
||||||
size_fn_ptr,
|
callable_func,
|
||||||
&[
|
&[
|
||||||
vmctx.as_basic_value_enum().into(),
|
vmctx.as_basic_value_enum().into(),
|
||||||
self.intrinsics.i32_ty.const_int(mem.into(), false).into(),
|
self.intrinsics.i32_ty.const_int(mem.into(), false).into(),
|
||||||
|
@ -1685,7 +1685,9 @@ pub fn tbaa_label<'ctx>(
|
|||||||
.get_global_metadata("wasmer_tbaa_root")
|
.get_global_metadata("wasmer_tbaa_root")
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
module.add_global_metadata("wasmer_tbaa_root", &context.metadata_node(&[]));
|
module
|
||||||
|
.add_global_metadata("wasmer_tbaa_root", &context.metadata_node(&[]))
|
||||||
|
.unwrap();
|
||||||
module.get_global_metadata("wasmer_tbaa_root")[0]
|
module.get_global_metadata("wasmer_tbaa_root")[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1696,10 +1698,12 @@ pub fn tbaa_label<'ctx>(
|
|||||||
.get_global_metadata(label.as_str())
|
.get_global_metadata(label.as_str())
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
module.add_global_metadata(
|
module
|
||||||
label.as_str(),
|
.add_global_metadata(
|
||||||
&context.metadata_node(&[type_label.into(), tbaa_root.into()]),
|
label.as_str(),
|
||||||
);
|
&context.metadata_node(&[type_label.into(), tbaa_root.into()]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
module.get_global_metadata(label.as_str())[0]
|
module.get_global_metadata(label.as_str())[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1714,18 +1718,20 @@ pub fn tbaa_label<'ctx>(
|
|||||||
.get_global_metadata(label.as_str())
|
.get_global_metadata(label.as_str())
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
module.add_global_metadata(
|
module
|
||||||
label.as_str(),
|
.add_global_metadata(
|
||||||
&context.metadata_node(&[
|
label.as_str(),
|
||||||
type_tbaa.into(),
|
&context.metadata_node(&[
|
||||||
type_tbaa.into(),
|
type_tbaa.into(),
|
||||||
intrinsics.i64_zero.into(),
|
type_tbaa.into(),
|
||||||
]),
|
intrinsics.i64_zero.into(),
|
||||||
);
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
module.get_global_metadata(label.as_str())[0]
|
module.get_global_metadata(label.as_str())[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attach the access tag to the instruction.
|
// Attach the access tag to the instruction.
|
||||||
let tbaa_kind = context.get_kind_id("tbaa");
|
let tbaa_kind = context.get_kind_id("tbaa");
|
||||||
instruction.set_metadata(type_tbaa, tbaa_kind);
|
instruction.set_metadata(type_tbaa, tbaa_kind).unwrap();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user