Skip to content

Commit

Permalink
Merge #2199
Browse files Browse the repository at this point in the history
2199: feat: Implement `MemoryUsage` for `Store` r=Hywan a=Hywan

# Description

This patch implements `loupe::MemoryUsage` for `wasmer::Store`.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Ivan Enderlin <[email protected]>
  • Loading branch information
bors[bot] and Hywan authored Mar 23, 2021
2 parents e46c397 + 5ff82e5 commit af59fcb
Show file tree
Hide file tree
Showing 48 changed files with 265 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 58 additions & 34 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ criterion = "0.3"
lazy_static = "1.4"
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
tempfile = "3.1"
loupe = "0.1"

[features]
# Don't add the compiler features in default, please add them on the Makefile
Expand Down
8 changes: 8 additions & 0 deletions examples/tunables_limit_memory.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -131,6 +133,12 @@ impl<T: Tunables> Tunables for LimitingTunables<T> {
}
}

impl<T: Tunables> MemoryUsage for LimitingTunables<T> {
fn size_of_val(&self, _tracker: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
}
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
// A Wasm module with one exported memory (min: 7 pages, max: unset)
let wat = br#"(module (memory 7) (export "memory" (memory 0)))"#;
Expand Down
Loading

0 comments on commit af59fcb

Please sign in to comment.