mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 22:28:21 +00:00
feat: Start implementing loupe::MemoryUsage on wasmer::Module.
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1162,6 +1162,7 @@ checksum = "f0700ebea6c2a63815aa6f376f1c6dac93223d7b11c4728a7f71ff951a6eca67"
|
||||
dependencies = [
|
||||
"loupe-derive",
|
||||
"rustversion",
|
||||
"indexmap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::store::Store;
|
||||
use crate::types::{ExportType, ImportType};
|
||||
use crate::InstantiationError;
|
||||
use loupe_derive::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>,
|
||||
|
||||
@@ -5,7 +5,7 @@ use inkwell::targets::{
|
||||
};
|
||||
pub use inkwell::OptimizationLevel as LLVMOptLevel;
|
||||
use itertools::Itertools;
|
||||
use loupe::MemoryUsage;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
use target_lexicon::Architecture;
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
|
||||
use crate::lib::std::vec::Vec;
|
||||
use crate::sourceloc::SourceLoc;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Single source location to generated address mapping.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct InstructionAddressMap {
|
||||
/// Original source location.
|
||||
pub srcloc: SourceLoc,
|
||||
@@ -22,7 +23,7 @@ pub struct InstructionAddressMap {
|
||||
|
||||
/// Function and its instructions addresses mappings.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
|
||||
pub struct FunctionAddressMap {
|
||||
/// Instructions maps.
|
||||
/// The array is sorted by the InstructionAddressMap::code_offset field.
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::lib::std::vec::Vec;
|
||||
use crate::section::{CustomSection, SectionIndex};
|
||||
use crate::trap::TrapInformation;
|
||||
use crate::{CompiledFunctionUnwindInfo, FunctionAddressMap, JumpTableOffsets, Relocation};
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
@@ -22,7 +23,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex};
|
||||
/// This structure is only used for reconstructing
|
||||
/// the frame information after a `Trap`.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
|
||||
pub struct CompiledFunctionFrameInfo {
|
||||
/// The traps (in the function body).
|
||||
///
|
||||
@@ -35,7 +36,7 @@ pub struct CompiledFunctionFrameInfo {
|
||||
|
||||
/// The function body.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct FunctionBody {
|
||||
/// The function body bytes.
|
||||
#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))]
|
||||
@@ -79,7 +80,7 @@ pub type CustomSections = PrimaryMap<SectionIndex, CustomSection>;
|
||||
/// In the future this structure may also hold other information useful
|
||||
/// for debugging.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, MemoryUsage)]
|
||||
pub struct Dwarf {
|
||||
/// The section index in the [`Compilation`] that corresponds to the exception frames.
|
||||
/// [Learn
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
//! [Learn more](https://en.wikipedia.org/wiki/Branch_table).
|
||||
|
||||
use super::CodeOffset;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_types::entity::{entity_impl, SecondaryMap};
|
||||
@@ -14,7 +15,7 @@ use wasmer_types::entity::{entity_impl, SecondaryMap};
|
||||
/// `JumpTable`s are used for indirect branching and are specialized for dense,
|
||||
/// 0-based jump offsets.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, MemoryUsage)]
|
||||
pub struct JumpTable(u32);
|
||||
|
||||
entity_impl!(JumpTable, "jt");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::lib::std::sync::Arc;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
@@ -10,7 +11,7 @@ use wasmer_vm::{MemoryStyle, ModuleInfo, TableStyle};
|
||||
/// This differs from [`ModuleInfo`] because it have extra info only
|
||||
/// possible after translation (such as the features used for compiling,
|
||||
/// or the `MemoryStyle` and `TableStyle`).
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||
pub struct CompileModuleInfo {
|
||||
/// The features used for compiling the module
|
||||
|
||||
@@ -13,6 +13,7 @@ use crate::lib::std::fmt;
|
||||
use crate::lib::std::vec::Vec;
|
||||
use crate::section::SectionIndex;
|
||||
use crate::{Addend, CodeOffset, JumpTable};
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
@@ -21,7 +22,7 @@ use wasmer_vm::libcalls::LibCall;
|
||||
|
||||
/// Relocation kinds for every ISA.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, MemoryUsage)]
|
||||
pub enum RelocationKind {
|
||||
/// absolute 4-byte
|
||||
Abs4,
|
||||
@@ -79,7 +80,7 @@ impl fmt::Display for RelocationKind {
|
||||
|
||||
/// A record of a relocation to perform.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct Relocation {
|
||||
/// The relocation kind.
|
||||
pub kind: RelocationKind,
|
||||
@@ -93,7 +94,7 @@ pub struct Relocation {
|
||||
|
||||
/// Destination function. Can be either user function or some special one, like `memory.grow`.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub enum RelocationTarget {
|
||||
/// A relocation to a function defined locally in the wasm (not an imported one).
|
||||
LocalFunc(LocalFunctionIndex),
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
use crate::lib::std::vec::Vec;
|
||||
use crate::Relocation;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_types::entity::entity_impl;
|
||||
|
||||
/// Index type of a Section defined inside a WebAssembly `Compilation`.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)]
|
||||
pub struct SectionIndex(u32);
|
||||
|
||||
entity_impl!(SectionIndex);
|
||||
@@ -22,7 +23,7 @@ entity_impl!(SectionIndex);
|
||||
///
|
||||
/// Determines how a custom section may be used.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub enum CustomSectionProtection {
|
||||
/// A custom section with read permission.
|
||||
Read,
|
||||
@@ -36,7 +37,7 @@ pub enum CustomSectionProtection {
|
||||
/// This is used so compilers can store arbitrary information
|
||||
/// in the emitted module.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct CustomSection {
|
||||
/// Memory protection that applies to this section.
|
||||
pub protection: CustomSectionProtection,
|
||||
@@ -55,7 +56,7 @@ pub struct CustomSection {
|
||||
|
||||
/// The bytes in the section.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
|
||||
pub struct SectionBody(#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))] Vec<u8>);
|
||||
|
||||
impl SectionBody {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//! and tracing errors.
|
||||
|
||||
use crate::lib::std::fmt;
|
||||
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize};
|
||||
serde(transparent)
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct SourceLoc(u32);
|
||||
|
||||
impl SourceLoc {
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::error::ParseCpuFeatureError;
|
||||
use crate::lib::std::str::FromStr;
|
||||
use crate::lib::std::string::{String, ToString};
|
||||
use enumset::{EnumSet, EnumSetType};
|
||||
use loupe::MemoryUsage;
|
||||
use loupe_derive::MemoryUsage;
|
||||
pub use target_lexicon::{
|
||||
Architecture, BinaryFormat, CallingConvention, Endianness, OperatingSystem, PointerWidth,
|
||||
Triple,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use crate::CodeOffset;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_vm::TrapCode;
|
||||
|
||||
/// Information about trap.
|
||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, MemoryUsage)]
|
||||
pub struct TrapInformation {
|
||||
/// The offset of the trapping instruction in native code. It is relative to the beginning of the function.
|
||||
pub code_offset: CodeOffset,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//!
|
||||
//! [Learn more](https://en.wikipedia.org/wiki/Call_stack).
|
||||
use crate::lib::std::vec::Vec;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize};
|
||||
///
|
||||
/// [unwind info]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||
pub enum CompiledFunctionUnwindInfo {
|
||||
/// Windows UNWIND_INFO.
|
||||
WindowsX64(Vec<u8>),
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::link::link_module;
|
||||
#[cfg(feature = "compiler")]
|
||||
use crate::serialize::SerializableCompilation;
|
||||
use crate::serialize::SerializableModule;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use wasmer_compiler::{CompileError, Features, Triple};
|
||||
#[cfg(feature = "compiler")]
|
||||
@@ -26,9 +27,11 @@ use wasmer_vm::{
|
||||
};
|
||||
|
||||
/// A compiled wasm module, ready to be instantiated.
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct JITArtifact {
|
||||
serializable: SerializableModule,
|
||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||
#[memoryusage(ignore)]
|
||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_compiler::{
|
||||
CompileModuleInfo, CustomSection, Dwarf, FunctionBody, JumpTableOffsets, Relocation,
|
||||
@@ -18,7 +19,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, Sign
|
||||
// }
|
||||
|
||||
/// The compilation related data for a serialized modules
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, MemoryUsage)]
|
||||
pub struct SerializableCompilation {
|
||||
pub function_bodies: PrimaryMap<LocalFunctionIndex, FunctionBody>,
|
||||
pub function_relocations: PrimaryMap<LocalFunctionIndex, Vec<Relocation>>,
|
||||
@@ -37,7 +38,7 @@ pub struct SerializableCompilation {
|
||||
|
||||
/// Serializable struct that is able to serialize from and to
|
||||
/// a `JITArtifactInfo`.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, MemoryUsage)]
|
||||
pub struct SerializableModule {
|
||||
pub compilation: SerializableCompilation,
|
||||
pub compile_info: CompileModuleInfo,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use crate::engine::{NativeEngine, NativeEngineInner};
|
||||
use crate::serialize::ModuleMetadata;
|
||||
use libloading::{Library, Symbol as LibrarySymbol};
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
@@ -37,10 +38,12 @@ use wasmer_vm::{
|
||||
};
|
||||
|
||||
/// A compiled wasm module, ready to be instantiated.
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct NativeArtifact {
|
||||
sharedobject_path: PathBuf,
|
||||
metadata: ModuleMetadata,
|
||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||
#[memoryusage(ignore)]
|
||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::NativeArtifact;
|
||||
use libloading::Library;
|
||||
use loupe::MemoryUsage;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
||||
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
||||
|
||||
/// Serializable struct that represents the compiled metadata.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
|
||||
pub struct ModuleMetadata {
|
||||
pub compile_info: CompileModuleInfo,
|
||||
pub prefix: String,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
use crate::engine::{ObjectFileEngine, ObjectFileEngineInner};
|
||||
use crate::serialize::{ModuleMetadata, ModuleMetadataSymbolRegistry};
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::collections::BTreeMap;
|
||||
use std::error::Error;
|
||||
use std::mem;
|
||||
@@ -30,10 +31,12 @@ use wasmer_vm::{
|
||||
};
|
||||
|
||||
/// A compiled wasm module, ready to be instantiated.
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct ObjectFileArtifact {
|
||||
metadata: ModuleMetadata,
|
||||
module_bytes: Vec<u8>,
|
||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||
#[memoryusage(ignore)]
|
||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
||||
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
||||
|
||||
/// Serializable struct that represents the compiled metadata.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
|
||||
pub struct ModuleMetadata {
|
||||
pub compile_info: CompileModuleInfo,
|
||||
pub prefix: String,
|
||||
@@ -13,6 +14,7 @@ pub struct ModuleMetadata {
|
||||
pub function_body_lengths: PrimaryMap<LocalFunctionIndex, u64>,
|
||||
}
|
||||
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct ModuleMetadataSymbolRegistry {
|
||||
pub prefix: String,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
resolve_imports, InstantiationError, Resolver, RuntimeError, SerializeError, Tunables,
|
||||
};
|
||||
use loupe::MemoryUsage;
|
||||
use std::any::Any;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
@@ -22,7 +23,7 @@ use wasmer_vm::{
|
||||
/// The `Artifact` contains the compiled data for a given
|
||||
/// module as well as extra information needed to run the
|
||||
/// module at runtime, such as [`ModuleInfo`] and [`Features`].
|
||||
pub trait Artifact: Send + Sync + Upcastable {
|
||||
pub trait Artifact: Send + Sync + Upcastable + MemoryUsage {
|
||||
/// Return a reference-counted pointer to the module
|
||||
fn module(&self) -> Arc<ModuleInfo>;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::de::{Deserializer, Visitor};
|
||||
use serde::ser::Serializer;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -5,7 +6,7 @@ use std::fmt;
|
||||
use wasmer_compiler::CompiledFunctionFrameInfo;
|
||||
|
||||
/// This is the unserialized verison of `CompiledFunctionFrameInfo`.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, MemoryUsage)]
|
||||
#[serde(transparent)]
|
||||
#[repr(transparent)]
|
||||
pub struct UnprocessedFunctionFrameInfo {
|
||||
@@ -44,7 +45,7 @@ impl UnprocessedFunctionFrameInfo {
|
||||
/// of compiling at the same time that emiting the JIT.
|
||||
/// In that case, we don't need to deserialize/process anything
|
||||
/// as the data is already in memory.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, MemoryUsage)]
|
||||
pub enum SerializableFunctionFrameInfo {
|
||||
/// The unprocessed frame info (binary)
|
||||
Unprocessed(UnprocessedFunctionFrameInfo),
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
//! FRAME_INFO.register(module, compiled_functions);
|
||||
//! ```
|
||||
use crate::serialize::SerializableFunctionFrameInfo;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::cmp;
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
@@ -44,6 +45,7 @@ pub struct GlobalFrameInfo {
|
||||
|
||||
/// An RAII structure used to unregister a module's frame information when the
|
||||
/// module is destroyed.
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct GlobalFrameInfoRegistration {
|
||||
/// The key that will be removed from the global `ranges` map when this is
|
||||
/// dropped.
|
||||
|
||||
@@ -21,7 +21,7 @@ more-asserts = "0.2"
|
||||
cfg-if = "0.1"
|
||||
backtrace = "0.3"
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
loupe = "0.1"
|
||||
loupe = { version = "0.1", features = ["enable-indexmap"] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use crate::vmcontext::VMGlobalDefinition;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::Mutex;
|
||||
use thiserror::Error;
|
||||
use wasmer_types::{GlobalType, Mutability, Type, Value};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
/// A Global instance
|
||||
pub struct Global {
|
||||
ty: GlobalType,
|
||||
|
||||
@@ -27,6 +27,7 @@ use crate::vmcontext::{
|
||||
};
|
||||
use crate::{FunctionBodyPtr, ModuleInfo, VMOffsets};
|
||||
use crate::{VMExportFunction, VMExportGlobal, VMExportMemory, VMExportTable};
|
||||
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||
use memoffset::offset_of;
|
||||
use more_asserts::assert_lt;
|
||||
use std::any::Any;
|
||||
@@ -34,9 +35,10 @@ use std::cell::{Cell, RefCell};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::ffi;
|
||||
use std::fmt;
|
||||
use std::ptr::NonNull;
|
||||
use std::mem;
|
||||
use std::ptr::{self, NonNull};
|
||||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
use std::{mem, ptr, slice};
|
||||
use wasmer_types::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
|
||||
use wasmer_types::{
|
||||
DataIndex, DataInitializer, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, GlobalInit,
|
||||
@@ -122,6 +124,7 @@ pub enum ImportFunctionEnv {
|
||||
/// The function environment. This is not always the user-supplied
|
||||
/// env.
|
||||
env: *mut ffi::c_void,
|
||||
|
||||
/// A clone function for duplicating the env.
|
||||
clone: fn(*mut ffi::c_void) -> *mut ffi::c_void,
|
||||
/// This field is not always present. When it is present, it
|
||||
@@ -187,6 +190,12 @@ impl Drop for ImportFunctionEnv {
|
||||
}
|
||||
}
|
||||
|
||||
impl MemoryUsage for ImportFunctionEnv {
|
||||
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Instance {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.debug_struct("Instance").finish()
|
||||
|
||||
@@ -56,12 +56,13 @@ pub use crate::vmcontext::{
|
||||
VMTableImport, VMTrampoline,
|
||||
};
|
||||
pub use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
|
||||
use loupe_derive::MemoryUsage;
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
/// A safe wrapper around `VMFunctionBody`.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, MemoryUsage)]
|
||||
#[repr(transparent)]
|
||||
pub struct FunctionBodyPtr(pub *const VMFunctionBody);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
use crate::probestack::PROBESTACK;
|
||||
use crate::trap::{raise_lib_trap, Trap, TrapCode};
|
||||
use crate::vmcontext::VMContext;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use wasmer_types::{DataIndex, ElemIndex, LocalMemoryIndex, MemoryIndex, TableIndex};
|
||||
@@ -405,7 +406,7 @@ pub static wasmer_probestack: unsafe extern "C" fn() = PROBESTACK;
|
||||
/// The name of a runtime library routine.
|
||||
///
|
||||
/// This list is likely to grow over time.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||
pub enum LibCall {
|
||||
/// ceil.f32
|
||||
CeilF32,
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
use crate::mmap::Mmap;
|
||||
use crate::vmcontext::VMMemoryDefinition;
|
||||
use loupe::MemoryUsage;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use more_asserts::assert_ge;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::BorrowMut;
|
||||
@@ -61,7 +63,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)]
|
||||
pub enum MemoryStyle {
|
||||
/// The actual memory can be resized and moved.
|
||||
Dynamic {
|
||||
@@ -96,7 +98,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;
|
||||
|
||||
@@ -116,7 +118,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>,
|
||||
@@ -144,7 +146,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.
|
||||
@@ -167,7 +169,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,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
//! `wasmer::Module`.
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
@@ -19,7 +20,7 @@ use wasmer_types::{
|
||||
TableIndex, TableInitializer, TableType,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
pub struct ModuleId {
|
||||
id: usize,
|
||||
}
|
||||
@@ -41,7 +42,7 @@ impl Default for ModuleId {
|
||||
|
||||
/// A translated WebAssembly module, excluding the function bodies and
|
||||
/// memory initializers.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, MemoryUsage)]
|
||||
pub struct ModuleInfo {
|
||||
/// A unique identifier (within this process) for this module.
|
||||
///
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
use crate::trap::{Trap, TrapCode};
|
||||
use crate::vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
|
||||
use loupe::MemoryUsage;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::cell::UnsafeCell;
|
||||
@@ -17,14 +19,14 @@ use std::sync::Mutex;
|
||||
use wasmer_types::{TableType, Type as ValType};
|
||||
|
||||
/// Implementation styles for WebAssembly tables.
|
||||
#[derive(Debug, Clone, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||
pub enum TableStyle {
|
||||
/// Signatures are stored in the table and checked in the caller.
|
||||
CallerChecksSignature,
|
||||
}
|
||||
|
||||
/// Trait for implementing the interface of a Wasm table.
|
||||
pub trait Table: fmt::Debug + Send + Sync {
|
||||
pub trait Table: fmt::Debug + Send + Sync + MemoryUsage {
|
||||
/// Returns the style for this Table.
|
||||
fn style(&self) -> &TableStyle;
|
||||
|
||||
@@ -103,7 +105,7 @@ pub trait Table: fmt::Debug + Send + Sync {
|
||||
}
|
||||
|
||||
/// A table instance.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
pub struct LinearTable {
|
||||
// TODO: we can remove the mutex by using atomic swaps and preallocating the max table size
|
||||
vec: Mutex<Vec<VMCallerCheckedAnyfunc>>,
|
||||
@@ -117,7 +119,7 @@ pub struct LinearTable {
|
||||
|
||||
/// A type to help manage who is responsible for the backing table of the
|
||||
/// `VMTableDefinition`.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MemoryUsage)]
|
||||
enum VMTableDefinitionOwnership {
|
||||
/// The `VMTableDefinition` is owned by the `Instance` and we should use
|
||||
/// its table. This is how a local table that's exported should be stored.
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
|
||||
use core::fmt::{self, Display, Formatter};
|
||||
use core::str::FromStr;
|
||||
use loupe_derive::MemoryUsage;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
/// A trap code describing the reason for a trap.
|
||||
///
|
||||
/// All trap instructions have an explicit trap code.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Error)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Error, MemoryUsage)]
|
||||
#[repr(u32)]
|
||||
pub enum TrapCode {
|
||||
/// The current stack space was exhausted.
|
||||
|
||||
@@ -9,10 +9,11 @@ use crate::instance::Instance;
|
||||
use crate::memory::Memory;
|
||||
use crate::table::Table;
|
||||
use crate::trap::{Trap, TrapCode};
|
||||
use loupe::MemoryUsage;
|
||||
use loupe::{MemoryUsage, MemoryUsageTracker, POINTER_BYTE_SIZE};
|
||||
use std::any::Any;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ptr::{self, NonNull};
|
||||
use std::sync::Arc;
|
||||
use std::u32;
|
||||
@@ -50,8 +51,14 @@ impl std::cmp::PartialEq for VMFunctionEnvironment {
|
||||
}
|
||||
}
|
||||
|
||||
impl MemoryUsage for VMFunctionEnvironment {
|
||||
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// An imported function.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone, MemoryUsage)]
|
||||
#[repr(C)]
|
||||
pub struct VMFunctionImport {
|
||||
/// A pointer to the imported function body.
|
||||
@@ -189,7 +196,7 @@ pub enum VMFunctionKind {
|
||||
|
||||
/// The fields compiled code needs to access to utilize a WebAssembly table
|
||||
/// imported from another instance.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[repr(C)]
|
||||
pub struct VMTableImport {
|
||||
/// A pointer to the imported table description.
|
||||
@@ -227,7 +234,7 @@ mod test_vmtable_import {
|
||||
|
||||
/// The fields compiled code needs to access to utilize a WebAssembly linear
|
||||
/// memory imported from another instance.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[repr(C)]
|
||||
pub struct VMMemoryImport {
|
||||
/// A pointer to the imported memory description.
|
||||
@@ -265,7 +272,7 @@ mod test_vmmemory_import {
|
||||
|
||||
/// The fields compiled code needs to access to utilize a WebAssembly global
|
||||
/// variable imported from another instance.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[repr(C)]
|
||||
pub struct VMGlobalImport {
|
||||
/// A pointer to the imported global variable description.
|
||||
@@ -337,6 +344,16 @@ unsafe impl Send for VMMemoryDefinition {}
|
||||
/// correctness in a multi-threaded context is concerned.
|
||||
unsafe impl Sync for VMMemoryDefinition {}
|
||||
|
||||
impl MemoryUsage for VMMemoryDefinition {
|
||||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
|
||||
if tracker.track(self.base as *const _ as *const ()) {
|
||||
POINTER_BYTE_SIZE * (self.current_length as usize)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VMMemoryDefinition {
|
||||
/// Do an unsynchronized, non-atomic `memory.copy` for the memory.
|
||||
///
|
||||
@@ -446,6 +463,16 @@ pub struct VMTableDefinition {
|
||||
pub current_elements: u32,
|
||||
}
|
||||
|
||||
impl MemoryUsage for VMTableDefinition {
|
||||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
|
||||
if tracker.track(self.base as *const _ as *const ()) {
|
||||
POINTER_BYTE_SIZE * (self.current_elements as usize)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_vmtable_definition {
|
||||
use super::VMTableDefinition;
|
||||
@@ -500,11 +527,17 @@ impl fmt::Debug for VMGlobalDefinitionStorage {
|
||||
}
|
||||
}
|
||||
|
||||
impl MemoryUsage for VMGlobalDefinitionStorage {
|
||||
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// The storage for a WebAssembly global defined within the instance.
|
||||
///
|
||||
/// TODO: Pack the globals more densely, rather than using the same size
|
||||
/// for every type.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[repr(C, align(16))]
|
||||
pub struct VMGlobalDefinition {
|
||||
storage: VMGlobalDefinitionStorage,
|
||||
@@ -751,7 +784,7 @@ impl Default for VMSharedSignatureIndex {
|
||||
/// The VM caller-checked "anyfunc" record, for caller-side signature checking.
|
||||
/// It consists of the actual function pointer and a signature id to be checked
|
||||
/// by the caller.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[repr(C)]
|
||||
pub struct VMCallerCheckedAnyfunc {
|
||||
/// Function body.
|
||||
|
||||
@@ -10,6 +10,8 @@ use crate::lib::std::boxed::Box;
|
||||
use crate::lib::std::marker::PhantomData;
|
||||
use crate::lib::std::ops::{Index, IndexMut};
|
||||
use crate::lib::std::slice;
|
||||
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||
use std::mem;
|
||||
|
||||
/// A slice mapping `K -> V` allocating dense entity references.
|
||||
///
|
||||
@@ -144,6 +146,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V> MemoryUsage for BoxedSlice<K, V>
|
||||
where
|
||||
K: EntityRef,
|
||||
V: MemoryUsage,
|
||||
{
|
||||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
+ self
|
||||
.elems
|
||||
.iter()
|
||||
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
|
||||
.sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -12,8 +12,10 @@ use crate::lib::std::marker::PhantomData;
|
||||
use crate::lib::std::ops::{Index, IndexMut};
|
||||
use crate::lib::std::slice;
|
||||
use crate::lib::std::vec::Vec;
|
||||
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::mem;
|
||||
|
||||
/// A primary mapping `K -> V` allocating dense entity references.
|
||||
///
|
||||
@@ -236,6 +238,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V> MemoryUsage for PrimaryMap<K, V>
|
||||
where
|
||||
K: EntityRef,
|
||||
V: MemoryUsage,
|
||||
{
|
||||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
+ self
|
||||
.elems
|
||||
.iter()
|
||||
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
|
||||
.sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -11,12 +11,14 @@ use crate::lib::std::marker::PhantomData;
|
||||
use crate::lib::std::ops::{Index, IndexMut};
|
||||
use crate::lib::std::slice;
|
||||
use crate::lib::std::vec::Vec;
|
||||
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{
|
||||
de::{Deserializer, SeqAccess, Visitor},
|
||||
ser::{SerializeSeq, Serializer},
|
||||
Deserialize, Serialize,
|
||||
};
|
||||
use std::mem;
|
||||
|
||||
/// A mapping `K -> V` for densely indexed entity references.
|
||||
///
|
||||
@@ -279,6 +281,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V> MemoryUsage for SecondaryMap<K, V>
|
||||
where
|
||||
K: EntityRef,
|
||||
V: Clone + MemoryUsage,
|
||||
{
|
||||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
|
||||
mem::size_of_val(self)
|
||||
+ self
|
||||
.elems
|
||||
.iter()
|
||||
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
|
||||
.sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex};
|
||||
use crate::lib::std::boxed::Box;
|
||||
use loupe_derive::MemoryUsage;
|
||||
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A WebAssembly table initializer.
|
||||
#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||
pub struct TableInitializer {
|
||||
/// The index of a table to initialize.
|
||||
pub table_index: TableIndex,
|
||||
@@ -19,7 +20,7 @@ pub struct TableInitializer {
|
||||
|
||||
/// A memory index and offset within that memory where a data initialization
|
||||
/// should be performed.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct DataInitializerLocation {
|
||||
/// The index of the memory to initialize.
|
||||
@@ -45,7 +46,7 @@ pub struct DataInitializer<'data> {
|
||||
|
||||
/// As `DataInitializer` but owning the data rather than
|
||||
/// holding a reference to it
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct OwnedDataInitializer {
|
||||
/// The location where the initialization is to be performed.
|
||||
|
||||
@@ -57,7 +57,7 @@ impl fmt::Display for Type {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
/// The WebAssembly V128 type
|
||||
pub struct V128(pub(crate) [u8; 16]);
|
||||
@@ -311,7 +311,7 @@ impl From<&FunctionType> for FunctionType {
|
||||
}
|
||||
|
||||
/// Indicator of whether a global is mutable or not
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub enum Mutability {
|
||||
/// The global is constant and its value does not change
|
||||
@@ -347,7 +347,7 @@ impl From<Mutability> for bool {
|
||||
}
|
||||
|
||||
/// WebAssembly global.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct GlobalType {
|
||||
/// The type of the value stored in the global.
|
||||
@@ -390,7 +390,7 @@ impl fmt::Display for GlobalType {
|
||||
}
|
||||
|
||||
/// Globals are initialized via the `const` operators or by referring to another import.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub enum GlobalInit {
|
||||
/// An `i32.const`.
|
||||
@@ -441,7 +441,7 @@ impl GlobalInit {
|
||||
/// Tables are contiguous chunks of a specific element, typically a `funcref` or
|
||||
/// an `externref`. The most common use for tables is a function table through
|
||||
/// which `call_indirect` can invoke other functions.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct TableType {
|
||||
/// The type of data stored in elements of the table.
|
||||
@@ -480,7 +480,7 @@ impl fmt::Display for TableType {
|
||||
///
|
||||
/// Memories are described in units of pages (64KB) and represent contiguous
|
||||
/// chunks of addressable memory.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct MemoryType {
|
||||
/// The minimum number of pages in the memory.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//! done as separate steps.
|
||||
|
||||
use crate::engine::DummyEngine;
|
||||
use loupe_derive::MemoryUsage;
|
||||
#[cfg(feature = "serialize")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
@@ -21,6 +22,7 @@ use wasmer_vm::{
|
||||
|
||||
/// Serializable struct for the artifact
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct DummyArtifactMetadata {
|
||||
pub module: Arc<ModuleInfo>,
|
||||
pub features: Features,
|
||||
@@ -34,10 +36,11 @@ pub struct DummyArtifactMetadata {
|
||||
///
|
||||
/// This artifact will point to fake finished functions and trampolines
|
||||
/// as no functions are really compiled.
|
||||
#[derive(MemoryUsage)]
|
||||
pub struct DummyArtifact {
|
||||
metadata: DummyArtifactMetadata,
|
||||
|
||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||
#[memoryusage(ignore)]
|
||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||
|
||||
Reference in New Issue
Block a user