Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wasix-major-fixes-and-tweaks' in…
Browse files Browse the repository at this point in the history
…to wasix
  • Loading branch information
theduke committed Feb 16, 2023
2 parents 30dc848 + 81bae8f commit cbcae65
Show file tree
Hide file tree
Showing 74 changed files with 1,780 additions and 1,559 deletions.
100 changes: 80 additions & 20 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion lib/api/src/sys/mem_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ impl<'a, T: ValueType> WasmSlice<'a, T> {

/// Reads this `WasmSlice` into a `slice`.
#[inline]
pub fn read_to_slice(self, buf: &mut [MaybeUninit<u8>]) -> Result<usize, MemoryAccessError> {
pub fn read_to_slice<'b>(
self,
buf: &'b mut [MaybeUninit<u8>],
) -> Result<usize, MemoryAccessError> {
let len = self.len.try_into().expect("WasmSlice length overflow");
self.buffer.read_uninit(self.offset, buf)?;
Ok(len)
Expand Down
37 changes: 19 additions & 18 deletions lib/api/src/sys/store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::sys::tunables::BaseTunables;
use derivative::Derivative;
use std::fmt;
use std::{
fmt,
ops::{Deref, DerefMut},
};
#[cfg(feature = "compiler")]
use wasmer_compiler::{AsEngineRef, Engine, EngineBuilder, EngineRef, Tunables};
use wasmer_types::OnCalledAction;
Expand Down Expand Up @@ -220,13 +223,6 @@ impl AsEngineRef for Store {
}
}

#[cfg(feature = "compiler")]
impl AsEngineRef for &Store {
fn as_engine_ref(&self) -> EngineRef<'_> {
EngineRef::new(&self.engine)
}
}

#[cfg(feature = "compiler")]
impl AsEngineRef for StoreRef<'_> {
fn as_engine_ref(&self) -> EngineRef<'_> {
Expand Down Expand Up @@ -374,21 +370,26 @@ impl AsStoreMut for StoreMut<'_> {
}
}

impl<T: AsStoreRef> AsStoreRef for &'_ T {
impl<P> AsStoreRef for P
where
P: Deref,
P::Target: AsStoreRef,
{
fn as_store_ref(&self) -> StoreRef<'_> {
T::as_store_ref(*self)
(**self).as_store_ref()
}
}
impl<T: AsStoreRef> AsStoreRef for &'_ mut T {
fn as_store_ref(&self) -> StoreRef<'_> {
T::as_store_ref(*self)
}
}
impl<T: AsStoreMut> AsStoreMut for &'_ mut T {

impl<P> AsStoreMut for P
where
P: DerefMut,
P::Target: AsStoreMut,
{
fn as_store_mut(&mut self) -> StoreMut<'_> {
T::as_store_mut(*self)
(**self).as_store_mut()
}

fn objects_mut(&mut self) -> &mut StoreObjects {
T::objects_mut(*self)
(**self).objects_mut()
}
}
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 cbcae65

Please sign in to comment.