Skip to content

Commit

Permalink
Remove virtual memory support (#408)
Browse files Browse the repository at this point in the history
* remove support for virtual memory in wasmi_core and wasmi

* remove virtual memory support for GitHub Actions CI

* rename buffer_vec.rs -> byte_buffer.rs

* use windows-latest in CI instead of windows-2019

We were required to use windows-2019 because of the virtual memory feature which is removed now.
  • Loading branch information
Robbepop authored Aug 14, 2022
1 parent baab359 commit 10f8780
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 251 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,9 @@ jobs:
matrix:
# windows-latest was pinned to windows-2019
# because of https://github.com/paritytech/wasmi/runs/5021520759
os: [ubuntu-latest, windows-2019, macos-latest]
include:
# Include a new variable `rustc-args` with `-- --test-threads 1`
# for windows-2019 to be used with virtual_memory crate feature
# enabled while testing.
- os: windows-2019
test-args: "--test-threads 1"
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Configure Pagefile for Windows
if: matrix.os == 'windows-2019'
uses: al-cheb/[email protected]
with:
minimum-size: 6GB
maximum-size: 32GB
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
Expand All @@ -83,10 +71,9 @@ jobs:
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: '--cfg debug_assertions'
TEST_FLAGS: ${{ matrix.test-args }}
with:
command: test
args: --workspace --release --all-features -- $TEST_FLAGS
args: --workspace --release --all-features

fmt:
name: Formatting
Expand Down
11 changes: 0 additions & 11 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ memory_units = "0.4.0"
libm = "0.2.1"
num-rational = { version = "0.4", default-features = false, features = ["num-bigint"] }
num-traits = { version = "0.2.8", default-features = false }
region = { version = "3.0", optional = true }
downcast-rs = { version = "1.2", default-features = false }

[dev-dependencies]
Expand All @@ -30,13 +29,3 @@ std = [
"num-traits/std",
"downcast-rs/std",
]
# Enables OS supported virtual memory.
#
# Note
#
# - This feature is only supported on 64-bit platforms.
# For 32-bit platforms the linear memory will fallback to using the Vec
# based implementation.
# - The default is to fall back is an inefficient vector based implementation.
# - By nature this feature requires `region` and the Rust standard library.
virtual_memory = ["region", "std"]
6 changes: 0 additions & 6 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ mod trap;
mod untyped;
mod value;

#[cfg(feature = "virtual_memory")]
mod vmem;

#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std as alloc;

#[cfg(feature = "virtual_memory")]
pub use self::vmem::{VirtualMemory, VirtualMemoryError};

/// WebAssembly-specific sizes and units.
pub mod memory_units {
pub use memory_units::{size_of, wasm32::*, ByteSize, Bytes, RoundUpTo};
Expand Down
102 changes: 0 additions & 102 deletions core/src/vmem.rs

This file was deleted.

10 changes: 0 additions & 10 deletions wasmi_v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ std = [
"wasmparser/std",
"spin/std",
]
# Enables OS supported virtual memory.
#
# Note
#
# - This feature is only supported on 64-bit platforms.
# For 32-bit platforms the linear memory will fallback to using the Vec
# based implementation.
# - The default is to fall back is an inefficient vector based implementation.
# - By nature this feature requires `region` and the Rust standard library.
virtual_memory = ["wasmi_core/virtual_memory", "std"]

[[bench]]
name = "benches"
Expand Down
77 changes: 0 additions & 77 deletions wasmi_v1/src/memory/buffer_vmem.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
use super::{max_memory_len, MemoryError};
use alloc::{vec, vec::Vec};
use core::{fmt, fmt::Display};

/// Dummy error for fallible `Vec`-based virtual memory operations.
#[derive(Debug)]
pub struct VirtualMemoryError {}

impl Display for VirtualMemoryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "encountered failure while operating with virtual memory")
}
}

/// A `Vec`-based byte buffer implementation.
///
Expand Down
23 changes: 4 additions & 19 deletions wasmi_v1/src/memory/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#[cfg(all(feature = "virtual_memory", target_pointer_width = "64"))]
#[path = "buffer_vmem.rs"]
mod byte_buffer;

#[cfg(not(all(feature = "virtual_memory", target_pointer_width = "64")))]
#[path = "buffer_vec.rs"]
mod byte_buffer;

use self::byte_buffer::{ByteBuffer, VirtualMemoryError};
use self::byte_buffer::ByteBuffer;
use super::{AsContext, AsContextMut, Index, StoreContext, StoreContextMut, Stored};
use core::{fmt, fmt::Display};
use wasmi_core::memory_units::{Bytes, Pages};
Expand Down Expand Up @@ -38,8 +32,6 @@ pub enum MemoryError {
OutOfBoundsGrowth,
/// Tried to access linear memory out of bounds.
OutOfBoundsAccess,
/// A generic virtual memory error.
Vmem(byte_buffer::VirtualMemoryError),
/// Occurs when a memory type does not satisfy the constraints of another.
UnsatisfyingMemoryType {
/// The unsatisfying [`MemoryType`].
Expand All @@ -52,16 +44,15 @@ pub enum MemoryError {
impl Display for MemoryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
MemoryError::OutOfBoundsAllocation => {
Self::OutOfBoundsAllocation => {
write!(f, "tried to allocate too much virtual memory")
}
MemoryError::OutOfBoundsGrowth => {
Self::OutOfBoundsGrowth => {
write!(f, "tried to grow virtual memory out of bounds")
}
MemoryError::OutOfBoundsAccess => {
Self::OutOfBoundsAccess => {
write!(f, "tried to access virtual memory out of bounds")
}
MemoryError::Vmem(error) => Display::fmt(error, f),
Self::UnsatisfyingMemoryType {
unsatisfying,
required,
Expand All @@ -76,12 +67,6 @@ impl Display for MemoryError {
}
}

impl From<VirtualMemoryError> for MemoryError {
fn from(error: VirtualMemoryError) -> Self {
Self::Vmem(error)
}
}

/// Returns the maximum virtual memory buffer length in bytes.
fn max_memory_len() -> usize {
i32::MAX as u32 as usize
Expand Down

0 comments on commit 10f8780

Please sign in to comment.