Skip to content

Commit

Permalink
Merge pull request #3663 from wasmerio/dash-fixes-and-pthreads
Browse files Browse the repository at this point in the history
Dash fixes and pthreads
  • Loading branch information
john-sharratt authored Mar 17, 2023
2 parents 1fe1e51 + bdc41ec commit fbd6fc4
Show file tree
Hide file tree
Showing 117 changed files with 3,266 additions and 721 deletions.
150 changes: 150 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions lib/api/src/function_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ pub struct FunctionEnvMut<'a, T: 'a> {
pub(crate) func_env: FunctionEnv<T>,
}

impl<'a, T> Debug for FunctionEnvMut<'a, T> {
impl<'a, T> Debug for FunctionEnvMut<'a, T>
where
T: Send + Debug + 'static,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "env_mut")
self.func_env.as_ref(&self.store_mut).fmt(f)
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/api/src/js/externals/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ impl Global {
let ty = self.handle.ty;
let raw = match ty.ty {
Type::I32 => RawValue {
i32: value.as_f64().unwrap() as _,
i32: value.as_f64().unwrap_or_default() as _,
},
Type::I64 => RawValue {
i64: value.as_f64().unwrap() as _,
i64: value.as_f64().unwrap_or_default() as _,
},
Type::F32 => RawValue {
f32: value.as_f64().unwrap() as _,
f32: value.as_f64().unwrap_or_default() as _,
},
Type::F64 => RawValue {
f64: value.as_f64().unwrap(),
f64: value.as_f64().unwrap_or_default(),
},
Type::V128 => RawValue {
u128: value.as_f64().unwrap() as _,
u128: value.as_f64().unwrap_or_default() as _,
},
Type::FuncRef => {
unimplemented!();
Expand Down
6 changes: 6 additions & 0 deletions lib/api/src/js/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub struct Module {
unsafe impl Send for Module {}
unsafe impl Sync for Module {}

impl From<Module> for JsValue {
fn from(val: Module) -> Self {
Self::from(val.module)
}
}

impl Module {
pub(crate) fn from_binary(
_engine: &impl AsEngineRef,
Expand Down
13 changes: 10 additions & 3 deletions lib/api/src/js/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ impl VMMemory {
pub fn duplicate(&self) -> Result<VMMemory, wasmer_types::MemoryError> {
let new_memory = crate::js::externals::memory::Memory::js_memory_from_type(&self.ty)?;

#[cfg(feature = "tracing")]
trace!("memory copy started");

let src = crate::js::externals::memory_view::MemoryView::new_raw(&self.memory);
let amount = src.data_size() as usize;

#[cfg(feature = "tracing")]
trace!(%amount, "memory copy started");

let mut dst = crate::js::externals::memory_view::MemoryView::new_raw(&new_memory);
let dst_size = dst.data_size() as usize;

Expand Down Expand Up @@ -111,6 +112,12 @@ impl From<VMMemory> for JsValue {
}
}

impl From<VMMemory> for (JsValue, MemoryType) {
fn from(value: VMMemory) -> Self {
(JsValue::from(value.memory), value.ty)
}
}

/// The shared memory is the same as the normal memory
pub type VMSharedMemory = VMMemory;

Expand Down
7 changes: 7 additions & 0 deletions lib/api/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,10 @@ impl fmt::Debug for Module {
.finish()
}
}

#[cfg(feature = "js")]
impl From<Module> for wasm_bindgen::JsValue {
fn from(value: Module) -> Self {
wasm_bindgen::JsValue::from(value.0)
}
}
12 changes: 8 additions & 4 deletions lib/api/src/sys/mem_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ where
.ok_or(MemoryAccessError::Overflow)?;
if end > slice.buffer.0.len as u64 {
#[cfg(feature = "tracing")]
warn!(
tracing::warn!(
"attempted to read ({} bytes) beyond the bounds of the memory view ({} > {})",
total_len, end, slice.buffer.0.len
total_len,
end,
slice.buffer.0.len
);
return Err(MemoryAccessError::HeapOutOfBounds);
}
Expand Down Expand Up @@ -47,9 +49,11 @@ where
.ok_or(MemoryAccessError::Overflow)?;
if end > ptr.buffer.0.len as u64 {
#[cfg(feature = "tracing")]
warn!(
tracing::warn!(
"attempted to read ({} bytes) beyond the bounds of the memory view ({} > {})",
total_len, end, ptr.buffer.0.len
total_len,
end,
ptr.buffer.0.len
);
return Err(MemoryAccessError::HeapOutOfBounds);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ default = [
"wasmer-artifact-create",
"static-artifact-create",
"webc_runner",
"tracing"
"tracing",
]
cache = ["wasmer-cache"]
cache-blake3-pure = ["wasmer-cache/blake3-pure"]
Expand Down
Loading

0 comments on commit fbd6fc4

Please sign in to comment.