From 026520998c4042d14b486217acdacb1b3919e758 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 15 Mar 2021 20:28:07 +0100 Subject: [PATCH 1/7] feat: Start implementing `loupe::MemoryUsage` on `wasmer::Store`. --- Cargo.lock | 97 +++++++++++++++-------- lib/api/Cargo.toml | 2 + lib/api/src/store.rs | 3 +- lib/api/src/tunables.rs | 3 +- lib/compiler-cranelift/Cargo.toml | 2 + lib/compiler-cranelift/src/compiler.rs | 2 + lib/compiler-cranelift/src/config.rs | 5 +- lib/compiler-llvm/Cargo.toml | 2 + lib/compiler-llvm/src/compiler.rs | 2 + lib/compiler-llvm/src/config.rs | 5 +- lib/compiler-singlepass/Cargo.toml | 2 + lib/compiler-singlepass/src/compiler.rs | 2 + lib/compiler-singlepass/src/config.rs | 3 +- lib/compiler/Cargo.toml | 2 + lib/compiler/src/compiler.rs | 3 +- lib/compiler/src/target.rs | 5 +- lib/compiler/src/translator/middleware.rs | 3 +- lib/engine-jit/Cargo.toml | 2 + lib/engine-jit/src/code_memory.rs | 2 + lib/engine-jit/src/engine.rs | 4 +- lib/engine-jit/src/unwind/dummy.rs | 2 + lib/engine-jit/src/unwind/systemv.rs | 9 ++- lib/engine-jit/src/unwind/windows_x64.rs | 20 +++++ lib/engine-native/Cargo.toml | 2 + lib/engine-native/src/engine.rs | 14 +++- lib/engine-object-file/Cargo.toml | 2 + lib/engine-object-file/src/engine.rs | 8 +- lib/engine/Cargo.toml | 2 + lib/engine/src/engine.rs | 6 +- lib/engine/src/tunables.rs | 3 +- lib/middlewares/Cargo.toml | 2 + lib/middlewares/src/metering.rs | 12 ++- lib/vm/Cargo.toml | 2 + lib/vm/src/mmap.rs | 9 +++ lib/vm/src/sig_registry.rs | 5 +- lib/vm/src/vmcontext.rs | 3 +- lib/wasmer-types/Cargo.toml | 2 + lib/wasmer-types/src/features.rs | 3 +- lib/wasmer-types/src/indexes.rs | 29 +++---- lib/wasmer-types/src/types.rs | 5 +- lib/wasmer-types/src/units.rs | 3 +- tests/lib/engine-dummy/Cargo.toml | 2 + tests/lib/engine-dummy/src/engine.rs | 3 +- 43 files changed, 225 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb73620585a..02001a8e23e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -545,9 +545,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -941,9 +941,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -1088,9 +1088,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213" +checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" [[package]] name = "libffi" @@ -1154,6 +1154,19 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "loupe" +version = "0.1.0" + +[[package]] +name = "loupe-derive" +version = "0.1.0" +dependencies = [ + "loupe", + "quote", + "syn", +] + [[package]] name = "mach" version = "0.3.2" @@ -1372,9 +1385,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] name = "peeking_take_while" @@ -1393,9 +1406,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pkg-config" @@ -1627,14 +1640,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -1648,9 +1660,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "region" @@ -1825,9 +1837,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -1853,9 +1865,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -1922,9 +1934,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", @@ -2041,15 +2053,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" -dependencies = [ - "once_cell", -] - [[package]] name = "time" version = "0.1.43" @@ -2094,9 +2097,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -2120,9 +2123,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "typetag" @@ -2295,6 +2298,8 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", + "loupe", + "loupe-derive", "more-asserts", "target-lexicon", "tempfile", @@ -2390,6 +2395,8 @@ version = "1.0.2" dependencies = [ "enumset", "hashbrown", + "loupe", + "loupe-derive", "serde", "serde_bytes", "smallvec", @@ -2409,6 +2416,8 @@ dependencies = [ "gimli", "hashbrown", "lazy_static", + "loupe", + "loupe-derive", "more-asserts", "rayon", "serde", @@ -2431,6 +2440,8 @@ dependencies = [ "itertools 0.10.0", "lazy_static", "libc", + "loupe", + "loupe-derive", "rayon", "regex", "rustc_version 0.2.3", @@ -2451,6 +2462,8 @@ dependencies = [ "dynasmrt", "hashbrown", "lazy_static", + "loupe", + "loupe-derive", "more-asserts", "rayon", "serde", @@ -2493,6 +2506,8 @@ dependencies = [ "backtrace", "bincode", "lazy_static", + "loupe", + "loupe-derive", "memmap2", "more-asserts", "rustc-demangle", @@ -2510,6 +2525,8 @@ name = "wasmer-engine-dummy" version = "1.0.2" dependencies = [ "bincode", + "loupe", + "loupe-derive", "serde", "serde_bytes", "wasmer-compiler", @@ -2524,6 +2541,8 @@ version = "1.0.2" dependencies = [ "bincode", "cfg-if 0.1.10", + "loupe", + "loupe-derive", "region", "serde", "serde_bytes", @@ -2542,6 +2561,8 @@ dependencies = [ "cfg-if 0.1.10", "leb128", "libloading", + "loupe", + "loupe-derive", "serde", "tempfile", "tracing", @@ -2561,6 +2582,8 @@ dependencies = [ "cfg-if 0.1.10", "leb128", "libloading", + "loupe", + "loupe-derive", "serde", "tempfile", "tracing", @@ -2583,6 +2606,8 @@ dependencies = [ name = "wasmer-middlewares" version = "1.0.2" dependencies = [ + "loupe", + "loupe-derive", "wasmer", "wasmer-types", "wasmer-vm", @@ -2603,6 +2628,8 @@ name = "wasmer-types" version = "1.0.2" dependencies = [ "cranelift-entity", + "loupe", + "loupe-derive", "serde", "thiserror", ] @@ -2616,6 +2643,8 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", + "loupe", + "loupe-derive", "memoffset", "more-asserts", "region", diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index f9286c04c17..a7b7a99450c 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -27,6 +27,8 @@ wat = { version = "1.0", optional = true } thiserror = "1.0" more-asserts = "0.2" target-lexicon = { version = "0.11", default-features = false } +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [target.'cfg(target_os = "windows")'.dependencies] winapi = "0.3" diff --git a/lib/api/src/store.rs b/lib/api/src/store.rs index 66137508240..0e21f90489e 100644 --- a/lib/api/src/store.rs +++ b/lib/api/src/store.rs @@ -1,4 +1,5 @@ use crate::tunables::BaseTunables; +use loupe_derive::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: -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] pub struct Store { engine: Arc, tunables: Arc, diff --git a/lib/api/src/tunables.rs b/lib/api/src/tunables.rs index 2425400010e..30d09521f6d 100644 --- a/lib/api/src/tunables.rs +++ b/lib/api/src/tunables.rs @@ -1,4 +1,5 @@ use crate::{MemoryType, Pages, TableType}; +use loupe_derive::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, diff --git a/lib/compiler-cranelift/Cargo.toml b/lib/compiler-cranelift/Cargo.toml index 9a2c809f55c..54cb0fba189 100644 --- a/lib/compiler-cranelift/Cargo.toml +++ b/lib/compiler-cranelift/Cargo.toml @@ -24,6 +24,8 @@ serde = { version = "1.0", features = ["derive"] } more-asserts = "0.2" gimli = { version = "0.23", optional = true } smallvec = "1.6" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index 9b28a0a3a70..18073577550 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -18,6 +18,7 @@ use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::{binemit, Context}; #[cfg(feature = "unwind")] use gimli::write::{Address, EhFrame, FrameTable}; +use loupe_derive::MemoryUsage; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; use wasmer_compiler::CompileError; @@ -32,6 +33,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex}; /// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR, /// optimizing it and then translating to assembly. +#[derive(MemoryUsage)] pub struct CraneliftCompiler { config: Cranelift, } diff --git a/lib/compiler-cranelift/src/config.rs b/lib/compiler-cranelift/src/config.rs index 5a7b671b329..ac639e94ee2 100644 --- a/lib/compiler-cranelift/src/config.rs +++ b/lib/compiler-cranelift/src/config.rs @@ -1,6 +1,7 @@ use crate::compiler::CraneliftCompiler; use cranelift_codegen::isa::{lookup, TargetIsa}; use cranelift_codegen::settings::{self, Configurable}; +use loupe_derive::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{ Architecture, Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target, @@ -10,7 +11,7 @@ use wasmer_compiler::{ /// Possible optimization levels for the Cranelift codegen backend. #[non_exhaustive] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, MemoryUsage)] pub enum CraneliftOptLevel { /// No optimizations performed, minimizes compilation time by disabling most /// optimizations. @@ -27,7 +28,7 @@ pub enum CraneliftOptLevel { /// /// This structure exposes a builder-like interface and is primarily /// consumed by `wasmer_engine::Engine::new`. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MemoryUsage)] pub struct Cranelift { enable_nan_canonicalization: bool, enable_verifier: bool, diff --git a/lib/compiler-llvm/Cargo.toml b/lib/compiler-llvm/Cargo.toml index ce5159448c0..ae97a0f4cd9 100644 --- a/lib/compiler-llvm/Cargo.toml +++ b/lib/compiler-llvm/Cargo.toml @@ -22,6 +22,8 @@ libc = { version = "^0.2", default-features = false } byteorder = "1" itertools = "0.10" rayon = "1.5" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [dependencies.inkwell] version = "=0.1.0-beta.2" diff --git a/lib/compiler-llvm/src/compiler.rs b/lib/compiler-llvm/src/compiler.rs index d08f34bad2f..5ea1c9f8f24 100644 --- a/lib/compiler-llvm/src/compiler.rs +++ b/lib/compiler-llvm/src/compiler.rs @@ -7,6 +7,7 @@ use inkwell::memory_buffer::MemoryBuffer; use inkwell::module::{Linkage, Module}; use inkwell::targets::FileType; use inkwell::DLLStorageClass; +use loupe_derive::MemoryUsage; use rayon::iter::ParallelBridge; use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; @@ -22,6 +23,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex}; /// A compiler that compiles a WebAssembly module with LLVM, translating the Wasm to LLVM IR, /// optimizing it and then translating to assembly. +#[derive(MemoryUsage)] pub struct LLVMCompiler { config: LLVM, } diff --git a/lib/compiler-llvm/src/config.rs b/lib/compiler-llvm/src/config.rs index 6ae8085aaf1..66af408fee6 100644 --- a/lib/compiler-llvm/src/config.rs +++ b/lib/compiler-llvm/src/config.rs @@ -5,6 +5,7 @@ use inkwell::targets::{ }; pub use inkwell::OptimizationLevel as LLVMOptLevel; use itertools::Itertools; +use loupe_derive::MemoryUsage; use std::fmt::Debug; use std::sync::Arc; use target_lexicon::Architecture; @@ -37,12 +38,14 @@ pub trait LLVMCallbacks: Debug + Send + Sync { fn obj_memory_buffer(&self, function: &CompiledKind, memory_buffer: &InkwellMemoryBuffer); } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MemoryUsage)] pub struct LLVM { pub(crate) enable_nan_canonicalization: bool, pub(crate) enable_verifier: bool, + #[memoryusage(ignore)] pub(crate) opt_level: LLVMOptLevel, is_pic: bool, + #[memoryusage(ignore)] pub(crate) callbacks: Option>, /// The middleware chain. pub(crate) middlewares: Vec>, diff --git a/lib/compiler-singlepass/Cargo.toml b/lib/compiler-singlepass/Cargo.toml index 2c771c8c552..38e2f178f76 100644 --- a/lib/compiler-singlepass/Cargo.toml +++ b/lib/compiler-singlepass/Cargo.toml @@ -24,6 +24,8 @@ dynasmrt = "1.0" lazy_static = "1.4" byteorder = "1.3" smallvec = "1.6" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler-singlepass/src/compiler.rs b/lib/compiler-singlepass/src/compiler.rs index 0f2f6520b62..51a520f61f6 100644 --- a/lib/compiler-singlepass/src/compiler.rs +++ b/lib/compiler-singlepass/src/compiler.rs @@ -7,6 +7,7 @@ use crate::codegen_x64::{ CodegenError, FuncGen, }; use crate::config::Singlepass; +use loupe_derive::MemoryUsage; use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; use wasmer_compiler::TrapInformation; @@ -22,6 +23,7 @@ use wasmer_vm::{ModuleInfo, TrapCode, VMOffsets}; /// A compiler that compiles a WebAssembly module with Singlepass. /// It does the compilation in one pass +#[derive(MemoryUsage)] pub struct SinglepassCompiler { config: Singlepass, } diff --git a/lib/compiler-singlepass/src/config.rs b/lib/compiler-singlepass/src/config.rs index 669b8be0770..2426db66d61 100644 --- a/lib/compiler-singlepass/src/config.rs +++ b/lib/compiler-singlepass/src/config.rs @@ -2,11 +2,12 @@ #![allow(unused_imports, dead_code)] use crate::compiler::SinglepassCompiler; +use loupe_derive::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target}; use wasmer_types::Features; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MemoryUsage)] pub struct Singlepass { pub(crate) enable_nan_canonicalization: bool, pub(crate) enable_stack_check: bool, diff --git a/lib/compiler/Cargo.toml b/lib/compiler/Cargo.toml index 92625b684b6..91a83a26af8 100644 --- a/lib/compiler/Cargo.toml +++ b/lib/compiler/Cargo.toml @@ -21,6 +21,8 @@ serde = { version = "1.0", features = ["derive"], optional = true } thiserror = "1.0" serde_bytes = { version = "0.11", optional = true } smallvec = "1.6" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [features] default = ["std", "enable-serde"] diff --git a/lib/compiler/src/compiler.rs b/lib/compiler/src/compiler.rs index db2313b4ac5..eff21365c8a 100644 --- a/lib/compiler/src/compiler.rs +++ b/lib/compiler/src/compiler.rs @@ -11,6 +11,7 @@ use crate::translator::ModuleMiddleware; use crate::FunctionBodyData; use crate::ModuleTranslationState; use crate::SectionIndex; +use loupe::MemoryUsage; use wasmer_types::entity::PrimaryMap; use wasmer_types::{Features, FunctionIndex, LocalFunctionIndex, SignatureIndex}; use wasmparser::{Validator, WasmFeatures}; @@ -58,7 +59,7 @@ where } /// An implementation of a Compiler from parsed WebAssembly module to Compiled native code. -pub trait Compiler: Send { +pub trait Compiler: Send + MemoryUsage { /// Validates a module. /// /// It returns the a succesful Result in case is valid, `CompileError` in case is not. diff --git a/lib/compiler/src/target.rs b/lib/compiler/src/target.rs index 9d18d79e87d..bc5da48df28 100644 --- a/lib/compiler/src/target.rs +++ b/lib/compiler/src/target.rs @@ -3,6 +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_derive::MemoryUsage; pub use target_lexicon::{ Architecture, BinaryFormat, CallingConvention, Endianness, OperatingSystem, PointerWidth, Triple, @@ -160,9 +161,11 @@ impl ToString for CpuFeature { /// This is the target that we will use for compiling /// the WebAssembly ModuleInfo, and then run it. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, MemoryUsage)] pub struct Target { + #[memoryusage(ignore)] triple: Triple, + #[memoryusage(ignore)] cpu_features: EnumSet, } diff --git a/lib/compiler/src/translator/middleware.rs b/lib/compiler/src/translator/middleware.rs index 5efcc562f9b..3dd8c6aeda1 100644 --- a/lib/compiler/src/translator/middleware.rs +++ b/lib/compiler/src/translator/middleware.rs @@ -1,6 +1,7 @@ //! The middleware parses the function binary bytecodes and transform them //! with the chosen functions. +use loupe::MemoryUsage; use smallvec::SmallVec; use std::collections::VecDeque; use std::fmt::Debug; @@ -12,7 +13,7 @@ use wasmparser::{BinaryReader, Operator, Type}; use crate::error::{MiddlewareError, WasmResult}; /// A shared builder for function middlewares. -pub trait ModuleMiddleware: Debug + Send + Sync { +pub trait ModuleMiddleware: Debug + Send + Sync + MemoryUsage { /// Generates a `FunctionMiddleware` for a given function. /// /// Here we generate a separate object for each function instead of executing directly on per-function operators, diff --git a/lib/engine-jit/Cargo.toml b/lib/engine-jit/Cargo.toml index a4d1c6f90d0..bbe11a705de 100644 --- a/lib/engine-jit/Cargo.toml +++ b/lib/engine-jit/Cargo.toml @@ -21,6 +21,8 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" cfg-if = "0.1" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winnt", "impl-default"] } diff --git a/lib/engine-jit/src/code_memory.rs b/lib/engine-jit/src/code_memory.rs index 3d23e1eda5c..e6a6a4fab03 100644 --- a/lib/engine-jit/src/code_memory.rs +++ b/lib/engine-jit/src/code_memory.rs @@ -3,6 +3,7 @@ //! Memory management for executable code. use crate::unwind::UnwindRegistry; +use loupe_derive::MemoryUsage; use wasmer_compiler::{CompiledFunctionUnwindInfo, CustomSection, FunctionBody}; use wasmer_vm::{Mmap, VMFunctionBody}; @@ -18,6 +19,7 @@ const ARCH_FUNCTION_ALIGNMENT: usize = 16; const DATA_SECTION_ALIGNMENT: usize = 64; /// Memory manager for executable code. +#[derive(MemoryUsage)] pub struct CodeMemory { unwind_registry: UnwindRegistry, mmap: Mmap, diff --git a/lib/engine-jit/src/engine.rs b/lib/engine-jit/src/engine.rs index c3ff020ff49..bac82365937 100644 --- a/lib/engine-jit/src/engine.rs +++ b/lib/engine-jit/src/engine.rs @@ -1,6 +1,7 @@ //! JIT compilation. use crate::{CodeMemory, JITArtifact}; +use loupe_derive::MemoryUsage; use std::sync::{Arc, Mutex}; #[cfg(feature = "compiler")] use wasmer_compiler::Compiler; @@ -17,7 +18,7 @@ use wasmer_vm::{ }; /// A WebAssembly `JIT` Engine. -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] pub struct JITEngine { inner: Arc>, /// The target for the compiler @@ -138,6 +139,7 @@ impl Engine for JITEngine { } /// The inner contents of `JITEngine` +#[derive(MemoryUsage)] pub struct JITEngineInner { /// The compiler #[cfg(feature = "compiler")] diff --git a/lib/engine-jit/src/unwind/dummy.rs b/lib/engine-jit/src/unwind/dummy.rs index 3d029ecd981..4cd69926cef 100644 --- a/lib/engine-jit/src/unwind/dummy.rs +++ b/lib/engine-jit/src/unwind/dummy.rs @@ -1,9 +1,11 @@ //! Module for Dummy unwind registry. +use loupe_derive::MemoryUsage; use wasmer_compiler::CompiledFunctionUnwindInfo; /// Represents a registry of function unwind information when the host system /// support any one in specific. +#[derive(MemoryUsage)] pub struct DummyUnwindRegistry {} impl DummyUnwindRegistry { diff --git a/lib/engine-jit/src/unwind/systemv.rs b/lib/engine-jit/src/unwind/systemv.rs index d08ea778077..573ac08b1dc 100644 --- a/lib/engine-jit/src/unwind/systemv.rs +++ b/lib/engine-jit/src/unwind/systemv.rs @@ -2,9 +2,12 @@ // Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md //! Module for System V ABI unwind registry. + +use loupe_derive::MemoryUsage; use wasmer_compiler::CompiledFunctionUnwindInfo; /// Represents a registry of function unwind information for System V ABI. +#[derive(MemoryUsage)] pub struct UnwindRegistry { registrations: Vec, published: bool, @@ -65,7 +68,11 @@ impl UnwindRegistry { // deregistering it. We must avoid this // scenario. Usually, this is handled upstream by the // compilers. - debug_assert_ne!(eh_frame, &[0, 0, 0, 0], "`eh_frame` seems to contain empty FDEs"); + debug_assert_ne!( + eh_frame, + &[0, 0, 0, 0], + "`eh_frame` seems to contain empty FDEs" + ); // On gnu (libgcc), `__register_frame` will walk the FDEs until an entry of length 0 let ptr = eh_frame.as_ptr(); diff --git a/lib/engine-jit/src/unwind/windows_x64.rs b/lib/engine-jit/src/unwind/windows_x64.rs index 96cac39239c..1db1658acc7 100644 --- a/lib/engine-jit/src/unwind/windows_x64.rs +++ b/lib/engine-jit/src/unwind/windows_x64.rs @@ -2,6 +2,7 @@ // Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md //! Module for Windows x64 ABI unwind registry. +use loupe::{MemoryUsage, MemoryUsageTracker}; use std::collections::HashMap; use wasmer_compiler::CompiledFunctionUnwindInfo; use winapi::um::winnt; @@ -103,3 +104,22 @@ impl Drop for UnwindRegistry { } } } + +impl MemoryUsage for UnwindRegistry { + fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize { + // To count `RUNTIME_FUNCTION`, we first check the + // [documentation][doc1]. We see that it's a type alias to + // `_IMAGE_RUNTIME_FUNCTION_ENTRY`, let's check the + // [documentation][doc2]. It's composed of two `DWORD`, so two + // `u64`, and one `IMAGE_RUNTIME_FUNCTION_ENTRY_u`, which we + // approximate to size of `u64`. + // + // [doc1]: https://docs.rs/winapi/0.3.9/winapi/um/winnt/type.RUNTIME_FUNCTION.html + // [doc2]: https://docs.rs/winapi/0.3.9/winapi/um/winnt/struct._IMAGE_RUNTIME_FUNCTION_ENTRY.html + self.functions + .iter() + .map(|(key, _)| (key, std::mem::size_of::() * 3)) + .sum::() + + self.published.size_of_val(tracker) + } +} diff --git a/lib/engine-native/Cargo.toml b/lib/engine-native/Cargo.toml index c8f5c125dda..c875b0f5044 100644 --- a/lib/engine-native/Cargo.toml +++ b/lib/engine-native/Cargo.toml @@ -24,6 +24,8 @@ leb128 = "0.2" libloading = "0.7" tempfile = "3.1" which = "4.0" +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-native/src/engine.rs b/lib/engine-native/src/engine.rs index 03d49d6424a..bcfb28d4089 100644 --- a/lib/engine-native/src/engine.rs +++ b/lib/engine-native/src/engine.rs @@ -2,6 +2,7 @@ use crate::NativeArtifact; use libloading::Library; +use loupe_derive::MemoryUsage; use std::path::Path; use std::sync::Arc; use std::sync::Mutex; @@ -15,7 +16,7 @@ use wasmer_types::FunctionType; use wasmer_vm::{SignatureRegistry, VMSharedSignatureIndex}; /// A WebAssembly `Native` Engine. -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] pub struct NativeEngine { inner: Arc>, /// The target for the compiler @@ -174,7 +175,7 @@ impl Engine for NativeEngine { } } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, MemoryUsage)] pub(crate) enum Linker { None, Clang11, @@ -219,25 +220,34 @@ impl Linker { } /// The inner contents of `NativeEngine` +#[derive(MemoryUsage)] pub struct NativeEngineInner { /// 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 `NativeEngine`, /// so we can assure no collisions. + #[memoryusage(ignore)] prefixer: Option String + Send>>, + /// Whether the native engine will cross-compile. is_cross_compiling: bool, + /// The linker to use. linker: Linker, + /// List of libraries loaded by this engine. + #[memoryusage(ignore)] libraries: Vec, } 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/lib/engine/Cargo.toml b/lib/engine/Cargo.toml index eab531b0f6b..55c4a4ed8da 100644 --- a/lib/engine/Cargo.toml +++ b/lib/engine/Cargo.toml @@ -25,6 +25,8 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" lazy_static = "1.4" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [badges] maintenance = { status = "actively-developed" } diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index 8cfceb3a83f..9eed69ac618 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -2,6 +2,8 @@ use crate::tunables::Tunables; use crate::{Artifact, DeserializeError}; +use loupe::MemoryUsage; +use loupe_derive::MemoryUsage; use memmap2::Mmap; use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; @@ -16,7 +18,7 @@ use wasmer_vm::VMSharedSignatureIndex; /// such as: JIT or Native. /// /// The product that an `Engine` produces and consumes is the [`Artifact`]. -pub trait Engine { +pub trait Engine: MemoryUsage { /// Gets the target fn target(&self) -> &Target; @@ -68,7 +70,7 @@ pub trait Engine { fn cloned(&self) -> Arc; } -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, MemoryUsage)] #[repr(transparent)] /// A unique identifier for an Engine. pub struct EngineId { diff --git a/lib/engine/src/tunables.rs b/lib/engine/src/tunables.rs index 7d3de72918a..adad964c697 100644 --- a/lib/engine/src/tunables.rs +++ b/lib/engine/src/tunables.rs @@ -1,4 +1,5 @@ use crate::error::LinkError; +use loupe::MemoryUsage; use std::ptr::NonNull; use std::sync::Arc; use wasmer_types::entity::{EntityRef, PrimaryMap}; @@ -13,7 +14,7 @@ use wasmer_vm::{VMMemoryDefinition, VMTableDefinition}; /// An engine delegates the creation of memories, tables, and globals /// to a foreign implementor of this trait. -pub trait Tunables { +pub trait Tunables: MemoryUsage { /// Construct a `MemoryStyle` for the provided `MemoryType` fn memory_style(&self, memory: &MemoryType) -> MemoryStyle; diff --git a/lib/middlewares/Cargo.toml b/lib/middlewares/Cargo.toml index 6ffde00e35c..ebbd3e75560 100644 --- a/lib/middlewares/Cargo.toml +++ b/lib/middlewares/Cargo.toml @@ -14,6 +14,8 @@ edition = "2018" wasmer = { path = "../api", version = "1.0.2" } wasmer-types = { path = "../wasmer-types", version = "1.0.2" } wasmer-vm = { path = "../vm", version = "1.0.2" } +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [badges] maintenance = { status = "actively-developed" } diff --git a/lib/middlewares/src/metering.rs b/lib/middlewares/src/metering.rs index 94a07df2880..b3ddc029afa 100644 --- a/lib/middlewares/src/metering.rs +++ b/lib/middlewares/src/metering.rs @@ -1,8 +1,11 @@ //! `metering` is a middleware for tracking how many operators are executed in total //! and putting a limit on the total number of operators executed. +use loupe::{MemoryUsage, MemoryUsageTracker}; +use loupe_derive::MemoryUsage; use std::convert::TryInto; use std::fmt; +use std::mem; use std::sync::{Arc, Mutex}; use wasmer::wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}; use wasmer::{ @@ -12,7 +15,7 @@ use wasmer::{ use wasmer_types::GlobalIndex; use wasmer_vm::ModuleInfo; -#[derive(Clone)] +#[derive(Clone, MemoryUsage)] struct MeteringGlobalIndexes(GlobalIndex, GlobalIndex); impl MeteringGlobalIndexes { @@ -154,6 +157,13 @@ impl u64 + Send + Sync + 'static> ModuleMiddleware for Meter } } +impl u64 + Send + Sync + 'static> MemoryUsage for Metering { + fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize { + mem::size_of_val(self) + self.global_indexes.size_of_val(tracker) + - mem::size_of_val(&self.global_indexes) + } +} + impl u64 + Send + Sync> fmt::Debug for FunctionMetering { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FunctionMetering") diff --git a/lib/vm/Cargo.toml b/lib/vm/Cargo.toml index 5f1c88d104c..4d55a8625bf 100644 --- a/lib/vm/Cargo.toml +++ b/lib/vm/Cargo.toml @@ -21,6 +21,8 @@ more-asserts = "0.2" cfg-if = "0.1" backtrace = "0.3" serde = { version = "1.0", features = ["derive", "rc"] } +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] } diff --git a/lib/vm/src/mmap.rs b/lib/vm/src/mmap.rs index 6b3dcdd19cd..7f33e88628e 100644 --- a/lib/vm/src/mmap.rs +++ b/lib/vm/src/mmap.rs @@ -4,6 +4,7 @@ //! Low-level abstraction for allocating and managing zero-filled pages //! of memory. +use loupe::{MemoryUsage, MemoryUsageTracker}; use more_asserts::assert_le; use more_asserts::assert_lt; use std::io; @@ -279,6 +280,14 @@ impl Drop for Mmap { } } +impl MemoryUsage for Mmap { + fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize { + tracker.track(self.as_ptr() as *const ()); + + self.len() + } +} + fn _assert() { fn _assert_send_sync() {} _assert_send_sync::(); diff --git a/lib/vm/src/sig_registry.rs b/lib/vm/src/sig_registry.rs index 58b690fc6b7..b0da474eb07 100644 --- a/lib/vm/src/sig_registry.rs +++ b/lib/vm/src/sig_registry.rs @@ -5,6 +5,7 @@ //! signature checking. use crate::vmcontext::VMSharedSignatureIndex; +use loupe_derive::MemoryUsage; use more_asserts::{assert_lt, debug_assert_lt}; use std::collections::{hash_map, HashMap}; use std::convert::TryFrom; @@ -15,7 +16,7 @@ use wasmer_types::FunctionType; /// call must match. To implement this efficiently, keep a registry of all /// signatures, shared by all instances, so that call sites can just do an /// index comparison. -#[derive(Debug)] +#[derive(Debug, MemoryUsage)] pub struct SignatureRegistry { // This structure is stored in an `Engine` and is intended to be shared // across many instances. Ideally instances can themselves be sent across @@ -25,7 +26,7 @@ pub struct SignatureRegistry { inner: RwLock, } -#[derive(Debug, Default)] +#[derive(Debug, Default, MemoryUsage)] struct Inner { signature2index: HashMap, index2signature: HashMap, diff --git a/lib/vm/src/vmcontext.rs b/lib/vm/src/vmcontext.rs index 4e50eb459cb..7262be3cb50 100644 --- a/lib/vm/src/vmcontext.rs +++ b/lib/vm/src/vmcontext.rs @@ -9,6 +9,7 @@ use crate::instance::Instance; use crate::memory::Memory; use crate::table::Table; use crate::trap::{Trap, TrapCode}; +use loupe_derive::MemoryUsage; use std::any::Any; use std::convert::TryFrom; use std::fmt; @@ -705,7 +706,7 @@ impl VMGlobalDefinition { /// An index into the shared signature registry, usable for checking signatures /// at indirect calls. #[repr(C)] -#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)] +#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash, MemoryUsage)] pub struct VMSharedSignatureIndex(u32); #[cfg(test)] diff --git a/lib/wasmer-types/Cargo.toml b/lib/wasmer-types/Cargo.toml index 9f56e3361ff..fbfebc32022 100644 --- a/lib/wasmer-types/Cargo.toml +++ b/lib/wasmer-types/Cargo.toml @@ -16,6 +16,8 @@ edition = "2018" cranelift-entity = "0.70" serde = { version = "1.0", features = ["derive"], optional = true, default-features = false } thiserror = "1.0" +loupe = { path = "../../../loupe/crates/loupe" } +loupe-derive = { path = "../../../loupe/crates/loupe-derive" } [features] default = ["std", "enable-serde"] diff --git a/lib/wasmer-types/src/features.rs b/lib/wasmer-types/src/features.rs index 557c4e6323d..a051bcfbdfc 100644 --- a/lib/wasmer-types/src/features.rs +++ b/lib/wasmer-types/src/features.rs @@ -1,3 +1,4 @@ +use loupe_derive::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; @@ -5,7 +6,7 @@ use serde::{Deserialize, Serialize}; /// Features usually have a corresponding [WebAssembly proposal]. /// /// [WebAssembly proposal]: https://github.com/WebAssembly/proposals -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct Features { /// Threads proposal should be enabled diff --git a/lib/wasmer-types/src/indexes.rs b/lib/wasmer-types/src/indexes.rs index 7c2247f8eb6..06ba01caae7 100644 --- a/lib/wasmer-types/src/indexes.rs +++ b/lib/wasmer-types/src/indexes.rs @@ -1,83 +1,84 @@ //! Helper functions and structures for the translation. use crate::entity::entity_impl; use core::u32; +use loupe_derive::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; /// Index type of a function defined locally inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct LocalFunctionIndex(u32); entity_impl!(LocalFunctionIndex); /// Index type of a table defined locally inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct LocalTableIndex(u32); entity_impl!(LocalTableIndex); /// Index type of a memory defined locally inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct LocalMemoryIndex(u32); entity_impl!(LocalMemoryIndex); /// Index type of a global defined locally inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct LocalGlobalIndex(u32); entity_impl!(LocalGlobalIndex); /// Index type of a function (imported or local) inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct FunctionIndex(u32); entity_impl!(FunctionIndex); /// Index type of a table (imported or local) inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct TableIndex(u32); entity_impl!(TableIndex); /// Index type of a global variable (imported or local) inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct GlobalIndex(u32); entity_impl!(GlobalIndex); /// Index type of a linear memory (imported or local) inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct MemoryIndex(u32); entity_impl!(MemoryIndex); /// Index type of a signature (imported or local) inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct SignatureIndex(u32); entity_impl!(SignatureIndex); /// Index type of a passive data segment inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct DataIndex(u32); entity_impl!(DataIndex); /// Index type of a passive element segment inside the WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct ElemIndex(u32); entity_impl!(ElemIndex); /// Index type of a custom section inside a WebAssembly module. -#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct CustomSectionIndex(u32); entity_impl!(CustomSectionIndex); /// An entity to export. -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub enum ExportIndex { /// Function export. @@ -91,7 +92,7 @@ pub enum ExportIndex { } /// An entity to import. -#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub enum ImportIndex { /// Function import. diff --git a/lib/wasmer-types/src/types.rs b/lib/wasmer-types/src/types.rs index 6a9b9b9ab4d..3482d42a8cc 100644 --- a/lib/wasmer-types/src/types.rs +++ b/lib/wasmer-types/src/types.rs @@ -6,6 +6,7 @@ use crate::lib::std::string::{String, ToString}; use crate::lib::std::vec::Vec; use crate::units::Pages; use crate::values::Value; +use loupe_derive::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; @@ -15,7 +16,7 @@ use serde::{Deserialize, Serialize}; // Value Types /// A list of all possible value types in WebAssembly. -#[derive(Copy, Debug, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Debug, Clone, Eq, PartialEq, Hash, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub enum Type { /// Signed 32 bit integer. @@ -225,7 +226,7 @@ impl ExternType { /// in a Wasm module or exposed to Wasm by the host. /// /// WebAssembly functions can have 0 or more parameters and results. -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct FunctionType { /// The parameters of the function diff --git a/lib/wasmer-types/src/units.rs b/lib/wasmer-types/src/units.rs index 93e9f04d473..7030061675f 100644 --- a/lib/wasmer-types/src/units.rs +++ b/lib/wasmer-types/src/units.rs @@ -1,6 +1,7 @@ use crate::lib::std::convert::TryFrom; use crate::lib::std::fmt; use crate::lib::std::ops::{Add, Sub}; +use loupe_derive::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use std::convert::TryInto; @@ -19,7 +20,7 @@ pub const WASM_MAX_PAGES: u32 = 0x10000; pub const WASM_MIN_PAGES: u32 = 0x100; /// Units of WebAssembly pages (as specified to be 65,536 bytes). -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, MemoryUsage)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct Pages(pub u32); 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, From 2afed4d813265e31ec7693fa489201b2c14a91eb Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 22 Mar 2021 11:38:25 +0100 Subject: [PATCH 2/7] feat: Use latest version of `loupe`. --- Cargo.lock | 20 ++++++-------------- lib/api/Cargo.toml | 3 +-- lib/api/src/store.rs | 2 +- lib/api/src/tunables.rs | 2 +- lib/compiler-cranelift/Cargo.toml | 3 +-- lib/compiler-cranelift/src/compiler.rs | 2 +- lib/compiler-cranelift/src/config.rs | 2 +- lib/compiler-llvm/Cargo.toml | 3 +-- lib/compiler-llvm/src/compiler.rs | 2 +- lib/compiler-llvm/src/config.rs | 6 +++--- lib/compiler-singlepass/Cargo.toml | 3 +-- lib/compiler-singlepass/src/compiler.rs | 2 +- lib/compiler-singlepass/src/config.rs | 2 +- lib/compiler/Cargo.toml | 3 +-- lib/compiler/src/target.rs | 6 +++--- lib/engine-jit/Cargo.toml | 3 +-- lib/engine-jit/src/code_memory.rs | 2 +- lib/engine-jit/src/engine.rs | 2 +- lib/engine-jit/src/unwind/dummy.rs | 2 +- lib/engine-jit/src/unwind/systemv.rs | 2 +- lib/engine-native/Cargo.toml | 3 +-- lib/engine-native/src/engine.rs | 6 +++--- lib/engine-object-file/Cargo.toml | 3 +-- lib/engine-object-file/src/engine.rs | 4 ++-- lib/engine/Cargo.toml | 3 +-- lib/engine/src/engine.rs | 1 - lib/middlewares/Cargo.toml | 3 +-- lib/middlewares/src/metering.rs | 1 - lib/vm/Cargo.toml | 3 +-- lib/vm/src/sig_registry.rs | 2 +- lib/vm/src/vmcontext.rs | 2 +- lib/wasmer-types/Cargo.toml | 3 +-- lib/wasmer-types/src/features.rs | 2 +- lib/wasmer-types/src/indexes.rs | 2 +- lib/wasmer-types/src/types.rs | 2 +- lib/wasmer-types/src/units.rs | 2 +- tests/lib/engine-dummy/Cargo.toml | 3 +-- tests/lib/engine-dummy/src/engine.rs | 2 +- 38 files changed, 48 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e27efa31d6c..3ebaca6ac15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,12 +1157,17 @@ dependencies = [ [[package]] name = "loupe" version = "0.1.0" +source = "git+https://github.com/wasmerio/loupe?branch=master#63c2f4a5acf1f3a8ed3568119cad96a731c71d21" +dependencies = [ + "loupe-derive", + "rustversion", +] [[package]] name = "loupe-derive" version = "0.1.0" +source = "git+https://github.com/wasmerio/loupe?branch=master#63c2f4a5acf1f3a8ed3568119cad96a731c71d21" dependencies = [ - "loupe", "quote", "syn", ] @@ -2299,7 +2304,6 @@ dependencies = [ "indexmap", "libc", "loupe", - "loupe-derive", "more-asserts", "target-lexicon", "tempfile", @@ -2396,7 +2400,6 @@ dependencies = [ "enumset", "hashbrown", "loupe", - "loupe-derive", "serde", "serde_bytes", "smallvec", @@ -2418,7 +2421,6 @@ dependencies = [ "hashbrown", "lazy_static", "loupe", - "loupe-derive", "more-asserts", "rayon", "serde", @@ -2442,7 +2444,6 @@ dependencies = [ "lazy_static", "libc", "loupe", - "loupe-derive", "rayon", "regex", "rustc_version 0.2.3", @@ -2464,7 +2465,6 @@ dependencies = [ "hashbrown", "lazy_static", "loupe", - "loupe-derive", "more-asserts", "rayon", "serde", @@ -2508,7 +2508,6 @@ dependencies = [ "bincode", "lazy_static", "loupe", - "loupe-derive", "memmap2", "more-asserts", "rustc-demangle", @@ -2527,7 +2526,6 @@ version = "1.0.2" dependencies = [ "bincode", "loupe", - "loupe-derive", "serde", "serde_bytes", "wasmer-compiler", @@ -2543,7 +2541,6 @@ dependencies = [ "bincode", "cfg-if 0.1.10", "loupe", - "loupe-derive", "region", "serde", "serde_bytes", @@ -2563,7 +2560,6 @@ dependencies = [ "leb128", "libloading", "loupe", - "loupe-derive", "serde", "tempfile", "tracing", @@ -2584,7 +2580,6 @@ dependencies = [ "leb128", "libloading", "loupe", - "loupe-derive", "serde", "tempfile", "tracing", @@ -2608,7 +2603,6 @@ name = "wasmer-middlewares" version = "1.0.2" dependencies = [ "loupe", - "loupe-derive", "wasmer", "wasmer-types", "wasmer-vm", @@ -2629,7 +2623,6 @@ name = "wasmer-types" version = "1.0.2" dependencies = [ "loupe", - "loupe-derive", "serde", "thiserror", ] @@ -2644,7 +2637,6 @@ dependencies = [ "indexmap", "libc", "loupe", - "loupe-derive", "memoffset", "more-asserts", "region", diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index a7b7a99450c..f69280e6d55 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -27,8 +27,7 @@ wat = { version = "1.0", optional = true } thiserror = "1.0" more-asserts = "0.2" target-lexicon = { version = "0.11", default-features = false } -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [target.'cfg(target_os = "windows")'.dependencies] winapi = "0.3" diff --git a/lib/api/src/store.rs b/lib/api/src/store.rs index 0e21f90489e..2371fd18b2c 100644 --- a/lib/api/src/store.rs +++ b/lib/api/src/store.rs @@ -1,5 +1,5 @@ use crate::tunables::BaseTunables; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::fmt; use std::sync::Arc; #[cfg(all(feature = "compiler", feature = "engine"))] diff --git a/lib/api/src/tunables.rs b/lib/api/src/tunables.rs index 30d09521f6d..d714ffd602b 100644 --- a/lib/api/src/tunables.rs +++ b/lib/api/src/tunables.rs @@ -1,5 +1,5 @@ use crate::{MemoryType, Pages, TableType}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::cmp::min; use std::ptr::NonNull; use std::sync::Arc; diff --git a/lib/compiler-cranelift/Cargo.toml b/lib/compiler-cranelift/Cargo.toml index 32bedd59e00..cb0d3630d72 100644 --- a/lib/compiler-cranelift/Cargo.toml +++ b/lib/compiler-cranelift/Cargo.toml @@ -25,8 +25,7 @@ serde = { version = "1.0", features = ["derive"] } more-asserts = "0.2" gimli = { version = "0.23", optional = true } smallvec = "1.6" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index 18073577550..dd297033098 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -18,7 +18,7 @@ use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::{binemit, Context}; #[cfg(feature = "unwind")] use gimli::write::{Address, EhFrame, FrameTable}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; use wasmer_compiler::CompileError; diff --git a/lib/compiler-cranelift/src/config.rs b/lib/compiler-cranelift/src/config.rs index ac639e94ee2..ed8419c2fce 100644 --- a/lib/compiler-cranelift/src/config.rs +++ b/lib/compiler-cranelift/src/config.rs @@ -1,7 +1,7 @@ use crate::compiler::CraneliftCompiler; use cranelift_codegen::isa::{lookup, TargetIsa}; use cranelift_codegen::settings::{self, Configurable}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{ Architecture, Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target, diff --git a/lib/compiler-llvm/Cargo.toml b/lib/compiler-llvm/Cargo.toml index ae97a0f4cd9..d6aac52fa35 100644 --- a/lib/compiler-llvm/Cargo.toml +++ b/lib/compiler-llvm/Cargo.toml @@ -22,8 +22,7 @@ libc = { version = "^0.2", default-features = false } byteorder = "1" itertools = "0.10" rayon = "1.5" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [dependencies.inkwell] version = "=0.1.0-beta.2" diff --git a/lib/compiler-llvm/src/compiler.rs b/lib/compiler-llvm/src/compiler.rs index 5ea1c9f8f24..d3d1b842856 100644 --- a/lib/compiler-llvm/src/compiler.rs +++ b/lib/compiler-llvm/src/compiler.rs @@ -7,7 +7,7 @@ use inkwell::memory_buffer::MemoryBuffer; use inkwell::module::{Linkage, Module}; use inkwell::targets::FileType; use inkwell::DLLStorageClass; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use rayon::iter::ParallelBridge; use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; diff --git a/lib/compiler-llvm/src/config.rs b/lib/compiler-llvm/src/config.rs index 66af408fee6..245a27e92f6 100644 --- a/lib/compiler-llvm/src/config.rs +++ b/lib/compiler-llvm/src/config.rs @@ -5,7 +5,7 @@ use inkwell::targets::{ }; pub use inkwell::OptimizationLevel as LLVMOptLevel; use itertools::Itertools; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::fmt::Debug; use std::sync::Arc; use target_lexicon::Architecture; @@ -42,10 +42,10 @@ pub trait LLVMCallbacks: Debug + Send + Sync { pub struct LLVM { pub(crate) enable_nan_canonicalization: bool, pub(crate) enable_verifier: bool, - #[memoryusage(ignore)] + #[loupe(skip)] pub(crate) opt_level: LLVMOptLevel, is_pic: bool, - #[memoryusage(ignore)] + #[loupe(skip)] pub(crate) callbacks: Option>, /// The middleware chain. pub(crate) middlewares: Vec>, diff --git a/lib/compiler-singlepass/Cargo.toml b/lib/compiler-singlepass/Cargo.toml index 38e2f178f76..ede05f8bb56 100644 --- a/lib/compiler-singlepass/Cargo.toml +++ b/lib/compiler-singlepass/Cargo.toml @@ -24,8 +24,7 @@ dynasmrt = "1.0" lazy_static = "1.4" byteorder = "1.3" smallvec = "1.6" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler-singlepass/src/compiler.rs b/lib/compiler-singlepass/src/compiler.rs index 51a520f61f6..edc1d93a4a4 100644 --- a/lib/compiler-singlepass/src/compiler.rs +++ b/lib/compiler-singlepass/src/compiler.rs @@ -7,7 +7,7 @@ use crate::codegen_x64::{ CodegenError, FuncGen, }; use crate::config::Singlepass; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}; use std::sync::Arc; use wasmer_compiler::TrapInformation; diff --git a/lib/compiler-singlepass/src/config.rs b/lib/compiler-singlepass/src/config.rs index 2426db66d61..d788478a9b9 100644 --- a/lib/compiler-singlepass/src/config.rs +++ b/lib/compiler-singlepass/src/config.rs @@ -2,7 +2,7 @@ #![allow(unused_imports, dead_code)] use crate::compiler::SinglepassCompiler; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target}; use wasmer_types::Features; diff --git a/lib/compiler/Cargo.toml b/lib/compiler/Cargo.toml index 91a83a26af8..579f7814ed0 100644 --- a/lib/compiler/Cargo.toml +++ b/lib/compiler/Cargo.toml @@ -21,8 +21,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } thiserror = "1.0" serde_bytes = { version = "0.11", optional = true } smallvec = "1.6" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [features] default = ["std", "enable-serde"] diff --git a/lib/compiler/src/target.rs b/lib/compiler/src/target.rs index bc5da48df28..12b2b06f1c6 100644 --- a/lib/compiler/src/target.rs +++ b/lib/compiler/src/target.rs @@ -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_derive::MemoryUsage; +use loupe::MemoryUsage; pub use target_lexicon::{ Architecture, BinaryFormat, CallingConvention, Endianness, OperatingSystem, PointerWidth, Triple, @@ -163,9 +163,9 @@ impl ToString for CpuFeature { /// the WebAssembly ModuleInfo, and then run it. #[derive(Clone, Debug, PartialEq, Eq, Hash, MemoryUsage)] pub struct Target { - #[memoryusage(ignore)] + #[loupe(skip)] triple: Triple, - #[memoryusage(ignore)] + #[loupe(skip)] cpu_features: EnumSet, } diff --git a/lib/engine-jit/Cargo.toml b/lib/engine-jit/Cargo.toml index bbe11a705de..38b70474e25 100644 --- a/lib/engine-jit/Cargo.toml +++ b/lib/engine-jit/Cargo.toml @@ -21,8 +21,7 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" cfg-if = "0.1" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winnt", "impl-default"] } diff --git a/lib/engine-jit/src/code_memory.rs b/lib/engine-jit/src/code_memory.rs index e6a6a4fab03..1498a23ea13 100644 --- a/lib/engine-jit/src/code_memory.rs +++ b/lib/engine-jit/src/code_memory.rs @@ -3,7 +3,7 @@ //! Memory management for executable code. use crate::unwind::UnwindRegistry; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use wasmer_compiler::{CompiledFunctionUnwindInfo, CustomSection, FunctionBody}; use wasmer_vm::{Mmap, VMFunctionBody}; diff --git a/lib/engine-jit/src/engine.rs b/lib/engine-jit/src/engine.rs index bac82365937..9009d937b62 100644 --- a/lib/engine-jit/src/engine.rs +++ b/lib/engine-jit/src/engine.rs @@ -1,7 +1,7 @@ //! JIT compilation. use crate::{CodeMemory, JITArtifact}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::sync::{Arc, Mutex}; #[cfg(feature = "compiler")] use wasmer_compiler::Compiler; diff --git a/lib/engine-jit/src/unwind/dummy.rs b/lib/engine-jit/src/unwind/dummy.rs index 4cd69926cef..cfb636bd2c8 100644 --- a/lib/engine-jit/src/unwind/dummy.rs +++ b/lib/engine-jit/src/unwind/dummy.rs @@ -1,6 +1,6 @@ //! Module for Dummy unwind registry. -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use wasmer_compiler::CompiledFunctionUnwindInfo; /// Represents a registry of function unwind information when the host system diff --git a/lib/engine-jit/src/unwind/systemv.rs b/lib/engine-jit/src/unwind/systemv.rs index 573ac08b1dc..8362fec499c 100644 --- a/lib/engine-jit/src/unwind/systemv.rs +++ b/lib/engine-jit/src/unwind/systemv.rs @@ -3,7 +3,7 @@ //! Module for System V ABI unwind registry. -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use wasmer_compiler::CompiledFunctionUnwindInfo; /// Represents a registry of function unwind information for System V ABI. diff --git a/lib/engine-native/Cargo.toml b/lib/engine-native/Cargo.toml index c875b0f5044..be045b7a4df 100644 --- a/lib/engine-native/Cargo.toml +++ b/lib/engine-native/Cargo.toml @@ -24,8 +24,7 @@ leb128 = "0.2" libloading = "0.7" tempfile = "3.1" which = "4.0" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [features] # Enable the `compiler` feature if you want the engine to compile diff --git a/lib/engine-native/src/engine.rs b/lib/engine-native/src/engine.rs index bcfb28d4089..84f857fd6d6 100644 --- a/lib/engine-native/src/engine.rs +++ b/lib/engine-native/src/engine.rs @@ -2,7 +2,7 @@ use crate::NativeArtifact; use libloading::Library; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::path::Path; use std::sync::Arc; use std::sync::Mutex; @@ -237,7 +237,7 @@ pub struct NativeEngineInner { /// The prefixer returns the a String to prefix each of /// the functions in the shared object generated by the `NativeEngine`, /// so we can assure no collisions. - #[memoryusage(ignore)] + #[loupe(skip)] prefixer: Option String + Send>>, /// Whether the native engine will cross-compile. @@ -247,7 +247,7 @@ pub struct NativeEngineInner { linker: Linker, /// List of libraries loaded by this engine. - #[memoryusage(ignore)] + #[loupe(skip)] libraries: Vec, } diff --git a/lib/engine-object-file/Cargo.toml b/lib/engine-object-file/Cargo.toml index f78e1d699e9..17ee1e01661 100644 --- a/lib/engine-object-file/Cargo.toml +++ b/lib/engine-object-file/Cargo.toml @@ -23,8 +23,7 @@ bincode = "1.3" leb128 = "0.2" libloading = "0.7" tempfile = "3.1" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [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 a3f051f82bd..8bd589361d2 100644 --- a/lib/engine-object-file/src/engine.rs +++ b/lib/engine-object-file/src/engine.rs @@ -1,5 +1,5 @@ use crate::ObjectFileArtifact; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::io::Read; use std::path::Path; use std::sync::{Arc, Mutex}; @@ -183,7 +183,7 @@ pub struct ObjectFileEngineInner { /// 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)] + #[loupe(skip)] prefixer: Option String + Send>>, } diff --git a/lib/engine/Cargo.toml b/lib/engine/Cargo.toml index 55c4a4ed8da..a8ae21becf7 100644 --- a/lib/engine/Cargo.toml +++ b/lib/engine/Cargo.toml @@ -25,8 +25,7 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" lazy_static = "1.4" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [badges] maintenance = { status = "actively-developed" } diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index 9eed69ac618..8d5f6c360bc 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -3,7 +3,6 @@ use crate::tunables::Tunables; use crate::{Artifact, DeserializeError}; use loupe::MemoryUsage; -use loupe_derive::MemoryUsage; use memmap2::Mmap; use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; diff --git a/lib/middlewares/Cargo.toml b/lib/middlewares/Cargo.toml index ebbd3e75560..5fd6837df79 100644 --- a/lib/middlewares/Cargo.toml +++ b/lib/middlewares/Cargo.toml @@ -14,8 +14,7 @@ edition = "2018" wasmer = { path = "../api", version = "1.0.2" } wasmer-types = { path = "../wasmer-types", version = "1.0.2" } wasmer-vm = { path = "../vm", version = "1.0.2" } -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [badges] maintenance = { status = "actively-developed" } diff --git a/lib/middlewares/src/metering.rs b/lib/middlewares/src/metering.rs index b3ddc029afa..faea363e073 100644 --- a/lib/middlewares/src/metering.rs +++ b/lib/middlewares/src/metering.rs @@ -2,7 +2,6 @@ //! and putting a limit on the total number of operators executed. use loupe::{MemoryUsage, MemoryUsageTracker}; -use loupe_derive::MemoryUsage; use std::convert::TryInto; use std::fmt; use std::mem; diff --git a/lib/vm/Cargo.toml b/lib/vm/Cargo.toml index 4d55a8625bf..cc12923e68b 100644 --- a/lib/vm/Cargo.toml +++ b/lib/vm/Cargo.toml @@ -21,8 +21,7 @@ more-asserts = "0.2" cfg-if = "0.1" backtrace = "0.3" serde = { version = "1.0", features = ["derive", "rc"] } -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] } diff --git a/lib/vm/src/sig_registry.rs b/lib/vm/src/sig_registry.rs index b0da474eb07..051006bc960 100644 --- a/lib/vm/src/sig_registry.rs +++ b/lib/vm/src/sig_registry.rs @@ -5,7 +5,7 @@ //! signature checking. use crate::vmcontext::VMSharedSignatureIndex; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use more_asserts::{assert_lt, debug_assert_lt}; use std::collections::{hash_map, HashMap}; use std::convert::TryFrom; diff --git a/lib/vm/src/vmcontext.rs b/lib/vm/src/vmcontext.rs index 7262be3cb50..929c1126f2d 100644 --- a/lib/vm/src/vmcontext.rs +++ b/lib/vm/src/vmcontext.rs @@ -9,7 +9,7 @@ use crate::instance::Instance; use crate::memory::Memory; use crate::table::Table; use crate::trap::{Trap, TrapCode}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::any::Any; use std::convert::TryFrom; use std::fmt; diff --git a/lib/wasmer-types/Cargo.toml b/lib/wasmer-types/Cargo.toml index 4a9ad93ab0c..8bff64a3dd7 100644 --- a/lib/wasmer-types/Cargo.toml +++ b/lib/wasmer-types/Cargo.toml @@ -13,8 +13,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", features = ["derive"], optional = true, default-features = false } thiserror = "1.0" -loupe = { path = "../../../loupe/crates/loupe" } -loupe-derive = { path = "../../../loupe/crates/loupe-derive" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [features] default = ["std", "enable-serde"] diff --git a/lib/wasmer-types/src/features.rs b/lib/wasmer-types/src/features.rs index a051bcfbdfc..4fc19564dcf 100644 --- a/lib/wasmer-types/src/features.rs +++ b/lib/wasmer-types/src/features.rs @@ -1,4 +1,4 @@ -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; diff --git a/lib/wasmer-types/src/indexes.rs b/lib/wasmer-types/src/indexes.rs index 06ba01caae7..ed5f320150d 100644 --- a/lib/wasmer-types/src/indexes.rs +++ b/lib/wasmer-types/src/indexes.rs @@ -1,7 +1,7 @@ //! Helper functions and structures for the translation. use crate::entity::entity_impl; use core::u32; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; diff --git a/lib/wasmer-types/src/types.rs b/lib/wasmer-types/src/types.rs index 3482d42a8cc..168f947616f 100644 --- a/lib/wasmer-types/src/types.rs +++ b/lib/wasmer-types/src/types.rs @@ -6,7 +6,7 @@ use crate::lib::std::string::{String, ToString}; use crate::lib::std::vec::Vec; use crate::units::Pages; use crate::values::Value; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; diff --git a/lib/wasmer-types/src/units.rs b/lib/wasmer-types/src/units.rs index 7030061675f..1d1360b60c9 100644 --- a/lib/wasmer-types/src/units.rs +++ b/lib/wasmer-types/src/units.rs @@ -1,7 +1,7 @@ use crate::lib::std::convert::TryFrom; use crate::lib::std::fmt; use crate::lib::std::ops::{Add, Sub}; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use std::convert::TryInto; diff --git a/tests/lib/engine-dummy/Cargo.toml b/tests/lib/engine-dummy/Cargo.toml index 3a81e5ef545..2a12de6d88e 100644 --- a/tests/lib/engine-dummy/Cargo.toml +++ b/tests/lib/engine-dummy/Cargo.toml @@ -15,8 +15,7 @@ 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" } +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [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 0135bd3919e..ca9b0c4a9c0 100644 --- a/tests/lib/engine-dummy/src/engine.rs +++ b/tests/lib/engine-dummy/src/engine.rs @@ -1,7 +1,7 @@ //! Dummy Engine. use crate::DummyArtifact; -use loupe_derive::MemoryUsage; +use loupe::MemoryUsage; use std::sync::Arc; use wasmer_compiler::{CompileError, Features, Target}; use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables}; From c212f74e1972566ebc62b9b79b2ca9c2fbf17740 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 22 Mar 2021 15:35:22 +0100 Subject: [PATCH 3/7] test: Implement `MemoryUsage` on test middlewares. --- Cargo.lock | 1 + Cargo.toml | 1 + tests/compilers/middlewares.rs | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ebaca6ac15..9ba2e51ebf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2701,6 +2701,7 @@ dependencies = [ "criterion", "glob", "lazy_static", + "loupe", "rustc_version 0.3.3", "tempfile", "test-generator", diff --git a/Cargo.toml b/Cargo.toml index 40fda1950f5..7bd6fe8427a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ criterion = "0.3" lazy_static = "1.4" wasmer-engine-dummy = { path = "tests/lib/engine-dummy" } tempfile = "3.1" +loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } [features] # Don't add the compiler features in default, please add them on the Makefile diff --git a/tests/compilers/middlewares.rs b/tests/compilers/middlewares.rs index 3a9e5516656..02eabc3738c 100644 --- a/tests/compilers/middlewares.rs +++ b/tests/compilers/middlewares.rs @@ -1,11 +1,12 @@ use crate::utils::get_store_with_middlewares; use anyhow::Result; +use loupe::MemoryUsage; use std::sync::Arc; use wasmer::wasmparser::Operator; use wasmer::*; -#[derive(Debug)] +#[derive(Debug, MemoryUsage)] struct Add2MulGen { value_off: i32, } @@ -47,7 +48,7 @@ impl FunctionMiddleware for Add2Mul { } } -#[derive(Debug)] +#[derive(Debug, MemoryUsage)] struct FusionGen; #[derive(Debug)] From 10c6f26770f8d185fd6acfe93809ecf5b0e6872e Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 22 Mar 2021 15:38:59 +0100 Subject: [PATCH 4/7] doc: Update the tunable exemple to include `MemoryUsage`. --- examples/tunables_limit_memory.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/tunables_limit_memory.rs b/examples/tunables_limit_memory.rs index ccd1ac773ac..14368249127 100644 --- a/examples/tunables_limit_memory.rs +++ b/examples/tunables_limit_memory.rs @@ -1,6 +1,8 @@ +use std::mem; use std::ptr::NonNull; use std::sync::Arc; +use loupe::{MemoryUsage, MemoryUsageTracker}; use wasmer::{ imports, vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition}, @@ -131,6 +133,12 @@ impl Tunables for LimitingTunables { } } +impl MemoryUsage for LimitingTunables { + fn size_of_val(&self, _tracker: &mut dyn MemoryUsageTracker) -> usize { + mem::size_of_val(self) + } +} + fn main() -> Result<(), Box> { // A Wasm module with one exported memory (min: 7 pages, max: unset) let wat = br#"(module (memory 7) (export "memory" (memory 0)))"#; From 1a2dbdaef6a438c72840a1af2c002c4e16f2968c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 23 Mar 2021 09:23:58 +0100 Subject: [PATCH 5/7] fix(engine-jit) Fix `MemoryUsage` on Windows. --- lib/engine-jit/src/unwind/windows_x64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/engine-jit/src/unwind/windows_x64.rs b/lib/engine-jit/src/unwind/windows_x64.rs index 1db1658acc7..7d9e017c851 100644 --- a/lib/engine-jit/src/unwind/windows_x64.rs +++ b/lib/engine-jit/src/unwind/windows_x64.rs @@ -118,7 +118,7 @@ impl MemoryUsage for UnwindRegistry { // [doc2]: https://docs.rs/winapi/0.3.9/winapi/um/winnt/struct._IMAGE_RUNTIME_FUNCTION_ENTRY.html self.functions .iter() - .map(|(key, _)| (key, std::mem::size_of::() * 3)) + .map(|(_, _)| std::mem::size_of::() * 3) .sum::() + self.published.size_of_val(tracker) } From 4b752ed498ecbdf6c3d196f7bdc097693dce41e0 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 23 Mar 2021 11:18:31 +0100 Subject: [PATCH 6/7] chore: Use `loupe` 0.1.0. --- Cargo.lock | 6 ++- Cargo.toml | 2 +- fuzz/Cargo.lock | 59 ++++++++++++++++++++++++------ lib/api/Cargo.toml | 2 +- lib/compiler-cranelift/Cargo.toml | 2 +- lib/compiler-llvm/Cargo.toml | 2 +- lib/compiler-singlepass/Cargo.toml | 2 +- lib/compiler/Cargo.toml | 2 +- lib/engine-jit/Cargo.toml | 2 +- lib/engine-native/Cargo.toml | 2 +- lib/engine-object-file/Cargo.toml | 2 +- lib/engine/Cargo.toml | 2 +- lib/middlewares/Cargo.toml | 2 +- lib/vm/Cargo.toml | 2 +- lib/wasmer-types/Cargo.toml | 2 +- tests/lib/engine-dummy/Cargo.toml | 2 +- 16 files changed, 66 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ba2e51ebf0..052da5f44dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,7 +1157,8 @@ dependencies = [ [[package]] name = "loupe" version = "0.1.0" -source = "git+https://github.com/wasmerio/loupe?branch=master#63c2f4a5acf1f3a8ed3568119cad96a731c71d21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0700ebea6c2a63815aa6f376f1c6dac93223d7b11c4728a7f71ff951a6eca67" dependencies = [ "loupe-derive", "rustversion", @@ -1166,7 +1167,8 @@ dependencies = [ [[package]] name = "loupe-derive" version = "0.1.0" -source = "git+https://github.com/wasmerio/loupe?branch=master#63c2f4a5acf1f3a8ed3568119cad96a731c71d21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9a2f753a29753600fa1e3f5c2b311babaca3bb66929bdc37082996e9c46cfb" dependencies = [ "quote", "syn", diff --git a/Cargo.toml b/Cargo.toml index 7bd6fe8427a..94c27a92e90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ criterion = "0.3" lazy_static = "1.4" wasmer-engine-dummy = { path = "tests/lib/engine-dummy" } tempfile = "3.1" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] # Don't add the compiler features in default, please add them on the Makefile diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 9d6af389f66..456f4fbf935 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +checksum = "81cddc5f91628367664cc7c69714ff08deee8a3efc54623011c772544d7b2767" [[package]] name = "arbitrary" @@ -454,9 +454,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" [[package]] name = "libfuzzer-sys" @@ -509,6 +509,26 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "loupe" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0700ebea6c2a63815aa6f376f1c6dac93223d7b11c4728a7f71ff951a6eca67" +dependencies = [ + "loupe-derive", + "rustversion", +] + +[[package]] +name = "loupe-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9a2f753a29753600fa1e3f5c2b311babaca3bb66929bdc37082996e9c46cfb" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "mach" version = "0.3.2" @@ -822,6 +842,12 @@ dependencies = [ "semver 0.9.0", ] +[[package]] +name = "rustversion" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" + [[package]] name = "scopeguard" version = "1.1.0" @@ -883,9 +909,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] @@ -901,9 +927,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -1038,7 +1064,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-encoder" version = "0.4.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#ea17086f38b3bd452a99340109bfdc9759f109a1" +source = "git+https://github.com/bytecodealliance/wasm-tools#4e86f2a84fc54264388040b200eb32a165ec6453" dependencies = [ "leb128", ] @@ -1046,7 +1072,7 @@ dependencies = [ [[package]] name = "wasm-smith" version = "0.4.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#ea17086f38b3bd452a99340109bfdc9759f109a1" +source = "git+https://github.com/bytecodealliance/wasm-tools#4e86f2a84fc54264388040b200eb32a165ec6453" dependencies = [ "arbitrary", "indexmap", @@ -1060,6 +1086,7 @@ version = "1.0.2" dependencies = [ "cfg-if 0.1.10", "indexmap", + "loupe", "more-asserts", "target-lexicon", "thiserror", @@ -1096,6 +1123,7 @@ name = "wasmer-compiler" version = "1.0.2" dependencies = [ "enumset", + "loupe", "serde", "serde_bytes", "smallvec", @@ -1111,8 +1139,10 @@ name = "wasmer-compiler-cranelift" version = "1.0.2" dependencies = [ "cranelift-codegen", + "cranelift-entity", "cranelift-frontend", "gimli", + "loupe", "more-asserts", "rayon", "serde", @@ -1134,6 +1164,7 @@ dependencies = [ "itertools", "lazy_static", "libc", + "loupe", "rayon", "regex", "rustc_version", @@ -1153,6 +1184,7 @@ dependencies = [ "dynasm", "dynasmrt", "lazy_static", + "loupe", "more-asserts", "rayon", "serde", @@ -1179,6 +1211,7 @@ dependencies = [ "backtrace", "bincode", "lazy_static", + "loupe", "memmap2", "more-asserts", "rustc-demangle", @@ -1197,6 +1230,7 @@ version = "1.0.2" dependencies = [ "bincode", "cfg-if 0.1.10", + "loupe", "region", "serde", "serde_bytes", @@ -1215,6 +1249,7 @@ dependencies = [ "cfg-if 0.1.10", "leb128", "libloading", + "loupe", "serde", "tempfile", "tracing", @@ -1230,6 +1265,7 @@ dependencies = [ name = "wasmer-middlewares" version = "1.0.2" dependencies = [ + "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1249,7 +1285,7 @@ dependencies = [ name = "wasmer-types" version = "1.0.2" dependencies = [ - "cranelift-entity", + "loupe", "serde", "thiserror", ] @@ -1263,6 +1299,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", + "loupe", "memoffset", "more-asserts", "region", diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index f69280e6d55..817061f0d26 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -27,7 +27,7 @@ wat = { version = "1.0", optional = true } thiserror = "1.0" more-asserts = "0.2" target-lexicon = { version = "0.11", default-features = false } -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [target.'cfg(target_os = "windows")'.dependencies] winapi = "0.3" diff --git a/lib/compiler-cranelift/Cargo.toml b/lib/compiler-cranelift/Cargo.toml index cb0d3630d72..c5ec84b033d 100644 --- a/lib/compiler-cranelift/Cargo.toml +++ b/lib/compiler-cranelift/Cargo.toml @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] } more-asserts = "0.2" gimli = { version = "0.23", optional = true } smallvec = "1.6" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler-llvm/Cargo.toml b/lib/compiler-llvm/Cargo.toml index d6aac52fa35..04052feaf6b 100644 --- a/lib/compiler-llvm/Cargo.toml +++ b/lib/compiler-llvm/Cargo.toml @@ -22,7 +22,7 @@ libc = { version = "^0.2", default-features = false } byteorder = "1" itertools = "0.10" rayon = "1.5" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [dependencies.inkwell] version = "=0.1.0-beta.2" diff --git a/lib/compiler-singlepass/Cargo.toml b/lib/compiler-singlepass/Cargo.toml index ede05f8bb56..9af24654b94 100644 --- a/lib/compiler-singlepass/Cargo.toml +++ b/lib/compiler-singlepass/Cargo.toml @@ -24,7 +24,7 @@ dynasmrt = "1.0" lazy_static = "1.4" byteorder = "1.3" smallvec = "1.6" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [dev-dependencies] target-lexicon = { version = "0.11", default-features = false } diff --git a/lib/compiler/Cargo.toml b/lib/compiler/Cargo.toml index 579f7814ed0..1c39419632c 100644 --- a/lib/compiler/Cargo.toml +++ b/lib/compiler/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } thiserror = "1.0" serde_bytes = { version = "0.11", optional = true } smallvec = "1.6" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] default = ["std", "enable-serde"] diff --git a/lib/engine-jit/Cargo.toml b/lib/engine-jit/Cargo.toml index 38b70474e25..9d54965d433 100644 --- a/lib/engine-jit/Cargo.toml +++ b/lib/engine-jit/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" cfg-if = "0.1" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winnt", "impl-default"] } diff --git a/lib/engine-native/Cargo.toml b/lib/engine-native/Cargo.toml index be045b7a4df..3e69503a13c 100644 --- a/lib/engine-native/Cargo.toml +++ b/lib/engine-native/Cargo.toml @@ -24,7 +24,7 @@ leb128 = "0.2" libloading = "0.7" tempfile = "3.1" which = "4.0" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] # Enable the `compiler` feature if you want the engine to compile diff --git a/lib/engine-object-file/Cargo.toml b/lib/engine-object-file/Cargo.toml index 17ee1e01661..51defdb94e2 100644 --- a/lib/engine-object-file/Cargo.toml +++ b/lib/engine-object-file/Cargo.toml @@ -23,7 +23,7 @@ bincode = "1.3" leb128 = "0.2" libloading = "0.7" tempfile = "3.1" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] # Enable the `compiler` feature if you want the engine to compile diff --git a/lib/engine/Cargo.toml b/lib/engine/Cargo.toml index a8ae21becf7..8cd8c2f5469 100644 --- a/lib/engine/Cargo.toml +++ b/lib/engine/Cargo.toml @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive", "rc"] } serde_bytes = { version = "0.11" } bincode = "1.3" lazy_static = "1.4" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [badges] maintenance = { status = "actively-developed" } diff --git a/lib/middlewares/Cargo.toml b/lib/middlewares/Cargo.toml index 5fd6837df79..3cf6cca7629 100644 --- a/lib/middlewares/Cargo.toml +++ b/lib/middlewares/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" wasmer = { path = "../api", version = "1.0.2" } wasmer-types = { path = "../wasmer-types", version = "1.0.2" } wasmer-vm = { path = "../vm", version = "1.0.2" } -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [badges] maintenance = { status = "actively-developed" } diff --git a/lib/vm/Cargo.toml b/lib/vm/Cargo.toml index cc12923e68b..a721dc1157b 100644 --- a/lib/vm/Cargo.toml +++ b/lib/vm/Cargo.toml @@ -21,7 +21,7 @@ more-asserts = "0.2" cfg-if = "0.1" backtrace = "0.3" serde = { version = "1.0", features = ["derive", "rc"] } -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] } diff --git a/lib/wasmer-types/Cargo.toml b/lib/wasmer-types/Cargo.toml index 8bff64a3dd7..340c0fe196c 100644 --- a/lib/wasmer-types/Cargo.toml +++ b/lib/wasmer-types/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", features = ["derive"], optional = true, default-features = false } thiserror = "1.0" -loupe = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] default = ["std", "enable-serde"] diff --git a/tests/lib/engine-dummy/Cargo.toml b/tests/lib/engine-dummy/Cargo.toml index 2a12de6d88e..01a50903a95 100644 --- a/tests/lib/engine-dummy/Cargo.toml +++ b/tests/lib/engine-dummy/Cargo.toml @@ -15,7 +15,7 @@ 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 = { git = "https://github.com/wasmerio/loupe", branch = "master" } +loupe = "0.1" [features] # Enable the `compiler` feature if you want the engine to compile From 0fe618a803b3ad07a8782bd724506b7c5ffd50c9 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 23 Mar 2021 11:19:57 +0100 Subject: [PATCH 7/7] doc(changelog) Add #2199. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 258168311ec..4086e134e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers ### Changed +- [#2199](https://github.com/wasmerio/wasmer/pull/2199) Implement `loupe::MemoryUsage` for `wasmer::Store`. - [#2140](https://github.com/wasmerio/wasmer/pull/2140) Reduce the number of dependencies in the `wasmer.dll` shared library by statically compiling CRT. - [#2113](https://github.com/wasmerio/wasmer/pull/2113) Bump minimum supported Rust version to 1.49 - [#2144](https://github.com/wasmerio/wasmer/pull/2144) Bump cranelift version to 0.70