From c75fb8a82737d06f8ad1aea42e63a586877208ab Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 16 Mar 2021 15:19:23 +0100 Subject: [PATCH] !fifth --- Cargo.lock | 4 ++++ lib/engine-object-file/Cargo.toml | 2 ++ lib/engine-object-file/src/engine.rs | 8 +++++++- tests/lib/engine-dummy/Cargo.toml | 2 ++ tests/lib/engine-dummy/src/engine.rs | 3 ++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff07601a75d..02001a8e23e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2525,6 +2525,8 @@ name = "wasmer-engine-dummy" version = "1.0.2" dependencies = [ "bincode", + "loupe", + "loupe-derive", "serde", "serde_bytes", "wasmer-compiler", @@ -2580,6 +2582,8 @@ dependencies = [ "cfg-if 0.1.10", "leb128", "libloading", + "loupe", + "loupe-derive", "serde", "tempfile", "tracing", diff --git a/lib/engine-object-file/Cargo.toml b/lib/engine-object-file/Cargo.toml index 36a0ee634fb..f78e1d699e9 100644 --- a/lib/engine-object-file/Cargo.toml +++ b/lib/engine-object-file/Cargo.toml @@ -23,6 +23,8 @@ bincode = "1.3" leb128 = "0.2" libloading = "0.7" tempfile = "3.1" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [features] # Enable the `compiler` feature if you want the engine to compile diff --git a/lib/engine-object-file/src/engine.rs b/lib/engine-object-file/src/engine.rs index 3f00db11977..a3f051f82bd 100644 --- a/lib/engine-object-file/src/engine.rs +++ b/lib/engine-object-file/src/engine.rs @@ -1,4 +1,5 @@ use crate::ObjectFileArtifact; +use loupe_derive::MemoryUsage; use std::io::Read; use std::path::Path; use std::sync::{Arc, Mutex}; @@ -12,7 +13,7 @@ use wasmer_types::FunctionType; use wasmer_vm::{SignatureRegistry, VMSharedSignatureIndex}; /// A WebAssembly `ObjectFile` Engine. -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] pub struct ObjectFileEngine { inner: Arc>, /// The target for the compiler @@ -165,19 +166,24 @@ impl Engine for ObjectFileEngine { } /// The inner contents of `ObjectFileEngine` +#[derive(MemoryUsage)] pub struct ObjectFileEngineInner { /// The compiler #[cfg(feature = "compiler")] compiler: Option>, + /// The WebAssembly features to use #[cfg(feature = "compiler")] features: Features, + /// The signature registry is used mainly to operate with trampolines /// performantly. signatures: SignatureRegistry, + /// The prefixer returns the a String to prefix each of /// the functions in the shared object generated by the `ObjectFileEngine`, /// so we can assure no collisions. + #[memoryusage(ignore)] prefixer: Option String + Send>>, } diff --git a/tests/lib/engine-dummy/Cargo.toml b/tests/lib/engine-dummy/Cargo.toml index 22c659d64af..3a81e5ef545 100644 --- a/tests/lib/engine-dummy/Cargo.toml +++ b/tests/lib/engine-dummy/Cargo.toml @@ -15,6 +15,8 @@ wasmer-engine = { path = "../../../lib/engine", version = "1.0.2" } serde = { version = "1.0", features = ["derive", "rc"], optional = true } serde_bytes = { version = "0.11", optional = true } bincode = { version = "1.2", optional = true } +loupe = { path = "../../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../../loupe/crates/loupe-derive" } [features] # Enable the `compiler` feature if you want the engine to compile diff --git a/tests/lib/engine-dummy/src/engine.rs b/tests/lib/engine-dummy/src/engine.rs index bdfab988571..0135bd3919e 100644 --- a/tests/lib/engine-dummy/src/engine.rs +++ b/tests/lib/engine-dummy/src/engine.rs @@ -1,6 +1,7 @@ //! Dummy Engine. use crate::DummyArtifact; +use loupe_derive::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{CompileError, Features, Target}; use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables}; @@ -17,7 +18,7 @@ extern "C" fn dummy_trampoline( } /// A WebAssembly `Dummy` Engine. -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] pub struct DummyEngine { signatures: Arc, features: Arc,