Skip to content

Commit

Permalink
Remove loupe dependency
Browse files Browse the repository at this point in the history
Closes #2731
Closes #2744
  • Loading branch information
epilys committed May 4, 2022
1 parent fd32ade commit 30a09a0
Show file tree
Hide file tree
Showing 90 changed files with 116 additions and 454 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C

## **Unreleased**

### Changed
- ##### Removed loupe crate dependency

### Fixed
- [#2829](https://github.com/wasmerio/wasmer/pull/2829) Improve error message oriented from JS object.
- [#2828](https://github.com/wasmerio/wasmer/pull/2828) Fix JsImportObject resolver.
Expand Down
35 changes: 0 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ serial_test = "0.5"
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
compiler-test-derive = { path = "tests/lib/compiler-test-derive" }
tempfile = "3.1"
loupe = "0.1"
# For logging tests using the `RUST_LOG=debug` when testing
test-log = { version = "0.2", default-features = false, features = ["trace"] }
tracing = { version = "0.1", default-features = false, features = ["log"] }
Expand Down
2 changes: 0 additions & 2 deletions examples/tunables_limit_memory.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::ptr::NonNull;
use std::sync::Arc;

use loupe::MemoryUsage;
use wasmer::{
imports,
vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition},
Expand All @@ -15,7 +14,6 @@ use wasmer_engine_universal::Universal;
///
/// After adjusting the memory limits, it delegates all other logic
/// to the base tunables.
#[derive(MemoryUsage)]
pub struct LimitingTunables<T: Tunables> {
/// The maximum a linear memory is allowed to be (in Wasm pages, 64 KiB each).
/// Since Wasmer ensures there is only none or one memory, this is practically
Expand Down
1 change: 0 additions & 1 deletion lib/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ wasmer-derive = { path = "../derive", version = "=2.2.1" }
wasmer-engine = { path = "../engine", version = "=2.2.1" }
wasmer-types = { path = "../types", version = "=2.2.1" }
target-lexicon = { version = "0.12.2", default-features = false }
loupe = "0.1"
# - Optional dependencies for `sys`.
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "=2.2.1", optional = true }
wasmer-compiler-cranelift = { path = "../compiler-cranelift", version = "=2.2.1", optional = true }
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::sys::externals::{Extern, Function, Global, Memory, Table};
use crate::sys::native::NativeFunc;
use crate::sys::WasmTypeList;
use indexmap::IndexMap;
use loupe::MemoryUsage;
use std::fmt;
use std::iter::{ExactSizeIterator, FromIterator};
use thiserror::Error;
Expand Down Expand Up @@ -60,7 +59,7 @@ pub enum ExportError {
/// the types of instances.
///
/// TODO: add examples of using exports
#[derive(Clone, Default, MemoryUsage)]
#[derive(Clone, Default)]
pub struct Exports {
map: IndexMap<String, Extern>,
}
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/externals/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::sys::RuntimeError;
use crate::sys::WasmerEnv;
pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv};

use loupe::MemoryUsage;
use std::cmp::max;
use std::ffi::c_void;
use std::fmt;
Expand Down Expand Up @@ -37,7 +36,7 @@ use wasmer_vm::{
/// with native functions. Attempting to create a native `Function` with one will
/// result in a panic.
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
#[derive(PartialEq, MemoryUsage)]
#[derive(PartialEq)]
pub struct Function {
pub(crate) store: Store,
pub(crate) exported: ExportFunction,
Expand Down
2 changes: 0 additions & 2 deletions lib/api/src/sys/externals/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::sys::types::Val;
use crate::sys::GlobalType;
use crate::sys::Mutability;
use crate::sys::RuntimeError;
use loupe::MemoryUsage;
use std::fmt;
use std::sync::Arc;
use wasmer_engine::Export;
Expand All @@ -17,7 +16,6 @@ use wasmer_vm::{Global as RuntimeGlobal, VMGlobal};
/// It consists of an individual value and a flag indicating whether it is mutable.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#global-instances>
#[derive(MemoryUsage)]
pub struct Global {
store: Store,
vm_global: VMGlobal,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::sys::externals::Extern;
use crate::sys::store::Store;
use crate::sys::MemoryType;
use crate::MemoryAccessError;
use loupe::MemoryUsage;
use std::convert::TryInto;
use std::mem;
use std::mem::MaybeUninit;
Expand All @@ -27,7 +26,7 @@ use wasmer_vm::{MemoryError, VMMemory};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
#[derive(Debug, MemoryUsage)]
#[derive(Debug)]
pub struct Memory {
store: Store,
vm_memory: VMMemory,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/externals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ pub use self::table::Table;
use crate::sys::exports::{ExportError, Exportable};
use crate::sys::store::{Store, StoreObject};
use crate::sys::ExternType;
use loupe::MemoryUsage;
use std::fmt;
use wasmer_engine::Export;

/// An `Extern` is the runtime representation of an entity that
/// can be imported or exported.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
#[derive(Clone, MemoryUsage)]
#[derive(Clone)]
pub enum Extern {
/// A external [`Function`].
Function(Function),
Expand Down
2 changes: 0 additions & 2 deletions lib/api/src/sys/externals/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::sys::store::Store;
use crate::sys::types::{Val, ValFuncRef};
use crate::sys::RuntimeError;
use crate::sys::TableType;
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_engine::Export;
use wasmer_vm::{Table as RuntimeTable, TableElement, VMTable};
Expand All @@ -18,7 +17,6 @@ use wasmer_vm::{Table as RuntimeTable, TableElement, VMTable};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
#[derive(MemoryUsage)]
pub struct Table {
store: Store,
vm_table: VMTable,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::sys::imports::Imports;
use crate::sys::module::Module;
use crate::sys::store::Store;
use crate::sys::{HostEnvInitError, LinkError, RuntimeError};
use loupe::MemoryUsage;
use std::fmt;
use std::sync::{Arc, Mutex};
use thiserror::Error;
Expand All @@ -18,7 +17,7 @@ use wasmer_vm::{InstanceHandle, VMContext};
/// interacting with WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
#[derive(Clone, MemoryUsage)]
#[derive(Clone)]
pub struct Instance {
handle: Arc<Mutex<InstanceHandle>>,
module: Module,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::sys::exports::Exportable;
use crate::sys::store::Store;
use crate::sys::types::{ExportType, ImportType};
use crate::sys::InstantiationError;
use loupe::MemoryUsage;
use std::fmt;
use std::io;
use std::path::Path;
Expand Down Expand Up @@ -33,7 +32,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, MemoryUsage)]
#[derive(Clone)]
pub struct Module {
// The field ordering here is actually significant because of the drop
// order: we want to drop the artifact before dropping the engine.
Expand Down
4 changes: 1 addition & 3 deletions lib/api/src/sys/store.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::sys::tunables::BaseTunables;
use loupe::MemoryUsage;
use std::fmt;
use std::sync::{Arc, RwLock};
#[cfg(all(feature = "compiler", feature = "engine"))]
Expand All @@ -17,11 +16,10 @@ use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn};
/// [`Tunables`] (that are used to create the memories, tables and globals).
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
#[derive(Clone, MemoryUsage)]
#[derive(Clone)]
pub struct Store {
engine: Arc<dyn Engine + Send + Sync>,
tunables: Arc<dyn Tunables + Send + Sync>,
#[loupe(skip)]
trap_handler: Arc<RwLock<Option<Box<TrapHandlerFn>>>>,
}

Expand Down
3 changes: 1 addition & 2 deletions lib/api/src/sys/tunables.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::sys::{MemoryType, Pages, TableType};
use loupe::MemoryUsage;
use std::ptr::NonNull;
use std::sync::Arc;
use target_lexicon::PointerWidth;
Expand All @@ -19,7 +18,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, MemoryUsage)]
#[derive(Clone)]
pub struct BaseTunables {
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
pub static_memory_bound: Pages,
Expand Down
1 change: 0 additions & 1 deletion lib/compiler-cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rayon = "1.5"
more-asserts = "0.2"
gimli = { version = "0.26", optional = true }
smallvec = "1.6"
loupe = "0.1"
target-lexicon = { version = "0.12.2", default-features = false }

[dev-dependencies]
Expand Down
2 changes: 0 additions & 2 deletions lib/compiler-cranelift/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use cranelift_codegen::{ir, MachReloc};
use cranelift_codegen::{Context, MachTrap};
#[cfg(feature = "unwind")]
use gimli::write::{Address, EhFrame, FrameTable};
use loupe::MemoryUsage;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use std::sync::Arc;
use wasmer_compiler::{
Expand All @@ -37,7 +36,6 @@ use wasmer_vm::TrapCode;

/// 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,
}
Expand Down
5 changes: 2 additions & 3 deletions lib/compiler-cranelift/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::compiler::CraneliftCompiler;
use cranelift_codegen::isa::{lookup, TargetIsa};
use cranelift_codegen::settings::{self, Configurable};
use cranelift_codegen::CodegenResult;
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_compiler::{
Architecture, Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target,
Expand All @@ -12,7 +11,7 @@ use wasmer_compiler::{

/// Possible optimization levels for the Cranelift codegen backend.
#[non_exhaustive]
#[derive(Clone, Debug, MemoryUsage)]
#[derive(Clone, Debug)]
pub enum CraneliftOptLevel {
/// No optimizations performed, minimizes compilation time by disabling most
/// optimizations.
Expand All @@ -29,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, MemoryUsage)]
#[derive(Debug, Clone)]
pub struct Cranelift {
enable_nan_canonicalization: bool,
enable_verifier: bool,
Expand Down
Loading

0 comments on commit 30a09a0

Please sign in to comment.