Skip to content

Commit

Permalink
Merge branch 'master' into feature/fix-singlepass-panic-no-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish authored Aug 19, 2019
2 parents 7b7f553 + 09e8430 commit 38b1e3d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 275 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://wasmer.io" target="_blank" rel="noopener noreferrer">
<img width="400" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/logo.png" alt="Wasmer logo">
<img width="300" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/logo.png" alt="Wasmer logo">
</a>
</p>

Expand Down
263 changes: 0 additions & 263 deletions lib/runtime-core/src/memory/atomic.rs

This file was deleted.

2 changes: 0 additions & 2 deletions lib/runtime-core/src/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ use std::{
rc::Rc,
};

pub use self::atomic::Atomic;
pub use self::dynamic::DynamicMemory;
pub use self::static_::{SharedStaticMemory, StaticMemory};
pub use self::view::{Atomically, MemoryView};

mod atomic;
mod dynamic;
pub mod ptr;
mod static_;
Expand Down
52 changes: 44 additions & 8 deletions lib/runtime-core/src/memory/view.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
use super::atomic::{Atomic, IntCast};
use crate::types::ValueType;

use std::sync::atomic::{
AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicU16, AtomicU32, AtomicU64, AtomicU8,
};
use std::{cell::Cell, marker::PhantomData, ops::Deref, slice};

pub trait Atomic {
type Output;
}
impl Atomic for i8 {
type Output = AtomicI8;
}
impl Atomic for i16 {
type Output = AtomicI16;
}
impl Atomic for i32 {
type Output = AtomicI32;
}
impl Atomic for i64 {
type Output = AtomicI64;
}
impl Atomic for u8 {
type Output = AtomicU8;
}
impl Atomic for u16 {
type Output = AtomicU16;
}
impl Atomic for u32 {
type Output = AtomicU32;
}
impl Atomic for u64 {
type Output = AtomicU64;
}
impl Atomic for f32 {
type Output = AtomicU32;
}
impl Atomic for f64 {
type Output = AtomicU64;
}

pub trait Atomicity {}
pub struct Atomically;
impl Atomicity for Atomically {}
Expand All @@ -28,10 +64,10 @@ where
}
}

impl<'a, T: IntCast> MemoryView<'a, T, NonAtomically> {
pub fn atomically(&self) -> MemoryView<'a, T, Atomically> {
impl<'a, T: Atomic> MemoryView<'a, T> {
pub fn atomically(&self) -> MemoryView<'a, T::Output, Atomically> {
MemoryView {
ptr: self.ptr,
ptr: self.ptr as *mut T::Output,
length: self.length,
_phantom: PhantomData,
}
Expand All @@ -45,9 +81,9 @@ impl<'a, T> Deref for MemoryView<'a, T, NonAtomically> {
}
}

impl<'a, T: IntCast> Deref for MemoryView<'a, T, Atomically> {
type Target = [Atomic<T>];
fn deref(&self) -> &[Atomic<T>] {
unsafe { slice::from_raw_parts(self.ptr as *const Atomic<T>, self.length) }
impl<'a, T> Deref for MemoryView<'a, T, Atomically> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe { slice::from_raw_parts(self.ptr as *const T, self.length) }
}
}
2 changes: 1 addition & 1 deletion lib/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub use wasmer_runtime_core::{compile_with, validate};
pub use wasmer_runtime_core::{func, imports};

pub mod memory {
pub use wasmer_runtime_core::memory::{Atomic, Atomically, Memory, MemoryView};
pub use wasmer_runtime_core::memory::{Atomically, Memory, MemoryView};
}

pub mod wasm {
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38b1e3d

Please sign in to comment.