Merge branch 'master' into feature/reference-types

This commit is contained in:
Mark McCaskey
2021-03-23 09:42:34 -07:00
97 changed files with 1111 additions and 178 deletions

View File

@@ -27,6 +27,7 @@ wat = { version = "1.0", optional = true }
thiserror = "1.0"
more-asserts = "0.2"
target-lexicon = { version = "0.11", default-features = false }
loupe = "0.1"
[target.'cfg(target_os = "windows")'.dependencies]
winapi = "0.3"

View File

@@ -3,6 +3,7 @@ use crate::import_object::LikeNamespace;
use crate::native::NativeFunc;
use crate::WasmTypeList;
use indexmap::IndexMap;
use loupe::MemoryUsage;
use std::fmt;
use std::iter::{ExactSizeIterator, FromIterator};
use std::sync::Arc;
@@ -61,7 +62,7 @@ pub enum ExportError {
/// the types of instances.
///
/// TODO: add examples of using exports
#[derive(Clone, Default)]
#[derive(Clone, Default, MemoryUsage)]
pub struct Exports {
map: Arc<IndexMap<String, Extern>>,
}

View File

@@ -10,6 +10,7 @@ pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, Witho
#[cfg(feature = "deprecated")]
pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv};
use loupe::MemoryUsage;
use std::cmp::max;
use std::ffi::c_void;
use std::fmt;
@@ -22,21 +23,22 @@ use wasmer_vm::{
};
/// A function defined in the Wasm module
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct WasmFunctionDefinition {
// Address of the trampoline to do the call.
#[loupe(skip)]
pub(crate) trampoline: VMTrampoline,
}
/// A function defined in the Host
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct HostFunctionDefinition {
/// If the host function has a custom environment attached
pub(crate) has_env: bool,
}
/// The inner helper
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub enum FunctionDefinition {
/// A function defined in the Wasm side
Wasm(WasmFunctionDefinition),
@@ -61,7 +63,7 @@ pub enum FunctionDefinition {
/// with native functions. Attempting to create a native `Function` with one will
/// result in a panic.
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct Function {
pub(crate) store: Store,
pub(crate) definition: FunctionDefinition,

View File

@@ -5,6 +5,7 @@ use crate::types::Val;
use crate::GlobalType;
use crate::Mutability;
use crate::RuntimeError;
use loupe::MemoryUsage;
use std::fmt;
use std::sync::Arc;
use wasmer_engine::{Export, ExportGlobal};
@@ -16,7 +17,7 @@ use wasmer_vm::{Global as RuntimeGlobal, VMExportGlobal};
/// It consists of an individual value and a flag indicating whether it is mutable.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#global-instances>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Global {
store: Store,
global: Arc<RuntimeGlobal>,

View File

@@ -2,6 +2,7 @@ use crate::exports::{ExportError, Exportable};
use crate::externals::Extern;
use crate::store::Store;
use crate::{MemoryType, MemoryView};
use loupe::MemoryUsage;
use std::convert::TryInto;
use std::slice;
use std::sync::Arc;
@@ -23,7 +24,7 @@ use wasmer_vm::{Memory as RuntimeMemory, MemoryError, VMExportMemory};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
pub struct Memory {
store: Store,
memory: Arc<dyn RuntimeMemory>,

View File

@@ -16,6 +16,7 @@ pub use self::table::Table;
use crate::exports::{ExportError, Exportable};
use crate::store::{Store, StoreObject};
use crate::ExternType;
use loupe::MemoryUsage;
use std::fmt;
use wasmer_engine::Export;
@@ -23,7 +24,7 @@ use wasmer_engine::Export;
/// can be imported or exported.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub enum Extern {
/// A external [`Function`].
Function(Function),

View File

@@ -4,6 +4,7 @@ use crate::store::Store;
use crate::types::{Val, ValFuncRef};
use crate::RuntimeError;
use crate::TableType;
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_engine::{Export, ExportTable};
use wasmer_vm::{Table as RuntimeTable, TableReference, VMExportTable};
@@ -17,7 +18,7 @@ use wasmer_vm::{Table as RuntimeTable, TableReference, VMExportTable};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Table {
store: Store,
table: Arc<dyn RuntimeTable>,

View File

@@ -3,6 +3,7 @@ use crate::externals::Extern;
use crate::module::Module;
use crate::store::Store;
use crate::{HostEnvInitError, LinkError, RuntimeError};
use loupe::MemoryUsage;
use std::fmt;
use std::sync::{Arc, Mutex};
use thiserror::Error;
@@ -17,7 +18,7 @@ use wasmer_vm::{InstanceHandle, VMContext};
/// interacting with WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Instance {
handle: Arc<Mutex<InstanceHandle>>,
module: Module,

View File

@@ -1,6 +1,7 @@
use crate::store::Store;
use crate::types::{ExportType, ImportType};
use crate::InstantiationError;
use loupe::MemoryUsage;
use std::fmt;
use std::io;
use std::path::Path;
@@ -30,7 +31,7 @@ pub enum IoCompileError {
///
/// Cloning a module is cheap: it does a shallow copy of the compiled
/// contents rather than a deep copy.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Module {
store: Store,
artifact: Arc<dyn Artifact>,

View File

@@ -1,4 +1,5 @@
use crate::tunables::BaseTunables;
use loupe::MemoryUsage;
use std::fmt;
use std::sync::Arc;
#[cfg(all(feature = "compiler", feature = "engine"))]
@@ -15,7 +16,7 @@ use wasmer_engine::{Engine, Tunables};
/// [`Tunables`] (that are used to create the memories, tables and globals).
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Store {
engine: Arc<dyn Engine + Send + Sync>,
tunables: Arc<dyn Tunables + Send + Sync>,

View File

@@ -1,4 +1,5 @@
use crate::{MemoryType, Pages, TableType};
use loupe::MemoryUsage;
use std::cmp::min;
use std::ptr::NonNull;
use std::sync::Arc;
@@ -19,7 +20,7 @@ use wasmer_vm::{
/// implementation or use composition to wrap your Tunables around
/// this one. The later approach is demonstrated in the
/// tunables-limit-memory example.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct BaseTunables {
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
pub static_memory_bound: Pages,