mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
merge master
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
use crate::mmap::Mmap;
|
||||
use crate::vmcontext::VMMemoryDefinition;
|
||||
use loupe::MemoryUsage;
|
||||
use more_asserts::assert_ge;
|
||||
#[cfg(feature = "enable-rkyv")]
|
||||
use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
|
||||
@@ -63,7 +64,7 @@ pub enum MemoryError {
|
||||
}
|
||||
|
||||
/// Implementation styles for WebAssembly linear memory.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||
#[cfg_attr(
|
||||
feature = "enable-rkyv",
|
||||
derive(RkyvSerialize, RkyvDeserialize, Archive)
|
||||
@@ -102,7 +103,7 @@ impl MemoryStyle {
|
||||
}
|
||||
|
||||
/// Trait for implementing Wasm Memory used by Wasmer.
|
||||
pub trait Memory: fmt::Debug + Send + Sync {
|
||||
pub trait Memory: fmt::Debug + Send + Sync + MemoryUsage {
|
||||
/// Returns the memory type for this memory.
|
||||
fn ty(&self) -> &MemoryType;
|
||||
|
||||
@@ -122,7 +123,7 @@ pub trait Memory: fmt::Debug + Send + Sync {
|
||||
}
|
||||
|
||||
/// A linear memory instance.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
pub struct LinearMemory {
|
||||
// The underlying allocation.
|
||||
mmap: Mutex<WasmMmap>,
|
||||
@@ -150,7 +151,7 @@ pub struct LinearMemory {
|
||||
|
||||
/// A type to help manage who is responsible for the backing memory of them
|
||||
/// `VMMemoryDefinition`.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
enum VMMemoryDefinitionOwnership {
|
||||
/// The `VMMemoryDefinition` is owned by the `Instance` and we should use
|
||||
/// its memory. This is how a local memory that's exported should be stored.
|
||||
@@ -173,7 +174,7 @@ unsafe impl Send for LinearMemory {}
|
||||
/// This is correct because all internal mutability is protected by a mutex.
|
||||
unsafe impl Sync for LinearMemory {}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
struct WasmMmap {
|
||||
// Our OS allocation of mmap'd memory.
|
||||
alloc: Mmap,
|
||||
|
||||
Reference in New Issue
Block a user