Skip to content

Commit

Permalink
Merge branch 'master' into fix_capi_memory_leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb authored Feb 15, 2023
2 parents c0f1bfa + b1a94df commit 0305668
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 64 deletions.
38 changes: 30 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion lib/compiler-llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rayon = "1.5"

[dependencies.inkwell]
package = "inkwell"
version = "=0.1.0-beta.4"
version = "0.1.1"
default-features = false
features = ["llvm12-0", "target-x86", "target-aarch64"]

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-llvm/src/abi/aarch64_systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Abi for Aarch64SystemV {
.collect::<Result<_, _>>()?;

let sret = context.struct_type(&basic_types, false);
let sret_ptr = sret.ptr_type(AddressSpace::Generic);
let sret_ptr = sret.ptr_type(AddressSpace::default());

let param_types =
std::iter::once(Ok(sret_ptr.as_basic_type_enum())).chain(param_types);
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-llvm/src/abi/x86_64_systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Abi for X86_64SystemV {
.collect::<Result<_, _>>()?;

let sret = context.struct_type(&basic_types, false);
let sret_ptr = sret.ptr_type(AddressSpace::Generic);
let sret_ptr = sret.ptr_type(AddressSpace::default());

let param_types =
std::iter::once(Ok(sret_ptr.as_basic_type_enum())).chain(param_types);
Expand Down
16 changes: 8 additions & 8 deletions lib/compiler-llvm/src/trampoline/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ impl FuncTrampoline {
.func_type_to_llvm(&self.ctx, &intrinsics, None, ty)?;
let trampoline_ty = intrinsics.void_ty.fn_type(
&[
intrinsics.ctx_ptr_ty.into(), // vmctx ptr
callee_ty.ptr_type(AddressSpace::Generic).into(), // callee function address
intrinsics.i128_ptr_ty.into(), // in/out values ptr
intrinsics.ctx_ptr_ty.into(), // vmctx ptr
callee_ty.ptr_type(AddressSpace::default()).into(), // callee function address
intrinsics.i128_ptr_ty.into(), // in/out values ptr
],
false,
);

let trampoline_func = module.add_function(name, trampoline_ty, Some(Linkage::External));
trampoline_func
.as_global_value()
.set_section(FUNCTION_SECTION);
.set_section(Some(FUNCTION_SECTION));
trampoline_func
.as_global_value()
.set_linkage(Linkage::DLLExport);
Expand Down Expand Up @@ -189,7 +189,7 @@ impl FuncTrampoline {
}
trampoline_func
.as_global_value()
.set_section(FUNCTION_SECTION);
.set_section(Some(FUNCTION_SECTION));
trampoline_func
.as_global_value()
.set_linkage(Linkage::DLLExport);
Expand Down Expand Up @@ -359,7 +359,7 @@ impl FuncTrampoline {
)
};
let ptr =
builder.build_pointer_cast(ptr, v.get_type().ptr_type(AddressSpace::Generic), "");
builder.build_pointer_cast(ptr, v.get_type().ptr_type(AddressSpace::default()), "");
builder.build_store(ptr, *v);
if v.get_type() == intrinsics.i128_ty.as_basic_type_enum() {
idx += 1;
Expand Down Expand Up @@ -424,12 +424,12 @@ impl FuncTrampoline {
],
false,
)
.ptr_type(AddressSpace::Generic);
.ptr_type(AddressSpace::default());
let vmctx = self.abi.get_vmctx_ptr_param(&trampoline_func);
let callee = builder
.build_load(
builder
.build_bitcast(vmctx, callee_ty.ptr_type(AddressSpace::Generic), "")
.build_bitcast(vmctx, callee_ty.ptr_type(AddressSpace::default()), "")
.into_pointer_value(),
"",
)
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler-llvm/src/translator/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl FuncTranslator {

func.add_attribute(AttributeLoc::Function, intrinsics.stack_probe);
func.set_personality_function(intrinsics.personality);
func.as_global_value().set_section(FUNCTION_SECTION);
func.as_global_value().set_section(Some(FUNCTION_SECTION));
func.set_linkage(Linkage::DLLExport);
func.as_global_value()
.set_dll_storage_class(DLLStorageClass::Export);
Expand Down Expand Up @@ -2334,7 +2334,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
// element type.
let casted_table_base = self.builder.build_pointer_cast(
table_base,
self.intrinsics.funcref_ty.ptr_type(AddressSpace::Generic),
self.intrinsics.funcref_ty.ptr_type(AddressSpace::default()),
"casted_table_base",
);

Expand Down Expand Up @@ -2503,7 +2503,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {

let typed_func_ptr = self.builder.build_pointer_cast(
func_ptr,
llvm_func_type.ptr_type(AddressSpace::Generic),
llvm_func_type.ptr_type(AddressSpace::default()),
"typed_func_ptr",
);

Expand Down
Loading

0 comments on commit 0305668

Please sign in to comment.