Merge branch 'master' into feature/reference-types

This commit is contained in:
Mark McCaskey
2021-03-23 09:42:34 -07:00
97 changed files with 1111 additions and 178 deletions

View File

@@ -18,6 +18,9 @@
- [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers
### Changed
- [#2201](https://github.com/wasmerio/wasmer/pull/2201) Implement `loupe::MemoryUsage` for `wasmer::Instance`.
- [#2200](https://github.com/wasmerio/wasmer/pull/2200) Implement `loupe::MemoryUsage` for `wasmer::Module`.
- [#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

93
Cargo.lock generated
View File

@@ -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,27 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "loupe"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1acf065b51eb58abbc66a07c27ec63142205d339a9f5093dc3e1d7cda3d5c9a3"
dependencies = [
"indexmap",
"loupe-derive",
"rustversion",
]
[[package]]
name = "loupe-derive"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e40881c741681f26b0f4c0261f493c8df600998807184b524e34b7e208324834"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "mach"
version = "0.3.2"
@@ -1372,9 +1393,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 +1414,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 +1648,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 +1668,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 +1845,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 +1873,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 +1942,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 +2061,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 +2105,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 +2131,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 +2306,7 @@ dependencies = [
"cfg-if 0.1.10",
"indexmap",
"libc",
"loupe",
"more-asserts",
"target-lexicon",
"tempfile",
@@ -2390,6 +2402,7 @@ version = "1.0.2"
dependencies = [
"enumset",
"hashbrown",
"loupe",
"serde",
"serde_bytes",
"smallvec",
@@ -2410,6 +2423,7 @@ dependencies = [
"gimli",
"hashbrown",
"lazy_static",
"loupe",
"more-asserts",
"rayon",
"serde",
@@ -2432,6 +2446,7 @@ dependencies = [
"itertools 0.10.0",
"lazy_static",
"libc",
"loupe",
"rayon",
"regex",
"rustc_version 0.2.3",
@@ -2452,6 +2467,7 @@ dependencies = [
"dynasmrt",
"hashbrown",
"lazy_static",
"loupe",
"more-asserts",
"rayon",
"serde",
@@ -2494,6 +2510,7 @@ dependencies = [
"backtrace",
"bincode",
"lazy_static",
"loupe",
"memmap2",
"more-asserts",
"rustc-demangle",
@@ -2511,6 +2528,7 @@ name = "wasmer-engine-dummy"
version = "1.0.2"
dependencies = [
"bincode",
"loupe",
"serde",
"serde_bytes",
"wasmer-compiler",
@@ -2525,6 +2543,7 @@ version = "1.0.2"
dependencies = [
"bincode",
"cfg-if 0.1.10",
"loupe",
"region",
"serde",
"serde_bytes",
@@ -2543,6 +2562,7 @@ dependencies = [
"cfg-if 0.1.10",
"leb128",
"libloading",
"loupe",
"serde",
"tempfile",
"tracing",
@@ -2562,6 +2582,7 @@ dependencies = [
"cfg-if 0.1.10",
"leb128",
"libloading",
"loupe",
"serde",
"tempfile",
"tracing",
@@ -2584,6 +2605,7 @@ dependencies = [
name = "wasmer-middlewares"
version = "1.0.2"
dependencies = [
"loupe",
"wasmer",
"wasmer-types",
"wasmer-vm",
@@ -2603,6 +2625,7 @@ dependencies = [
name = "wasmer-types"
version = "1.0.2"
dependencies = [
"loupe",
"serde",
"thiserror",
]
@@ -2616,6 +2639,7 @@ dependencies = [
"cfg-if 0.1.10",
"indexmap",
"libc",
"loupe",
"memoffset",
"more-asserts",
"region",
@@ -2680,6 +2704,7 @@ dependencies = [
"criterion",
"glob",
"lazy_static",
"loupe",
"rustc_version 0.3.3",
"tempfile",
"test-generator",

View File

@@ -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

View File

@@ -29,6 +29,8 @@
[Wasmer](https://wasmer.io/) enables super lightweight containers based on [WebAssembly](https://webassembly.org/) that can run anywhere: from Desktop to the Cloud and IoT devices, and also embedded in [*any programming language*](https://github.com/wasmerio/wasmer#language-integrations).
> This readme is also available in: [🇨🇳 中文-Chinese](https://github.com/wasmerio/wasmer/blob/master/docs/cn/README.md) • [🇪🇸 Español-Spanish](https://github.com/wasmerio/wasmer/blob/master/docs/es/README.md) • [🇫🇷 Français-French](https://github.com/wasmerio/wasmer/blob/master/docs/es/README.md).
## Features
* **Fast & Safe**. Wasmer runs WebAssembly at *near-native* speed in a fully sandboxed environment.
@@ -103,66 +105,66 @@ qjs >
[👋 Missing a language?](https://github.com/wasmerio/wasmer/issues/new?assignees=&labels=%F0%9F%8E%89+enhancement&template=---feature-request.md&title=)
[rust logo]: ./assets/languages/rust.svg
[rust logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/rust.svg
[rust integration]: https://github.com/wasmerio/wasmer/tree/master/lib/api
[`wasmer` rust crate]: https://crates.io/crates/wasmer/
[rust docs]: https://wasmerio.github.io/wasmer/crates/wasmer_runtime
[c logo]: ./assets/languages/c.svg
[c logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/c.svg
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
[`wasmer.h` headers]: https://wasmerio.github.io/wasmer/c/
[c docs]: https://wasmerio.github.io/wasmer/c/
[c# logo]: ./assets/languages/csharp.svg
[c# logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/csharp.svg
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
[`wasmersharp` nuget package]: https://www.nuget.org/packages/WasmerSharp/
[c# docs]: https://migueldeicaza.github.io/WasmerSharp/
[d logo]: ./assets/languages/d.svg
[d logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/d.svg
[d integration]: https://github.com/chances/wasmer-d
[`wasmer` Dub package]: https://code.dlang.org/packages/wasmer
[d docs]: https://chances.github.io/wasmer-d
[python logo]: ./assets/languages/python.svg
[python logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/python.svg
[python integration]: https://github.com/wasmerio/wasmer-python
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
[python docs]: https://github.com/wasmerio/wasmer-python#api-of-the-wasmer-extensionmodule
[go logo]: ./assets/languages/go.svg
[go logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/go.svg
[go integration]: https://github.com/wasmerio/wasmer-go
[`wasmer` go package]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer
[go docs]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer?tab=doc
[php logo]: ./assets/languages/php.svg
[php logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/php.svg
[php integration]: https://github.com/wasmerio/wasmer-php
[`wasm` pecl package]: https://pecl.php.net/package/wasm
[php docs]: https://wasmerio.github.io/wasmer-php/wasm/
[js logo]: ./assets/languages/js.svg
[js logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/js.svg
[js integration]: https://github.com/wasmerio/wasmer-js
[`@wasmerio` npm packages]: https://www.npmjs.com/org/wasmer
[js docs]: https://docs.wasmer.io/integrations/js/reference-api
[ruby logo]: ./assets/languages/ruby.svg
[ruby logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/ruby.svg
[ruby integration]: https://github.com/wasmerio/wasmer-ruby
[`wasmer` ruby gem]: https://rubygems.org/gems/wasmer
[ruby docs]: https://www.rubydoc.info/gems/wasmer/
[java logo]: ./assets/languages/java.svg
[java logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/java.svg
[java integration]: https://github.com/wasmerio/wasmer-java
[`wasmer/wasmer-jni` bintray package]: https://bintray.com/wasmer/wasmer-jni/wasmer-jni
[java docs]: https://github.com/wasmerio/wasmer-java/#api-of-the-wasmer-library
[elixir logo]: ./assets/languages/elixir.svg
[elixir logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/elixir.svg
[elixir integration]: https://github.com/tessi/wasmex
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
[`wasmex` hex package]: https://hex.pm/packages/wasmex
[r logo]: ./assets/languages/r.svg
[r logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/r.svg
[r integration]: https://github.com/dirkschumacher/wasmr
[r docs]: https://github.com/dirkschumacher/wasmr#example
[postgres logo]: ./assets/languages/postgres.svg
[postgres logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/postgres.svg
[postgres integration]: https://github.com/wasmerio/wasmer-postgres
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation

192
docs/cn/README.md Normal file
View File

@@ -0,0 +1,192 @@
<div align="center">
<a href="https://wasmer.io" target="_blank" rel="noopener noreferrer">
<img width="300" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/logo.png" alt="Wasmer logo">
</a>
<p>
<a href="https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild">
<img src="https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square" alt="Build Status">
</a>
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square" alt="License">
</a>
<a href="https://slack.wasmer.io">
<img src="https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square" alt="Slack channel">
</a>
</p>
<h3>
<a href="https://wasmer.io/">网站</a>
<span></span>
<a href="https://docs.wasmer.io">文件资料</a>
<span></span>
<a href="https://slack.wasmer.io/">聊天</a>
</h3>
</div>
<br />
[Wasmer](https://wasmer.io/) 使得能够基于 [WebAssembly](https://webassembly.org/)其可以在任何地方运行超轻型容器从桌面到云和的IoT装置并且也嵌入在 [*任何编程语言*](https://github.com/wasmerio/wasmer#language-integrations).
> This readme is also available in: [🇬🇧 English-英文](https://github.com/wasmerio/wasmer/blob/master/README.md) • [🇪🇸 Español-西班牙语](https://github.com/wasmerio/wasmer/blob/master/docs/es/README.md) • [🇫🇷 Français-法语/法语](https://github.com/wasmerio/wasmer/blob/master/docs/es/README.md).
## 特征
* **快速又安全**. Wasmer 在完全沙盒化的环境中以“接近本机”的速度运行 WebAssembly。
* **可插拔**. Wasmer支持不同的编译框架以最适合您的需求LLVMCranelift ...).
* **普遍的**. 您可以在任何*平台*macOSLinux和Windows和*芯片组*中运行Wasmer.
* **符合标准**. 运行时通过了[官方WebAssembly测试
套件](https://github.com/WebAssembly/testsuite) 支持[WASI](https://github.com/WebAssembly/WASI) 和[Emscripten](https://emscripten.org/).
## 快速开始
Wasmer出厂时没有任何依赖关系. 您可以使用以下安装程序进行安装:
```sh
curl https://get.wasmer.io -sSfL | sh
```
<details>
<summary>使用Powershell (Windows)</summary>
<p>
```powershell
iwr https://win.wasmer.io -useb | iex
```
</p>
</details>
> 有关更多安装选项,请参见 [wasmer-install](https://github.com/wasmerio/wasmer-install): Homebrew, Scoop, Cargo...
#### 执行WebAssembly文件
安装Wasmer之后您应该已经准备好执行第一个WebAssemby文件! 🎉
您可以通过运行QuickJS开始: [qjs.wasm](https://registry-cdn.wapm.io/contents/_/quickjs/0.0.3/build/qjs.wasm)
```bash
$ wasmer qjs.wasm
QuickJS - Type "\h" for help
qjs >
```
#### 接下来是您可以做的:
- [在您的Rust应用程序中使用Wasmer](https://docs.wasmer.io/integrations/rust)
- [在WAPM上发布Wasm程序包](https://docs.wasmer.io/ecosystem/wapm/publishing-your-package)
- [阅读有关Wasmer的更多信息](https://medium.com/wasmer/)
## 语言整合
📦 Wasmer运行时可以用作**以不同语言嵌入的库**因此您可以在任何位置使用WebAssembly.
| &nbsp; | 语言 | 箱 | 文件资料 |
|-|-|-|-|
| ![Rust logo] | [**Rust**][Rust integration] | [`wasmer` Rust crate] | [文件资料][rust docs]
| ![C logo] | [**C/C++**][C integration] | [`wasmer.h` headers] | [文件资料][c docs] |
| ![C# logo] | [**C#**][C# integration] | [`WasmerSharp` NuGet package] | [文件资料][c# docs] |
| ![D logo] | [**D**][D integration] | [`wasmer` Dub package] | [文件资料][d docs] |
| ![Python logo] | [**Python**][Python integration] | [`wasmer` PyPI package] | [文件资料][python docs] |
| ![JS logo] | [**Javascript**][JS integration] | [`@wasmerio` NPM packages] | [文件资料][js docs] |
| ![Go logo] | [**Go**][Go integration] | [`wasmer` Go package] | [文件资料][go docs] |
| ![PHP logo] | [**PHP**][PHP integration] | [`wasm` PECL package] | [文件资料][php docs] |
| ![Ruby logo] | [**Ruby**][Ruby integration] | [`wasmer` Ruby Gem] | [文件资料][ruby docs] |
| ![Java logo] | [**Java**][Java integration] | [`wasmer/wasmer-jni` Bintray package] | [文件资料][java docs] |
| ![Elixir logo] | [**Elixir**][Elixir integration] | [`wasmex` hex package] | [文件资料][elixir docs] |
| ![R logo] | [**R**][R integration] | *没有已发布的软件包* | [文件资料][r docs] |
| ![Postgres logo] | [**Postgres**][Postgres integration] | *没有已发布的软件包* | [文件资料][postgres docs] |
| | [**Swift**][Swift integration] | *没有已发布的软件包* | |
[👋 缺少语言?](https://github.com/wasmerio/wasmer/issues/new?assignees=&labels=%F0%9F%8E%89+enhancement&template=---feature-request.md&title=)
[rust logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/rust.svg
[rust integration]: https://github.com/wasmerio/wasmer/tree/master/lib/api
[`wasmer` rust crate]: https://crates.io/crates/wasmer/
[rust docs]: https://wasmerio.github.io/wasmer/crates/wasmer_runtime
[c logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/c.svg
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
[`wasmer.h` headers]: https://wasmerio.github.io/wasmer/c/
[c docs]: https://wasmerio.github.io/wasmer/c/
[c# logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/csharp.svg
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
[`wasmersharp` nuget package]: https://www.nuget.org/packages/WasmerSharp/
[c# docs]: https://migueldeicaza.github.io/WasmerSharp/
[d logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/d.svg
[d integration]: https://github.com/chances/wasmer-d
[`wasmer` Dub package]: https://code.dlang.org/packages/wasmer
[d docs]: https://chances.github.io/wasmer-d
[python logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/python.svg
[python integration]: https://github.com/wasmerio/wasmer-python
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
[python docs]: https://github.com/wasmerio/wasmer-python#api-of-the-wasmer-extensionmodule
[go logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/go.svg
[go integration]: https://github.com/wasmerio/wasmer-go
[`wasmer` go package]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer
[go docs]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer?tab=doc
[php logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/php.svg
[php integration]: https://github.com/wasmerio/wasmer-php
[`wasm` pecl package]: https://pecl.php.net/package/wasm
[php docs]: https://wasmerio.github.io/wasmer-php/wasm/
[js logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/js.svg
[js integration]: https://github.com/wasmerio/wasmer-js
[`@wasmerio` npm packages]: https://www.npmjs.com/org/wasmer
[js docs]: https://docs.wasmer.io/integrations/js/reference-api
[ruby logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/ruby.svg
[ruby integration]: https://github.com/wasmerio/wasmer-ruby
[`wasmer` ruby gem]: https://rubygems.org/gems/wasmer
[ruby docs]: https://www.rubydoc.info/gems/wasmer/
[java logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/java.svg
[java integration]: https://github.com/wasmerio/wasmer-java
[`wasmer/wasmer-jni` bintray package]: https://bintray.com/wasmer/wasmer-jni/wasmer-jni
[java docs]: https://github.com/wasmerio/wasmer-java/#api-of-the-wasmer-library
[elixir logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/elixir.svg
[elixir integration]: https://github.com/tessi/wasmex
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
[`wasmex` hex package]: https://hex.pm/packages/wasmex
[r logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/r.svg
[r integration]: https://github.com/dirkschumacher/wasmr
[r docs]: https://github.com/dirkschumacher/wasmr#example
[postgres logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/postgres.svg
[postgres integration]: https://github.com/wasmerio/wasmer-postgres
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation
[swift integration]: https://github.com/AlwaysRightInstitute/SwiftyWasmer
## 贡献
**我们欢迎任何形式的贡献,尤其是来自社区新成员的贡献** 💜
您可以在[我们的出色文档](https://docs.wasmer.io/ecosystem/wasmer/building-from-source) 中检查如何构建Wasmer运行时!
### 测试
要测试吗? The [Wasmer文档将向您展示如何](https://docs.wasmer.io/ecosystem/wasmer/building-from-source/testing).
## 社区
Wasmer拥有一个了不起的开发人员和贡献者社区。 欢迎您,请加入我们! 👋
### 频道
- [Slack](https://slack.wasmer.io/)
- [Twitter](https://twitter.com/wasmerio)
- [Facebook](https://www.facebook.com/wasmerio)
- [Email](mailto:hello@wasmer.io)

191
docs/es/README.md Normal file
View File

@@ -0,0 +1,191 @@
<div align="center">
<a href="https://wasmer.io" target="_blank" rel="noopener noreferrer">
<img width="300" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/logo.png" alt="Wasmer logo">
</a>
<p>
<a href="https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild">
<img src="https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square" alt="Build Status">
</a>
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square" alt="License">
</a>
<a href="https://slack.wasmer.io">
<img src="https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square" alt="Slack channel">
</a>
</p>
<h3>
<a href="https://wasmer.io/">Web</a>
<span></span>
<a href="https://docs.wasmer.io">Documentación</a>
<span></span>
<a href="https://slack.wasmer.io/">Chat</a>
</h3>
</div>
<br />
[Wasmer](https://wasmer.io/) hace posible tener contenedores ultraligeros basados en [WebAssembly](https://webassembly.org/) que pueden ser ejecutados en cualquier sitio: desde tu ordenador hasta la nube y dispositivos de IoT, además de poder ser ejecutados [*en cualquier lenguaje de programación*](https://github.com/wasmerio/wasmer#language-integrations).
> This README is also available in: [🇬🇧 English-Inglés](https://github.com/wasmerio/wasmer/blob/master/README.md) • [🇫🇷 Français-Francés](https://github.com/wasmerio/wasmer/blob/master/docs/fr/README.md) • [🇨🇳 中文-Chino](https://github.com/wasmerio/wasmer/blob/master/docs/cn/README.md).
## Funcionalidades
* **Rápido y Seguro**. Wasmer ejecuta WebAssembly a velocidades *nativas* en un entorno completamente protegido.
* **Extendible**. Wasmer soporta diferentes métodos de compilación dependiendo de tus necesidades (LLVM, Cranelift...).
* **Universal**. Puedes ejecutar Wasmer en cualquier *platforma* (macOS, Linux y Windows) y *chip*.
* **Respeta los estándares**. Wasmer pasa los [tests oficiales de WebAssembly](https://github.com/WebAssembly/testsuite) siendo compatible con [WASI](https://github.com/WebAssembly/WASI) y [Emscripten](https://emscripten.org/).
## Empezamos?
Wasmer no requiere ninguna dependencia. Puedes instalarlo con uno de éstos instaladores:
```sh
curl https://get.wasmer.io -sSfL | sh
```
<details>
<summary>Con PowerShell (Windows)</summary>
<p>
```powershell
iwr https://win.wasmer.io -useb | iex
```
</p>
</details>
> Visita [wasmer-install](https://github.com/wasmerio/wasmer-install) para más opciones de instalación: Homebrew, Scoop, Cargo...
#### Ejecuta un archivo WebAssembly
¡Después de instalar Wasmer deberías estar listo para ejecutar tu primer módulo de WebAssembly! 🎉
Puedes empezar corriendo QuickJS: [qjs.wasm](https://registry-cdn.wapm.io/contents/_/quickjs/0.0.3/build/qjs.wasm)
```bash
$ wasmer qjs.wasm
QuickJS - Type "\h" for help
qjs >
```
#### Esto es lo que puedes hacer:
- [Usa Wasmer desde tu aplicación de Rust](https://docs.wasmer.io/integrations/rust)
- [Publica un paquete de Wasm en WAPM](https://docs.wasmer.io/ecosystem/wapm/publishing-your-package)
- [Lee más sobre Wasmer](https://medium.com/wasmer/)
## Integraciones en diferentes Lenguajes
📦 Wasmer puede ser usado como una librería **integrado en diferentes lenguajes de programación**, para que puedas ejecutar WebAssembly _en cualquier sitio_.
| &nbsp; | Lenguaje | Librería | Documentación |
|-|-|-|-|
| ![Rust logo] | [**Rust**][Rust integration] | [`wasmer` en crates.io] | [Documentación][rust docs]
| ![C logo] | [**C/C++**][C integration] | [cabecera `wasmer.h`] | [Documentación][c docs] |
| ![C# logo] | [**C#**][C# integration] | [`WasmerSharp` en NuGet] | [Documentación][c# docs] |
| ![D logo] | [**D**][D integration] | [`wasmer` en Dug] | [Documentación][d docs] |
| ![Python logo] | [**Python**][Python integration] | [`wasmer` en PyPI] | [Documentación][python docs] |
| ![JS logo] | [**Javascript**][JS integration] | [`@wasmerio` en NPM] | [Documentación][js docs] |
| ![Go logo] | [**Go**][Go integration] | [`wasmer` en Go] | [Documentación][go docs] |
| ![PHP logo] | [**PHP**][PHP integration] | [`wasm` en PECL] | [Documentación][php docs] |
| ![Ruby logo] | [**Ruby**][Ruby integration] | [`wasmer` en Ruby Gems] | [Documentación][ruby docs] |
| ![Java logo] | [**Java**][Java integration] | [`wasmer/wasmer-jni` en Bintray] | [Documentación][java docs] |
| ![Elixir logo] | [**Elixir**][Elixir integration] | [`wasmex` en hex] | [Documentación][elixir docs] |
| ![R logo] | [**R**][R integration] | *sin paquete publicado* | [Documentación][r docs] |
| ![Postgres logo] | [**Postgres**][Postgres integration] | *sin paquete publicado* | [Documentación][postgres docs] |
| | [**Swift**][Swift integration] | *sin paquete publicado* | |
[👋 Falta algún lenguaje?](https://github.com/wasmerio/wasmer/issues/new?assignees=&labels=%F0%9F%8E%89+enhancement&template=---feature-request.md&title=)
[rust logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/rust.svg
[rust integration]: https://github.com/wasmerio/wasmer/tree/master/lib/api
[`wasmer` en crates.io]: https://crates.io/crates/wasmer/
[rust docs]: https://wasmerio.github.io/wasmer/crates/wasmer_runtime
[c logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/c.svg
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
[cabecera `wasmer.h`]: https://wasmerio.github.io/wasmer/c/
[c docs]: https://wasmerio.github.io/wasmer/c/
[c# logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/csharp.svg
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
[`wasmersharp` en NuGet]: https://www.nuget.org/packages/WasmerSharp/
[c# docs]: https://migueldeicaza.github.io/WasmerSharp/
[d logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/d.svg
[d integration]: https://github.com/chances/wasmer-d
[`wasmer` en Dub]: https://code.dlang.org/packages/wasmer
[d docs]: https://chances.github.io/wasmer-d
[python logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/python.svg
[python integration]: https://github.com/wasmerio/wasmer-python
[`wasmer` en pypi]: https://pypi.org/project/wasmer/
[python docs]: https://github.com/wasmerio/wasmer-python#api-of-the-wasmer-extensionmodule
[go logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/go.svg
[go integration]: https://github.com/wasmerio/wasmer-go
[`wasmer` en go]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer
[go docs]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer?tab=doc
[php logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/php.svg
[php integration]: https://github.com/wasmerio/wasmer-php
[php docs]: https://wasmerio.github.io/wasmer-php/wasm/
[`wasm` en pecl]: https://pecl.php.net/package/wasm
[js logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/js.svg
[js integration]: https://github.com/wasmerio/wasmer-js
[`@wasmerio` en npm]: https://www.npmjs.com/org/wasmer
[js docs]: https://docs.wasmer.io/integrations/js/reference-api
[ruby logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/ruby.svg
[ruby integration]: https://github.com/wasmerio/wasmer-ruby
[`wasmer` en ruby gems]: https://rubygems.org/gems/wasmer
[ruby docs]: https://www.rubydoc.info/gems/wasmer/
[java logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/java.svg
[java integration]: https://github.com/wasmerio/wasmer-java
[`wasmer/wasmer-jni` en bintray]: https://bintray.com/wasmer/wasmer-jni/wasmer-jni
[java docs]: https://github.com/wasmerio/wasmer-java/#api-of-the-wasmer-library
[elixir logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/elixir.svg
[elixir integration]: https://github.com/tessi/wasmex
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
[`wasmex` en hex]: https://hex.pm/packages/wasmex
[r logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/r.svg
[r integration]: https://github.com/dirkschumacher/wasmr
[r docs]: https://github.com/dirkschumacher/wasmr#example
[postgres logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/postgres.svg
[postgres integration]: https://github.com/wasmerio/wasmer-postgres
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation
[swift integration]: https://github.com/AlwaysRightInstitute/SwiftyWasmer
## Contribuye
**Damos la bienvenida a cualquier forma de contribución, especialmente a los nuevos miembros de la comunidad** 💜
¡Puedes ver cómo crear el binario de Wasmer con [nuestros increíbles documentos](https://docs.wasmer.io/ecosystem/wasmer/building-from-source)!
### Tests
Testear quieres? Los [documentos de Wasmer te enseñarán cómo](https://docs.wasmer.io/ecosystem/wasmer/building-from-source/testing).
## Comunidad
Wasmer tiene una comunidad increíble de desarrolladores y colaboradores ¡Bienvenido, únete a nosotros! 👋
### Medios
- [Slack](https://slack.wasmer.io/)
- [Twitter](https://twitter.com/wasmerio)
- [Facebook](https://www.facebook.com/wasmerio)
- [Email](mailto:hello@wasmer.io)

191
docs/fr/README.md Normal file
View File

@@ -0,0 +1,191 @@
<div align="center">
<a href="https://wasmer.io" target="_blank" rel="noopener noreferrer">
<img width="300" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/logo.png" alt="Logo Wasmer">
</a>
<p>
<a href="https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild">
<img src="https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square" alt="État des tests">
</a>
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square" alt="Licence">
</a>
<a href="https://slack.wasmer.io">
<img src="https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square" alt="Salon Slack">
</a>
</p>
<h3>
<a href="https://wasmer.io/">Web</a>
<span></span>
<a href="https://docs.wasmer.io">Documentation</a>
<span></span>
<a href="https://slack.wasmer.io/">Chat</a>
</h3>
</div>
<br />
[Wasmer](https://wasmer.io/) permet l'utilisation de conteneurs super légers basés sur [WebAssembly](https://webassembly.org/) qui peuvent fonctionner n'importe où : du bureau au cloud en passant par les appareils IoT, et également intégrés dans [*une multitude de langages de programmation*](https://github.com/wasmerio/wasmer#language-integrations).
> This readme is also available in: [🇬🇧 English-Anglaise](https://github.com/wasmerio/wasmer/blob/master/README.md) • [🇪🇸 Español-Espagnol](https://github.com/wasmerio/wasmer/blob/master/docs/es/README.md) • [🇨🇳 中文-Chinoise](https://github.com/wasmerio/wasmer/blob/master/docs/cn/README.md)
## Fonctionnalités
* **Rapide et sûr**. Wasmer exécute WebAssembly à une vitesse *quasi native* dans un environnement entièrement contrôlé (bac à sable, _sandbox_).
* **Modulaire**. Wasmer prend en charge différents frameworks de compilation pour répondre au mieux à vos besoins (LLVM, Cranelift ...).
* **Universel**. Vous pouvez exécuter Wasmer sur n'importe quelle *plate-forme* (macOS, Linux et Windows) et *processeur*.
* **Conforme aux normes**. Wasmer passe [la suite de tests officielle de WebAssembly](https://github.com/WebAssembly/testsuite) prenant en charge [WASI](https://github.com/WebAssembly/WASI) et [Emscripten](https://emscripten.org/)
## Quickstart
Wasmer est livré sans aucune dépendance. Vous pouvez l'installer à l'aide des programmes d'installation ci-dessous :
```sh
curl https://get.wasmer.io -sSfL | sh
```
<details>
<summary>Avec PowerShell (Windows)</summary>
<p>
```powershell
iwr https://win.wasmer.io -useb | iex
```
</p>
</details>
> Voir [wasmer-install](https://github.com/wasmerio/wasmer-install) pour plus d'options d'installation: Homebrew, Scoop, Cargo...
#### Exécution d'un fichier WebAssembly
Après avoir installé Wasmer, vous devriez être prêt à exécuter votre premier fichier WebAssemby ! 🎉
Vous pouvez commencer par exécuter QuickJS : [qjs.wasm](https://registry-cdn.wapm.io/contents/_/quickjs/0.0.3/build/qjs.wasm)
```bash
$ wasmer qjs.wasm
QuickJS - Type "\h" for help
qjs >
```
#### Voici ce que vous pouvez faire ensuite
- [Utilisez Wasmer depuis votre application Rust](https://docs.wasmer.io/integrations/rust)
- [Publier un paquet Wasm sur WAPM](https://docs.wasmer.io/ecosystem/wapm/publishing-your-package)
- [En savoir plus sur Wasmer](https://medium.com/wasmer/)
## Intégrations
📦 Wasmer peut être utilisé comme une bibliothèque **intégrée dans différents langages**, vous pouvez donc utiliser WebAssembly _n'import où_.
| &nbsp; | Langage de programmation | Package | Docs |
|-|-|-|-|
| ![Rust logo] | [**Rust**][Rust integration] | [`wasmer` Rust crate] | [Docs][rust docs]
| ![C logo] | [**C/C++**][C integration] | [`wasmer.h` headers] | [Docs][c docs] |
| ![C# logo] | [**C#**][C# integration] | [`WasmerSharp` NuGet package] | [Docs][c# docs] |
| ![D logo] | [**D**][D integration] | [`wasmer` Dub package] | [Docs][d docs] |
| ![Python logo] | [**Python**][Python integration] | [`wasmer` PyPI package] | [Docs][python docs] |
| ![JS logo] | [**Javascript**][JS integration] | [`@wasmerio` NPM packages] | [Docs][js docs] |
| ![Go logo] | [**Go**][Go integration] | [`wasmer` Go package] | [Docs][go docs] |
| ![PHP logo] | [**PHP**][PHP integration] | [`wasm` PECL package] | [Docs][php docs] |
| ![Ruby logo] | [**Ruby**][Ruby integration] | [`wasmer` Ruby Gem] | [Docs][ruby docs] |
| ![Java logo] | [**Java**][Java integration] | [`wasmer/wasmer-jni` Bintray package] | [Docs][java docs] |
| ![Elixir logo] | [**Elixir**][Elixir integration] | [`wasmex` hex package] | [Docs][elixir docs] |
| ![R logo] | [**R**][R integration] | *no published package* | [Docs][r docs] |
| ![Postgres logo] | [**Postgres**][Postgres integration] | *no published package* | [Docs][postgres docs] |
| | [**Swift**][Swift integration] | *no published package* | |
[👋 Il manque un langage ?](https://github.com/wasmerio/wasmer/issues/new?assignees=&labels=%F0%9F%8E%89+enhancement&template=---feature-request.md&title=)
[rust logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/rust.svg
[rust integration]: https://github.com/wasmerio/wasmer/tree/master/lib/api
[`wasmer` rust crate]: https://crates.io/crates/wasmer/
[rust docs]: https://wasmerio.github.io/wasmer/crates/wasmer_runtime
[c logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/c.svg
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
[`wasmer.h` headers]: https://wasmerio.github.io/wasmer/c/
[c docs]: https://wasmerio.github.io/wasmer/c/
[c# logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/csharp.svg
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
[`wasmersharp` nuget package]: https://www.nuget.org/packages/WasmerSharp/
[c# docs]: https://migueldeicaza.github.io/WasmerSharp/
[d logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/d.svg
[d integration]: https://github.com/chances/wasmer-d
[`wasmer` Dub package]: https://code.dlang.org/packages/wasmer
[d docs]: https://chances.github.io/wasmer-d
[python logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/python.svg
[python integration]: https://github.com/wasmerio/wasmer-python
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
[python docs]: https://github.com/wasmerio/wasmer-python#api-of-the-wasmer-extensionmodule
[go logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/go.svg
[go integration]: https://github.com/wasmerio/wasmer-go
[`wasmer` go package]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer
[go docs]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer?tab=doc
[php logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/php.svg
[php integration]: https://github.com/wasmerio/wasmer-php
[`wasm` pecl package]: https://pecl.php.net/package/wasm
[php docs]: https://wasmerio.github.io/wasmer-php/wasm/
[js logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/js.svg
[js integration]: https://github.com/wasmerio/wasmer-js
[`@wasmerio` npm packages]: https://www.npmjs.com/org/wasmer
[js docs]: https://docs.wasmer.io/integrations/js/reference-api
[ruby logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/ruby.svg
[ruby integration]: https://github.com/wasmerio/wasmer-ruby
[`wasmer` ruby gem]: https://rubygems.org/gems/wasmer
[ruby docs]: https://www.rubydoc.info/gems/wasmer/
[java logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/java.svg
[java integration]: https://github.com/wasmerio/wasmer-java
[`wasmer/wasmer-jni` bintray package]: https://bintray.com/wasmer/wasmer-jni/wasmer-jni
[java docs]: https://github.com/wasmerio/wasmer-java/#api-of-the-wasmer-library
[elixir logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/elixir.svg
[elixir integration]: https://github.com/tessi/wasmex
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
[`wasmex` hex package]: https://hex.pm/packages/wasmex
[r logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/r.svg
[r integration]: https://github.com/dirkschumacher/wasmr
[r docs]: https://github.com/dirkschumacher/wasmr#example
[postgres logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/postgres.svg
[postgres integration]: https://github.com/wasmerio/wasmer-postgres
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation
[swift integration]: https://github.com/AlwaysRightInstitute/SwiftyWasmer
## Contribuer
**Nous accueillons toutes formes de contributions, en particulier de la part des nouveaux membres de notre communauté**. 💜
Vous pouvez vérifier comment compiler Wasmer dans [notre documentation](https://docs.wasmer.io/ecosystem/wasmer/building-from-source)!
### Test
Vous voulez des tests ? La [documentation de Wasmer](https://docs.wasmer.io/ecosystem/wasmer/building-from-source/testing) vous montrera comment les exécuter.
## Communauté
Wasmer a une incroyable communauté de développeurs et de contributeurs. Bienvenue et rejoignez-nous ! 👋
### Canaux de communications
- [Slack](https://slack.wasmer.io/)
- [Twitter](https://twitter.com/wasmerio)
- [Facebook](https://www.facebook.com/wasmerio)
- [Email](mailto:hello@wasmer.io)

View File

@@ -45,6 +45,7 @@ fn main() -> anyhow::Result<()> {
// (`Cranelift`) and pass it to an engine (`JIT`). We then pass the engine to
// the store and are now ready to compile and run WebAssembly!
let store = Store::new(&JIT::new(Cranelift::default()).engine());
// We then use our store and Wasm bytes to compile a `Module`.
// A `Module` is a compiled WebAssembly module that isn't ready to execute yet.
let module = Module::new(&store, wasm_bytes)?;
@@ -71,6 +72,7 @@ fn main() -> anyhow::Result<()> {
// An `Instance` is a compiled WebAssembly module that has been set up
// and is ready to execute.
let instance = Instance::new(&module, &import_object)?;
// We get the `NativeFunc` with no parameters and no results from the instance.
//
// Recall that the Wasm module exported a function named "run", this is getting

View File

@@ -1,6 +1,7 @@
use std::ptr::NonNull;
use std::sync::Arc;
use loupe::MemoryUsage;
use wasmer::{
imports,
vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition},
@@ -14,6 +15,7 @@ use wasmer_engine_jit::JIT;
///
/// 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

58
fuzz/Cargo.lock generated
View File

@@ -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,27 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "loupe"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1acf065b51eb58abbc66a07c27ec63142205d339a9f5093dc3e1d7cda3d5c9a3"
dependencies = [
"indexmap",
"loupe-derive",
"rustversion",
]
[[package]]
name = "loupe-derive"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e40881c741681f26b0f4c0261f493c8df600998807184b524e34b7e208324834"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "mach"
version = "0.3.2"
@@ -822,6 +843,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 +910,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 +928,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 +1065,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 +1073,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 +1087,7 @@ version = "1.0.2"
dependencies = [
"cfg-if 0.1.10",
"indexmap",
"loupe",
"more-asserts",
"target-lexicon",
"thiserror",
@@ -1096,6 +1124,7 @@ name = "wasmer-compiler"
version = "1.0.2"
dependencies = [
"enumset",
"loupe",
"serde",
"serde_bytes",
"smallvec",
@@ -1114,6 +1143,7 @@ dependencies = [
"cranelift-entity",
"cranelift-frontend",
"gimli",
"loupe",
"more-asserts",
"rayon",
"serde",
@@ -1135,6 +1165,7 @@ dependencies = [
"itertools",
"lazy_static",
"libc",
"loupe",
"rayon",
"regex",
"rustc_version",
@@ -1154,6 +1185,7 @@ dependencies = [
"dynasm",
"dynasmrt",
"lazy_static",
"loupe",
"more-asserts",
"rayon",
"serde",
@@ -1180,6 +1212,7 @@ dependencies = [
"backtrace",
"bincode",
"lazy_static",
"loupe",
"memmap2",
"more-asserts",
"rustc-demangle",
@@ -1198,6 +1231,7 @@ version = "1.0.2"
dependencies = [
"bincode",
"cfg-if 0.1.10",
"loupe",
"region",
"serde",
"serde_bytes",
@@ -1216,6 +1250,7 @@ dependencies = [
"cfg-if 0.1.10",
"leb128",
"libloading",
"loupe",
"serde",
"tempfile",
"tracing",
@@ -1231,6 +1266,7 @@ dependencies = [
name = "wasmer-middlewares"
version = "1.0.2"
dependencies = [
"loupe",
"wasmer",
"wasmer-types",
"wasmer-vm",
@@ -1250,6 +1286,7 @@ dependencies = [
name = "wasmer-types"
version = "1.0.2"
dependencies = [
"loupe",
"serde",
"thiserror",
]
@@ -1263,6 +1300,7 @@ dependencies = [
"cfg-if 0.1.10",
"indexmap",
"libc",
"loupe",
"memoffset",
"more-asserts",
"region",

View File

@@ -27,6 +27,7 @@ wat = { version = "1.0", optional = true }
thiserror = "1.0"
more-asserts = "0.2"
target-lexicon = { version = "0.11", default-features = false }
loupe = "0.1"
[target.'cfg(target_os = "windows")'.dependencies]
winapi = "0.3"

View File

@@ -3,6 +3,7 @@ use crate::import_object::LikeNamespace;
use crate::native::NativeFunc;
use crate::WasmTypeList;
use indexmap::IndexMap;
use loupe::MemoryUsage;
use std::fmt;
use std::iter::{ExactSizeIterator, FromIterator};
use std::sync::Arc;
@@ -61,7 +62,7 @@ pub enum ExportError {
/// the types of instances.
///
/// TODO: add examples of using exports
#[derive(Clone, Default)]
#[derive(Clone, Default, MemoryUsage)]
pub struct Exports {
map: Arc<IndexMap<String, Extern>>,
}

View File

@@ -10,6 +10,7 @@ pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, Witho
#[cfg(feature = "deprecated")]
pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv};
use loupe::MemoryUsage;
use std::cmp::max;
use std::ffi::c_void;
use std::fmt;
@@ -22,21 +23,22 @@ use wasmer_vm::{
};
/// A function defined in the Wasm module
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct WasmFunctionDefinition {
// Address of the trampoline to do the call.
#[loupe(skip)]
pub(crate) trampoline: VMTrampoline,
}
/// A function defined in the Host
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct HostFunctionDefinition {
/// If the host function has a custom environment attached
pub(crate) has_env: bool,
}
/// The inner helper
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub enum FunctionDefinition {
/// A function defined in the Wasm side
Wasm(WasmFunctionDefinition),
@@ -61,7 +63,7 @@ pub enum FunctionDefinition {
/// 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(Clone, PartialEq)]
#[derive(Clone, PartialEq, MemoryUsage)]
pub struct Function {
pub(crate) store: Store,
pub(crate) definition: FunctionDefinition,

View File

@@ -5,6 +5,7 @@ use crate::types::Val;
use crate::GlobalType;
use crate::Mutability;
use crate::RuntimeError;
use loupe::MemoryUsage;
use std::fmt;
use std::sync::Arc;
use wasmer_engine::{Export, ExportGlobal};
@@ -16,7 +17,7 @@ use wasmer_vm::{Global as RuntimeGlobal, VMExportGlobal};
/// 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(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Global {
store: Store,
global: Arc<RuntimeGlobal>,

View File

@@ -2,6 +2,7 @@ use crate::exports::{ExportError, Exportable};
use crate::externals::Extern;
use crate::store::Store;
use crate::{MemoryType, MemoryView};
use loupe::MemoryUsage;
use std::convert::TryInto;
use std::slice;
use std::sync::Arc;
@@ -23,7 +24,7 @@ use wasmer_vm::{Memory as RuntimeMemory, MemoryError, VMExportMemory};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
pub struct Memory {
store: Store,
memory: Arc<dyn RuntimeMemory>,

View File

@@ -16,6 +16,7 @@ pub use self::table::Table;
use crate::exports::{ExportError, Exportable};
use crate::store::{Store, StoreObject};
use crate::ExternType;
use loupe::MemoryUsage;
use std::fmt;
use wasmer_engine::Export;
@@ -23,7 +24,7 @@ use wasmer_engine::Export;
/// can be imported or exported.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub enum Extern {
/// A external [`Function`].
Function(Function),

View File

@@ -4,6 +4,7 @@ use crate::store::Store;
use crate::types::{Val, ValFuncRef};
use crate::RuntimeError;
use crate::TableType;
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_engine::{Export, ExportTable};
use wasmer_vm::{Table as RuntimeTable, TableReference, VMExportTable};
@@ -17,7 +18,7 @@ use wasmer_vm::{Table as RuntimeTable, TableReference, VMExportTable};
/// mutable from both host and WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Table {
store: Store,
table: Arc<dyn RuntimeTable>,

View File

@@ -3,6 +3,7 @@ use crate::externals::Extern;
use crate::module::Module;
use crate::store::Store;
use crate::{HostEnvInitError, LinkError, RuntimeError};
use loupe::MemoryUsage;
use std::fmt;
use std::sync::{Arc, Mutex};
use thiserror::Error;
@@ -17,7 +18,7 @@ use wasmer_vm::{InstanceHandle, VMContext};
/// interacting with WebAssembly.
///
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Instance {
handle: Arc<Mutex<InstanceHandle>>,
module: Module,

View File

@@ -1,6 +1,7 @@
use crate::store::Store;
use crate::types::{ExportType, ImportType};
use crate::InstantiationError;
use loupe::MemoryUsage;
use std::fmt;
use std::io;
use std::path::Path;
@@ -30,7 +31,7 @@ pub enum IoCompileError {
///
/// Cloning a module is cheap: it does a shallow copy of the compiled
/// contents rather than a deep copy.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Module {
store: Store,
artifact: Arc<dyn Artifact>,

View File

@@ -1,4 +1,5 @@
use crate::tunables::BaseTunables;
use loupe::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: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct Store {
engine: Arc<dyn Engine + Send + Sync>,
tunables: Arc<dyn Tunables + Send + Sync>,

View File

@@ -1,4 +1,5 @@
use crate::{MemoryType, Pages, TableType};
use loupe::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,

View File

@@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive"] }
more-asserts = "0.2"
gimli = { version = "0.23", optional = true }
smallvec = "1.6"
loupe = "0.1"
[dev-dependencies]
target-lexicon = { version = "0.11", default-features = false }

View File

@@ -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::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,
}

View File

@@ -1,6 +1,7 @@
use crate::compiler::CraneliftCompiler;
use cranelift_codegen::isa::{lookup, TargetIsa};
use cranelift_codegen::settings::{self, Configurable};
use loupe::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,

View File

@@ -22,6 +22,7 @@ libc = { version = "^0.2", default-features = false }
byteorder = "1"
itertools = "0.10"
rayon = "1.5"
loupe = "0.1"
[dependencies.inkwell]
version = "=0.1.0-beta.2"

View File

@@ -7,6 +7,7 @@ use inkwell::memory_buffer::MemoryBuffer;
use inkwell::module::{Linkage, Module};
use inkwell::targets::FileType;
use inkwell::DLLStorageClass;
use loupe::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,
}

View File

@@ -5,6 +5,7 @@ use inkwell::targets::{
};
pub use inkwell::OptimizationLevel as LLVMOptLevel;
use itertools::Itertools;
use loupe::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,
#[loupe(skip)]
pub(crate) opt_level: LLVMOptLevel,
is_pic: bool,
#[loupe(skip)]
pub(crate) callbacks: Option<Arc<dyn LLVMCallbacks>>,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,

View File

@@ -24,6 +24,7 @@ dynasmrt = "1.0"
lazy_static = "1.4"
byteorder = "1.3"
smallvec = "1.6"
loupe = "0.1"
[dev-dependencies]
target-lexicon = { version = "0.11", default-features = false }

View File

@@ -7,6 +7,7 @@ use crate::codegen_x64::{
CodegenError, FuncGen,
};
use crate::config::Singlepass;
use loupe::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,
}

View File

@@ -2,11 +2,12 @@
#![allow(unused_imports, dead_code)]
use crate::compiler::SinglepassCompiler;
use loupe::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,

View File

@@ -21,6 +21,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
thiserror = "1.0"
serde_bytes = { version = "0.11", optional = true }
smallvec = "1.6"
loupe = "0.1"
[features]
default = ["std", "enable-serde"]

View File

@@ -3,12 +3,13 @@
use crate::lib::std::vec::Vec;
use crate::sourceloc::SourceLoc;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
/// Single source location to generated address mapping.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub struct InstructionAddressMap {
/// Original source location.
pub srcloc: SourceLoc,
@@ -22,7 +23,7 @@ pub struct InstructionAddressMap {
/// Function and its instructions addresses mappings.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
pub struct FunctionAddressMap {
/// Instructions maps.
/// The array is sorted by the InstructionAddressMap::code_offset field.

View File

@@ -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.

View File

@@ -12,6 +12,7 @@ use crate::lib::std::vec::Vec;
use crate::section::{CustomSection, SectionIndex};
use crate::trap::TrapInformation;
use crate::{CompiledFunctionUnwindInfo, FunctionAddressMap, JumpTableOffsets, Relocation};
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_types::entity::PrimaryMap;
@@ -22,7 +23,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex};
/// This structure is only used for reconstructing
/// the frame information after a `Trap`.
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
pub struct CompiledFunctionFrameInfo {
/// The traps (in the function body).
///
@@ -35,7 +36,7 @@ pub struct CompiledFunctionFrameInfo {
/// The function body.
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub struct FunctionBody {
/// The function body bytes.
#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))]
@@ -79,7 +80,7 @@ pub type CustomSections = PrimaryMap<SectionIndex, CustomSection>;
/// In the future this structure may also hold other information useful
/// for debugging.
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, MemoryUsage)]
pub struct Dwarf {
/// The section index in the [`Compilation`] that corresponds to the exception frames.
/// [Learn

View File

@@ -5,6 +5,7 @@
//! [Learn more](https://en.wikipedia.org/wiki/Branch_table).
use super::CodeOffset;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_types::entity::{entity_impl, SecondaryMap};
@@ -14,7 +15,7 @@ use wasmer_types::entity::{entity_impl, SecondaryMap};
/// `JumpTable`s are used for indirect branching and are specialized for dense,
/// 0-based jump offsets.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, MemoryUsage)]
pub struct JumpTable(u32);
entity_impl!(JumpTable, "jt");

View File

@@ -1,4 +1,5 @@
use crate::lib::std::sync::Arc;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_types::entity::PrimaryMap;
@@ -10,7 +11,7 @@ use wasmer_vm::{MemoryStyle, ModuleInfo, TableStyle};
/// This differs from [`ModuleInfo`] because it have extra info only
/// possible after translation (such as the features used for compiling,
/// or the `MemoryStyle` and `TableStyle`).
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
pub struct CompileModuleInfo {
/// The features used for compiling the module

View File

@@ -13,6 +13,7 @@ use crate::lib::std::fmt;
use crate::lib::std::vec::Vec;
use crate::section::SectionIndex;
use crate::{Addend, CodeOffset, JumpTable};
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_types::entity::PrimaryMap;
@@ -21,7 +22,7 @@ use wasmer_vm::libcalls::LibCall;
/// Relocation kinds for every ISA.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, MemoryUsage)]
pub enum RelocationKind {
/// absolute 4-byte
Abs4,
@@ -79,7 +80,7 @@ impl fmt::Display for RelocationKind {
/// A record of a relocation to perform.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub struct Relocation {
/// The relocation kind.
pub kind: RelocationKind,
@@ -93,7 +94,7 @@ pub struct Relocation {
/// Destination function. Can be either user function or some special one, like `memory.grow`.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, MemoryUsage)]
pub enum RelocationTarget {
/// A relocation to a function defined locally in the wasm (not an imported one).
LocalFunc(LocalFunctionIndex),

View File

@@ -7,13 +7,14 @@
use crate::lib::std::vec::Vec;
use crate::Relocation;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_types::entity::entity_impl;
/// Index type of a Section defined inside a WebAssembly `Compilation`.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, MemoryUsage)]
pub struct SectionIndex(u32);
entity_impl!(SectionIndex);
@@ -22,7 +23,7 @@ entity_impl!(SectionIndex);
///
/// Determines how a custom section may be used.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub enum CustomSectionProtection {
/// A custom section with read permission.
Read,
@@ -36,7 +37,7 @@ pub enum CustomSectionProtection {
/// This is used so compilers can store arbitrary information
/// in the emitted module.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub struct CustomSection {
/// Memory protection that applies to this section.
pub protection: CustomSectionProtection,
@@ -55,7 +56,7 @@ pub struct CustomSection {
/// The bytes in the section.
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
pub struct SectionBody(#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))] Vec<u8>);
impl SectionBody {

View File

@@ -8,7 +8,7 @@
//! and tracing errors.
use crate::lib::std::fmt;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
@@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize};
serde(transparent)
)]
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, MemoryUsage)]
pub struct SourceLoc(u32);
impl SourceLoc {

View File

@@ -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::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 {
#[loupe(skip)]
triple: Triple,
#[loupe(skip)]
cpu_features: EnumSet<CpuFeature>,
}

View File

@@ -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,

View File

@@ -1,11 +1,12 @@
use crate::CodeOffset;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use wasmer_vm::TrapCode;
/// Information about trap.
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, MemoryUsage)]
pub struct TrapInformation {
/// The offset of the trapping instruction in native code. It is relative to the beginning of the function.
pub code_offset: CodeOffset,

View File

@@ -6,6 +6,7 @@
//!
//! [Learn more](https://en.wikipedia.org/wiki/Call_stack).
use crate::lib::std::vec::Vec;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
@@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize};
///
/// [unwind info]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
pub enum CompiledFunctionUnwindInfo {
/// Windows UNWIND_INFO.
WindowsX64(Vec<u8>),

View File

@@ -21,6 +21,7 @@ serde = { version = "1.0", features = ["derive", "rc"] }
serde_bytes = { version = "0.11" }
bincode = "1.3"
cfg-if = "0.1"
loupe = "0.1"
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["winnt", "impl-default"] }

View File

@@ -6,6 +6,7 @@ use crate::link::link_module;
#[cfg(feature = "compiler")]
use crate::serialize::SerializableCompilation;
use crate::serialize::SerializableModule;
use loupe::MemoryUsage;
use std::sync::{Arc, Mutex};
use wasmer_compiler::{CompileError, Features, Triple};
#[cfg(feature = "compiler")]
@@ -27,9 +28,11 @@ use wasmer_vm::{
};
/// A compiled wasm module, ready to be instantiated.
#[derive(MemoryUsage)]
pub struct JITArtifact {
serializable: SerializableModule,
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
#[loupe(skip)]
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,

View File

@@ -3,6 +3,7 @@
//! Memory management for executable code.
use crate::unwind::UnwindRegistry;
use loupe::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,

View File

@@ -1,6 +1,7 @@
//! JIT compilation.
use crate::{CodeMemory, JITArtifact};
use loupe::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<Mutex<JITEngineInner>>,
/// The target for the compiler
@@ -145,6 +146,7 @@ impl Engine for JITEngine {
}
/// The inner contents of `JITEngine`
#[derive(MemoryUsage)]
pub struct JITEngineInner {
/// The compiler
#[cfg(feature = "compiler")]

View File

@@ -1,3 +1,4 @@
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use wasmer_compiler::{
CompileModuleInfo, CustomSection, Dwarf, FunctionBody, JumpTableOffsets, Relocation,
@@ -18,7 +19,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, Sign
// }
/// The compilation related data for a serialized modules
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, MemoryUsage)]
pub struct SerializableCompilation {
pub function_bodies: PrimaryMap<LocalFunctionIndex, FunctionBody>,
pub function_relocations: PrimaryMap<LocalFunctionIndex, Vec<Relocation>>,
@@ -37,7 +38,7 @@ pub struct SerializableCompilation {
/// Serializable struct that is able to serialize from and to
/// a `JITArtifactInfo`.
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, MemoryUsage)]
pub struct SerializableModule {
pub compilation: SerializableCompilation,
pub compile_info: CompileModuleInfo,

View File

@@ -1,9 +1,11 @@
//! Module for Dummy unwind registry.
use loupe::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 {

View File

@@ -2,9 +2,12 @@
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
//! Module for System V ABI unwind registry.
use loupe::MemoryUsage;
use wasmer_compiler::CompiledFunctionUnwindInfo;
/// Represents a registry of function unwind information for System V ABI.
#[derive(MemoryUsage)]
pub struct UnwindRegistry {
registrations: Vec<usize>,
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();

View File

@@ -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(|(_, _)| std::mem::size_of::<u64>() * 3)
.sum::<usize>()
+ self.published.size_of_val(tracker)
}
}

View File

@@ -24,6 +24,7 @@ leb128 = "0.2"
libloading = "0.7"
tempfile = "3.1"
which = "4.0"
loupe = "0.1"
[features]
# Enable the `compiler` feature if you want the engine to compile

View File

@@ -4,6 +4,7 @@
use crate::engine::{NativeEngine, NativeEngineInner};
use crate::serialize::ModuleMetadata;
use libloading::{Library, Symbol as LibrarySymbol};
use loupe::MemoryUsage;
use std::error::Error;
use std::fs::File;
use std::io::{Read, Write};
@@ -37,10 +38,12 @@ use wasmer_vm::{
};
/// A compiled wasm module, ready to be instantiated.
#[derive(MemoryUsage)]
pub struct NativeArtifact {
sharedobject_path: PathBuf,
metadata: ModuleMetadata,
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
#[loupe(skip)]
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
func_data_registry: Arc<FuncDataRegistry>,

View File

@@ -2,6 +2,7 @@
use crate::NativeArtifact;
use libloading::Library;
use loupe::MemoryUsage;
use std::path::Path;
use std::sync::Arc;
use std::sync::Mutex;
@@ -17,7 +18,7 @@ use wasmer_vm::{
};
/// A WebAssembly `Native` Engine.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct NativeEngine {
inner: Arc<Mutex<NativeEngineInner>>,
/// The target for the compiler
@@ -183,7 +184,7 @@ impl Engine for NativeEngine {
}
}
#[derive(Clone, Copy)]
#[derive(Clone, Copy, MemoryUsage)]
pub(crate) enum Linker {
None,
Clang11,
@@ -228,29 +229,39 @@ impl Linker {
}
/// The inner contents of `NativeEngine`
#[derive(MemoryUsage)]
pub struct NativeEngineInner {
/// The compiler
#[cfg(feature = "compiler")]
compiler: Option<Box<dyn Compiler>>,
/// The WebAssembly features to use
#[cfg(feature = "compiler")]
features: Features,
/// The signature registry is used mainly to operate with trampolines
/// performantly.
signatures: SignatureRegistry,
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
func_data: Arc<FuncDataRegistry>,
/// 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.
#[loupe(skip)]
prefixer: Option<Box<dyn Fn(&[u8]) -> 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.
#[loupe(skip)]
libraries: Vec<Library>,
}

View File

@@ -1,10 +1,11 @@
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
/// Serializable struct that represents the compiled metadata.
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
pub struct ModuleMetadata {
pub compile_info: CompileModuleInfo,
pub prefix: String,

View File

@@ -23,6 +23,7 @@ bincode = "1.3"
leb128 = "0.2"
libloading = "0.7"
tempfile = "3.1"
loupe = "0.1"
[features]
# Enable the `compiler` feature if you want the engine to compile

View File

@@ -3,6 +3,7 @@
use crate::engine::{ObjectFileEngine, ObjectFileEngineInner};
use crate::serialize::{ModuleMetadata, ModuleMetadataSymbolRegistry};
use loupe::MemoryUsage;
use std::collections::BTreeMap;
use std::error::Error;
use std::mem;
@@ -31,10 +32,12 @@ use wasmer_vm::{
};
/// A compiled wasm module, ready to be instantiated.
#[derive(MemoryUsage)]
pub struct ObjectFileArtifact {
metadata: ModuleMetadata,
module_bytes: Vec<u8>,
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
#[loupe(skip)]
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,

View File

@@ -1,4 +1,5 @@
use crate::ObjectFileArtifact;
use loupe::MemoryUsage;
use std::io::Read;
use std::path::Path;
use std::sync::{Arc, Mutex};
@@ -14,7 +15,7 @@ use wasmer_vm::{
};
/// A WebAssembly `ObjectFile` Engine.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct ObjectFileEngine {
inner: Arc<Mutex<ObjectFileEngineInner>>,
/// The target for the compiler
@@ -174,23 +175,29 @@ impl Engine for ObjectFileEngine {
}
/// The inner contents of `ObjectFileEngine`
#[derive(MemoryUsage)]
pub struct ObjectFileEngineInner {
/// The compiler
#[cfg(feature = "compiler")]
compiler: Option<Box<dyn Compiler>>,
/// The WebAssembly features to use
#[cfg(feature = "compiler")]
features: Features,
/// The signature registry is used mainly to operate with trampolines
/// performantly.
signatures: SignatureRegistry,
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
func_data: Arc<FuncDataRegistry>,
/// 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.
#[loupe(skip)]
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
}

View File

@@ -1,10 +1,11 @@
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
/// Serializable struct that represents the compiled metadata.
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
pub struct ModuleMetadata {
pub compile_info: CompileModuleInfo,
pub prefix: String,
@@ -13,6 +14,7 @@ pub struct ModuleMetadata {
pub function_body_lengths: PrimaryMap<LocalFunctionIndex, u64>,
}
#[derive(MemoryUsage)]
pub struct ModuleMetadataSymbolRegistry {
pub prefix: String,
}

View File

@@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive", "rc"] }
serde_bytes = { version = "0.11" }
bincode = "1.3"
lazy_static = "1.4"
loupe = "0.1"
[badges]
maintenance = { status = "actively-developed" }

View File

@@ -1,6 +1,7 @@
use crate::{
resolve_imports, InstantiationError, Resolver, RuntimeError, SerializeError, Tunables,
};
use loupe::MemoryUsage;
use std::any::Any;
use std::fs;
use std::path::Path;
@@ -22,7 +23,7 @@ use wasmer_vm::{
/// The `Artifact` contains the compiled data for a given
/// module as well as extra information needed to run the
/// module at runtime, such as [`ModuleInfo`] and [`Features`].
pub trait Artifact: Send + Sync + Upcastable {
pub trait Artifact: Send + Sync + Upcastable + MemoryUsage {
/// Return a reference-counted pointer to the module
fn module(&self) -> Arc<ModuleInfo>;

View File

@@ -2,6 +2,7 @@
use crate::tunables::Tunables;
use crate::{Artifact, DeserializeError};
use loupe::MemoryUsage;
use memmap2::Mmap;
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
@@ -16,7 +17,7 @@ use wasmer_vm::{VMCallerCheckedAnyfunc, VMFuncRef, 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;
@@ -71,7 +72,7 @@ pub trait Engine {
fn cloned(&self) -> Arc<dyn Engine + Send + Sync>;
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, MemoryUsage)]
#[repr(transparent)]
/// A unique identifier for an Engine.
pub struct EngineId {

View File

@@ -1,10 +1,10 @@
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_vm::{
ImportInitializerFuncPtr, VMExport, VMExportFunction, VMExportGlobal, VMExportMemory,
VMExportTable,
};
use std::sync::Arc;
/// The value of an export passed from one instance to another.
#[derive(Debug, Clone)]
pub enum Export {
@@ -54,7 +54,7 @@ impl From<VMExport> for Export {
///
/// This struct owns the original `host_env`, thus when it gets dropped
/// it calls the `drop` function on it.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, MemoryUsage)]
pub struct ExportFunctionMetadata {
/// This field is stored here to be accessible by `Drop`.
///
@@ -69,20 +69,26 @@ pub struct ExportFunctionMetadata {
/// See `wasmer_vm::export::VMExportFunction::vmctx` for the version of
/// this pointer that is used by the VM when creating an `Instance`.
pub(crate) host_env: *mut std::ffi::c_void,
/// Function pointer to `WasmerEnv::init_with_instance(&mut self, instance: &Instance)`.
///
/// This function is called to finish setting up the environment after
/// we create the `api::Instance`.
// This one is optional for now because dynamic host envs need the rest
// of this without the init fn
#[loupe(skip)]
pub(crate) import_init_function_ptr: Option<ImportInitializerFuncPtr>,
/// A function analogous to `Clone::clone` that returns a leaked `Box`.
#[loupe(skip)]
pub(crate) host_env_clone_fn: fn(*mut std::ffi::c_void) -> *mut std::ffi::c_void,
/// The destructor to free the host environment.
///
/// # Safety
/// - This function should only be called in when properly synchronized.
/// For example, in the `Drop` implementation of this type.
#[loupe(skip)]
pub(crate) host_env_drop_fn: unsafe fn(*mut std::ffi::c_void),
}
@@ -132,7 +138,7 @@ impl Drop for ExportFunctionMetadata {
/// A function export value with an extra function pointer to initialize
/// host environments.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, MemoryUsage)]
pub struct ExportFunction {
/// The VM function, containing most of the data.
pub vm_function: VMExportFunction,

View File

@@ -1,3 +1,4 @@
use loupe::MemoryUsage;
use serde::de::{Deserializer, Visitor};
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
@@ -5,7 +6,7 @@ use std::fmt;
use wasmer_compiler::CompiledFunctionFrameInfo;
/// This is the unserialized verison of `CompiledFunctionFrameInfo`.
#[derive(Clone, Serialize, Deserialize)]
#[derive(Clone, Serialize, Deserialize, MemoryUsage)]
#[serde(transparent)]
#[repr(transparent)]
pub struct UnprocessedFunctionFrameInfo {
@@ -44,7 +45,7 @@ impl UnprocessedFunctionFrameInfo {
/// of compiling at the same time that emiting the JIT.
/// In that case, we don't need to deserialize/process anything
/// as the data is already in memory.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub enum SerializableFunctionFrameInfo {
/// The unprocessed frame info (binary)
Unprocessed(UnprocessedFunctionFrameInfo),

View File

@@ -11,6 +11,7 @@
//! FRAME_INFO.register(module, compiled_functions);
//! ```
use crate::serialize::SerializableFunctionFrameInfo;
use loupe::MemoryUsage;
use std::cmp;
use std::collections::BTreeMap;
use std::sync::{Arc, RwLock};
@@ -44,6 +45,7 @@ pub struct GlobalFrameInfo {
/// An RAII structure used to unregister a module's frame information when the
/// module is destroyed.
#[derive(MemoryUsage)]
pub struct GlobalFrameInfoRegistration {
/// The key that will be removed from the global `ranges` map when this is
/// dropped.

View File

@@ -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;

View File

@@ -14,6 +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 = "0.1"
[badges]
maintenance = { status = "actively-developed" }

View File

@@ -1,8 +1,10 @@
//! `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 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 +14,7 @@ use wasmer::{
use wasmer_types::GlobalIndex;
use wasmer_vm::ModuleInfo;
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
struct MeteringGlobalIndexes(GlobalIndex, GlobalIndex);
impl MeteringGlobalIndexes {
@@ -154,6 +156,13 @@ impl<F: Fn(&Operator) -> u64 + Send + Sync + 'static> ModuleMiddleware for Meter
}
}
impl<F: Fn(&Operator) -> u64 + Send + Sync + 'static> MemoryUsage for Metering<F> {
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<F: Fn(&Operator) -> u64 + Send + Sync> fmt::Debug for FunctionMetering<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FunctionMetering")

View File

@@ -21,6 +21,7 @@ more-asserts = "0.2"
cfg-if = "0.1"
backtrace = "0.3"
serde = { version = "1.0", features = ["derive", "rc"] }
loupe = { version = "0.1", features = ["enable-indexmap"] }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] }

View File

@@ -6,6 +6,7 @@ use crate::instance::InstanceRef;
use crate::memory::{Memory, MemoryStyle};
use crate::table::{Table, TableStyle};
use crate::vmcontext::{VMFunctionBody, VMFunctionEnvironment, VMFunctionKind, VMTrampoline};
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_types::{FunctionType, MemoryType, TableType};
@@ -26,7 +27,7 @@ pub enum VMExport {
}
/// A function export value.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, MemoryUsage)]
pub struct VMExportFunction {
/// The address of the native-code function.
pub address: *const VMFunctionBody,
@@ -46,6 +47,7 @@ pub struct VMExportFunction {
///
/// May be `None` when the function is a host function (`FunctionType`
/// == `Dynamic` or `vmctx` == `nullptr`).
#[loupe(skip)]
pub call_trampoline: Option<VMTrampoline>,
/// A “reference” to the instance through the

View File

@@ -5,11 +5,12 @@
//! long as we need them to.
use crate::vmcontext::VMCallerCheckedAnyfunc;
use loupe::MemoryUsage;
use std::collections::HashMap;
use std::sync::Mutex;
/// The registry that holds the values that `VMFuncRef`s point to.
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
pub struct FuncDataRegistry {
// 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 @@ unsafe impl Sync for FuncDataRegistry {}
/// A function reference. A single word that points to metadata about a function.
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, MemoryUsage)]
pub struct VMFuncRef(pub(crate) *const VMCallerCheckedAnyfunc);
impl wasmer_types::NativeWasmType for VMFuncRef {
@@ -86,7 +87,7 @@ impl std::ops::DerefMut for VMFuncRef {
unsafe impl Send for VMFuncRef {}
unsafe impl Sync for VMFuncRef {}
#[derive(Debug, Default)]
#[derive(Debug, Default, MemoryUsage)]
struct Inner {
func_data: Vec<Box<VMCallerCheckedAnyfunc>>,
anyfunc_to_index: HashMap<VMCallerCheckedAnyfunc, usize>,

View File

@@ -1,11 +1,12 @@
use crate::vmcontext::VMGlobalDefinition;
use loupe::MemoryUsage;
use std::cell::UnsafeCell;
use std::ptr::NonNull;
use std::sync::Mutex;
use thiserror::Error;
use wasmer_types::{GlobalType, Mutability, Type, Value, ValueEnumType};
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
/// A Global instance
pub struct Global {
ty: GlobalType,

View File

@@ -28,6 +28,7 @@ use crate::vmcontext::{
};
use crate::{FunctionBodyPtr, ModuleInfo, VMOffsets};
use crate::{VMExportFunction, VMExportGlobal, VMExportMemory, VMExportTable};
use loupe::{MemoryUsage, MemoryUsageTracker};
use memoffset::offset_of;
use more_asserts::assert_lt;
use std::any::Any;
@@ -36,9 +37,10 @@ use std::collections::HashMap;
use std::convert::{TryFrom, TryInto};
use std::ffi;
use std::fmt;
use std::ptr::NonNull;
use std::mem;
use std::ptr::{self, NonNull};
use std::slice;
use std::sync::Arc;
use std::{mem, ptr, slice};
use wasmer_types::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
use wasmer_types::{
DataIndex, DataInitializer, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, GlobalInit,
@@ -57,6 +59,7 @@ pub type ImportInitializerFuncPtr<ResultErr = *mut ffi::c_void> =
/// contain various data. That's why the type has a C representation
/// to ensure that the `vmctx` field is last. See the documentation of
/// the `vmctx` field to learn more.
#[derive(MemoryUsage)]
#[repr(C)]
pub(crate) struct Instance {
/// The `ModuleInfo` this `Instance` was instantiated from.
@@ -78,6 +81,7 @@ pub(crate) struct Instance {
functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
/// Pointers to function call trampolines in executable memory.
#[loupe(skip)]
function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
/// Passive elements in this instantiation. As `elem.drop`s happen, these
@@ -95,6 +99,7 @@ pub(crate) struct Instance {
host_state: Box<dyn Any>,
/// Handler run when `SIGBUS`, `SIGFPE`, `SIGILL`, or `SIGSEGV` are caught by the instance thread.
#[loupe(skip)]
pub(crate) signal_handler: Cell<Option<Box<SignalHandler>>>,
/// Functions to operate on host environments in the imports
@@ -108,6 +113,7 @@ pub(crate) struct Instance {
/// field is last, and represents a dynamically-sized array that
/// extends beyond the nominal end of the struct (similar to a
/// flexible array member).
#[loupe(skip)]
vmctx: VMContext,
}
@@ -127,6 +133,7 @@ pub enum ImportFunctionEnv {
/// The function environment. This is not always the user-supplied
/// env.
env: *mut ffi::c_void,
/// A clone function for duplicating the env.
clone: fn(*mut ffi::c_void) -> *mut ffi::c_void,
/// This field is not always present. When it is present, it
@@ -192,6 +199,12 @@ impl Drop for ImportFunctionEnv {
}
}
impl MemoryUsage for ImportFunctionEnv {
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
}
}
impl fmt::Debug for Instance {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.debug_struct("Instance").finish()
@@ -872,7 +885,7 @@ impl Instance {
///
/// This is more or less a public facade of the private `Instance`,
/// providing useful higher-level API.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, MemoryUsage)]
pub struct InstanceHandle {
/// The [`InstanceRef`]. See its documentation to learn more.
instance: InstanceRef,

View File

@@ -1,5 +1,7 @@
use super::Instance;
use loupe::{MemoryUsage, MemoryUsageTracker};
use std::alloc::Layout;
use std::mem;
use std::ptr::{self, NonNull};
use std::sync::{atomic, Arc};
@@ -208,3 +210,13 @@ impl Drop for InstanceRef {
unsafe { Self::deallocate_instance(self) };
}
}
impl MemoryUsage for InstanceRef {
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self) + self.strong.size_of_val(tracker) - mem::size_of_val(&self.strong)
+ self.instance_layout.size_of_val(tracker)
- mem::size_of_val(&self.instance_layout)
+ self.as_ref().size_of_val(tracker)
- mem::size_of_val(&self.instance)
}
}

View File

@@ -58,13 +58,14 @@ pub use crate::vmcontext::{
VMTableImport, VMTrampoline,
};
pub use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
use loupe::MemoryUsage;
pub use wasmer_types::VMExternRef;
/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// A safe wrapper around `VMFunctionBody`.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, MemoryUsage)]
#[repr(transparent)]
pub struct FunctionBodyPtr(pub *const VMFunctionBody);

View File

@@ -41,6 +41,7 @@ use crate::table::{TableElement, TableReference};
use crate::trap::{raise_lib_trap, Trap, TrapCode};
use crate::vmcontext::VMContext;
use crate::VMExternRef;
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use std::fmt;
use wasmer_types::{
@@ -680,7 +681,7 @@ pub static wasmer_vm_probestack: unsafe extern "C" fn() = PROBESTACK;
/// The name of a runtime library routine.
///
/// This list is likely to grow over time.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, MemoryUsage)]
pub enum LibCall {
/// ceil.f32
CeilF32,

View File

@@ -7,6 +7,7 @@
use crate::mmap::Mmap;
use crate::vmcontext::VMMemoryDefinition;
use loupe::MemoryUsage;
use more_asserts::assert_ge;
use serde::{Deserialize, Serialize};
use std::borrow::BorrowMut;
@@ -61,7 +62,7 @@ pub enum MemoryError {
}
/// Implementation styles for WebAssembly linear memory.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, MemoryUsage)]
pub enum MemoryStyle {
/// The actual memory can be resized and moved.
Dynamic {
@@ -96,7 +97,7 @@ impl MemoryStyle {
}
/// Trait for implementing Wasm Memory used by Wasmer.
pub trait Memory: fmt::Debug + Send + Sync {
pub trait Memory: fmt::Debug + Send + Sync + MemoryUsage {
/// Returns the memory type for this memory.
fn ty(&self) -> &MemoryType;
@@ -116,7 +117,7 @@ pub trait Memory: fmt::Debug + Send + Sync {
}
/// A linear memory instance.
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
pub struct LinearMemory {
// The underlying allocation.
mmap: Mutex<WasmMmap>,
@@ -144,7 +145,7 @@ pub struct LinearMemory {
/// A type to help manage who is responsible for the backing memory of them
/// `VMMemoryDefinition`.
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
enum VMMemoryDefinitionOwnership {
/// The `VMMemoryDefinition` is owned by the `Instance` and we should use
/// its memory. This is how a local memory that's exported should be stored.
@@ -167,7 +168,7 @@ unsafe impl Send for LinearMemory {}
/// This is correct because all internal mutability is protected by a mutex.
unsafe impl Sync for LinearMemory {}
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
struct WasmMmap {
// Our OS allocation of mmap'd memory.
alloc: Mmap,

View File

@@ -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<T: Send + Sync>() {}
_assert_send_sync::<Mmap>();

View File

@@ -5,6 +5,7 @@
//! `wasmer::Module`.
use indexmap::IndexMap;
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
@@ -19,7 +20,7 @@ use wasmer_types::{
TableIndex, TableInitializer, TableType,
};
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
pub struct ModuleId {
id: usize,
}
@@ -41,7 +42,7 @@ impl Default for ModuleId {
/// A translated WebAssembly module, excluding the function bodies and
/// memory initializers.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, MemoryUsage)]
pub struct ModuleInfo {
/// A unique identifier (within this process) for this module.
///

View File

@@ -5,6 +5,7 @@
//! signature checking.
use crate::vmcontext::VMSharedSignatureIndex;
use loupe::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<Inner>,
}
#[derive(Debug, Default)]
#[derive(Debug, Default, MemoryUsage)]
struct Inner {
signature2index: HashMap<FunctionType, VMSharedSignatureIndex>,
index2signature: HashMap<VMSharedSignatureIndex, FunctionType>,

View File

@@ -9,6 +9,7 @@ use crate::func_data_registry::VMFuncRef;
use crate::trap::{Trap, TrapCode};
use crate::vmcontext::VMTableDefinition;
use crate::VMExternRef;
use loupe::{MemoryUsage, MemoryUsageTracker};
use serde::{Deserialize, Serialize};
use std::borrow::{Borrow, BorrowMut};
use std::cell::UnsafeCell;
@@ -19,14 +20,14 @@ use std::sync::Mutex;
use wasmer_types::{ExternRef, TableType, Type as ValType};
/// Implementation styles for WebAssembly tables.
#[derive(Debug, Clone, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Hash, Serialize, Deserialize, MemoryUsage)]
pub enum TableStyle {
/// Signatures are stored in the table and checked in the caller.
CallerChecksSignature,
}
/// Trait for implementing the interface of a Wasm table.
pub trait Table: fmt::Debug + Send + Sync {
pub trait Table: fmt::Debug + Send + Sync + MemoryUsage {
/// Returns the style for this Table.
fn style(&self) -> &TableStyle;
@@ -134,6 +135,12 @@ pub union TableElement {
pub(crate) func_ref: VMFuncRef,
}
impl MemoryUsage for TableElement {
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
std::mem::size_of_val(self)
}
}
impl fmt::Debug for TableElement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("TableElement").finish()
@@ -155,7 +162,7 @@ impl Default for TableReference {
}
/// A table instance.
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
pub struct LinearTable {
// TODO: we can remove the mutex by using atomic swaps and preallocating the max table size
vec: Mutex<Vec<TableElement>>,
@@ -169,7 +176,7 @@ pub struct LinearTable {
/// A type to help manage who is responsible for the backing table of the
/// `VMTableDefinition`.
#[derive(Debug)]
#[derive(Debug, MemoryUsage)]
enum VMTableDefinitionOwnership {
/// The `VMTableDefinition` is owned by the `Instance` and we should use
/// its table. This is how a local table that's exported should be stored.

View File

@@ -5,13 +5,14 @@
use core::fmt::{self, Display, Formatter};
use core::str::FromStr;
use loupe::MemoryUsage;
use serde::{Deserialize, Serialize};
use thiserror::Error;
/// A trap code describing the reason for a trap.
///
/// All trap instructions have an explicit trap code.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Error)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Error, MemoryUsage)]
#[repr(u32)]
pub enum TrapCode {
/// The current stack space was exhausted.

View File

@@ -11,9 +11,11 @@ use crate::memory::Memory;
use crate::table::Table;
use crate::trap::{Trap, TrapCode};
use crate::VMExternRef;
use loupe::{MemoryUsage, MemoryUsageTracker, POINTER_BYTE_SIZE};
use std::any::Any;
use std::convert::TryFrom;
use std::fmt;
use std::mem;
use std::ptr::{self, NonNull};
use std::sync::Arc;
use std::u32;
@@ -59,8 +61,14 @@ impl std::hash::Hash for VMFunctionEnvironment {
}
}
impl MemoryUsage for VMFunctionEnvironment {
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
}
}
/// An imported function.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, MemoryUsage)]
#[repr(C)]
pub struct VMFunctionImport {
/// A pointer to the imported function body.
@@ -177,7 +185,7 @@ mod test_vmfunction_body {
}
/// A function kind is a calling convention into and out of wasm code.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, MemoryUsage)]
#[repr(C)]
pub enum VMFunctionKind {
/// A static function has the native signature:
@@ -198,7 +206,7 @@ pub enum VMFunctionKind {
/// The fields compiled code needs to access to utilize a WebAssembly table
/// imported from another instance.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
#[repr(C)]
pub struct VMTableImport {
/// A pointer to the imported table description.
@@ -236,7 +244,7 @@ mod test_vmtable_import {
/// The fields compiled code needs to access to utilize a WebAssembly linear
/// memory imported from another instance.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
#[repr(C)]
pub struct VMMemoryImport {
/// A pointer to the imported memory description.
@@ -274,7 +282,7 @@ mod test_vmmemory_import {
/// The fields compiled code needs to access to utilize a WebAssembly global
/// variable imported from another instance.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
#[repr(C)]
pub struct VMGlobalImport {
/// A pointer to the imported global variable description.
@@ -346,6 +354,16 @@ unsafe impl Send for VMMemoryDefinition {}
/// correctness in a multi-threaded context is concerned.
unsafe impl Sync for VMMemoryDefinition {}
impl MemoryUsage for VMMemoryDefinition {
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
if tracker.track(self.base as *const _ as *const ()) {
POINTER_BYTE_SIZE * (self.current_length as usize)
} else {
0
}
}
}
impl VMMemoryDefinition {
/// Do an unsynchronized, non-atomic `memory.copy` for the memory.
///
@@ -455,6 +473,16 @@ pub struct VMTableDefinition {
pub current_elements: u32,
}
impl MemoryUsage for VMTableDefinition {
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
if tracker.track(self.base as *const _ as *const ()) {
POINTER_BYTE_SIZE * (self.current_elements as usize)
} else {
0
}
}
}
#[cfg(test)]
mod test_vmtable_definition {
use super::VMTableDefinition;
@@ -511,11 +539,17 @@ impl fmt::Debug for VMGlobalDefinitionStorage {
}
}
impl MemoryUsage for VMGlobalDefinitionStorage {
fn size_of_val(&self, _: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
}
}
/// The storage for a WebAssembly global defined within the instance.
///
/// TODO: Pack the globals more densely, rather than using the same size
/// for every type.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
#[repr(C, align(16))]
pub struct VMGlobalDefinition {
storage: VMGlobalDefinitionStorage,
@@ -756,7 +790,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)]
@@ -801,7 +835,7 @@ impl Default for VMSharedSignatureIndex {
/// The VM caller-checked "anyfunc" record, for caller-side signature checking.
/// It consists of the actual function pointer and a signature id to be checked
/// by the caller.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, MemoryUsage)]
#[repr(C)]
pub struct VMCallerCheckedAnyfunc {
/// Function body.

View File

@@ -8,6 +8,7 @@
use crate::module::ModuleInfo;
use crate::VMBuiltinFunctionIndex;
use loupe::MemoryUsage;
use more_asserts::assert_lt;
use std::convert::TryFrom;
use wasmer_types::{
@@ -33,7 +34,7 @@ const fn align(offset: u32, width: u32) -> u32 {
/// related structs that JIT code accesses directly.
///
/// [`VMContext`]: crate::vmcontext::VMContext
#[derive(Clone, Debug)]
#[derive(Clone, Debug, MemoryUsage)]
pub struct VMOffsets {
/// The size in bytes of a pointer on the target.
pub pointer_size: u8,

View File

@@ -13,6 +13,7 @@ edition = "2018"
[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true, default-features = false }
thiserror = "1.0"
loupe = "0.1"
[features]
default = ["std", "enable-serde"]

View File

@@ -10,6 +10,8 @@ use crate::lib::std::boxed::Box;
use crate::lib::std::marker::PhantomData;
use crate::lib::std::ops::{Index, IndexMut};
use crate::lib::std::slice;
use loupe::{MemoryUsage, MemoryUsageTracker};
use std::mem;
/// A slice mapping `K -> V` allocating dense entity references.
///
@@ -144,6 +146,21 @@ where
}
}
impl<K, V> MemoryUsage for BoxedSlice<K, V>
where
K: EntityRef,
V: MemoryUsage,
{
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
+ self
.elems
.iter()
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
.sum::<usize>()
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@@ -12,8 +12,10 @@ use crate::lib::std::marker::PhantomData;
use crate::lib::std::ops::{Index, IndexMut};
use crate::lib::std::slice;
use crate::lib::std::vec::Vec;
use loupe::{MemoryUsage, MemoryUsageTracker};
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use std::mem;
/// A primary mapping `K -> V` allocating dense entity references.
///
@@ -236,6 +238,21 @@ where
}
}
impl<K, V> MemoryUsage for PrimaryMap<K, V>
where
K: EntityRef,
V: MemoryUsage,
{
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
+ self
.elems
.iter()
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
.sum::<usize>()
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@@ -11,12 +11,14 @@ use crate::lib::std::marker::PhantomData;
use crate::lib::std::ops::{Index, IndexMut};
use crate::lib::std::slice;
use crate::lib::std::vec::Vec;
use loupe::{MemoryUsage, MemoryUsageTracker};
#[cfg(feature = "enable-serde")]
use serde::{
de::{Deserializer, SeqAccess, Visitor},
ser::{SerializeSeq, Serializer},
Deserialize, Serialize,
};
use std::mem;
/// A mapping `K -> V` for densely indexed entity references.
///
@@ -279,6 +281,21 @@ where
}
}
impl<K, V> MemoryUsage for SecondaryMap<K, V>
where
K: EntityRef,
V: Clone + MemoryUsage,
{
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
mem::size_of_val(self)
+ self
.elems
.iter()
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value))
.sum::<usize>()
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@@ -1,3 +1,4 @@
use loupe::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

View File

@@ -1,83 +1,84 @@
//! Helper functions and structures for the translation.
use crate::entity::entity_impl;
use core::u32;
use loupe::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.

View File

@@ -1,11 +1,12 @@
use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex};
use crate::lib::std::boxed::Box;
use loupe::MemoryUsage;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
/// A WebAssembly table initializer.
#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
#[derive(Clone, Debug, Hash, Serialize, Deserialize, MemoryUsage)]
pub struct TableInitializer {
/// The index of a table to initialize.
pub table_index: TableIndex,
@@ -19,7 +20,7 @@ pub struct TableInitializer {
/// A memory index and offset within that memory where a data initialization
/// should be performed.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct DataInitializerLocation {
/// The index of the memory to initialize.
@@ -45,7 +46,7 @@ pub struct DataInitializer<'data> {
/// As `DataInitializer` but owning the data rather than
/// holding a reference to it
#[derive(Debug, Clone)]
#[derive(Debug, Clone, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct OwnedDataInitializer {
/// The location where the initialization is to be performed.

View File

@@ -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, ValueEnumType};
use loupe::{MemoryUsage, MemoryUsageTracker};
#[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.
@@ -97,6 +98,12 @@ impl From<&[u8]> for V128 {
}
}
impl MemoryUsage for V128 {
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize {
self.as_slice().size_of_val(tracker)
}
}
// External Types
/// A list of all possible types which can be externally referenced from a
@@ -225,7 +232,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
@@ -310,7 +317,7 @@ impl From<&FunctionType> for FunctionType {
}
/// Indicator of whether a global is mutable or not
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum Mutability {
/// The global is constant and its value does not change
@@ -346,7 +353,7 @@ impl From<Mutability> for bool {
}
/// WebAssembly global.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct GlobalType {
/// The type of the value stored in the global.
@@ -389,7 +396,7 @@ impl fmt::Display for GlobalType {
}
/// Globals are initialized via the `const` operators or by referring to another import.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum GlobalInit {
/// An `i32.const`.
@@ -441,7 +448,7 @@ impl GlobalInit {
/// Tables are contiguous chunks of a specific element, typically a `funcref` or
/// an `externref`. The most common use for tables is a function table through
/// which `call_indirect` can invoke other functions.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct TableType {
/// The type of data stored in elements of the table.
@@ -480,7 +487,7 @@ impl fmt::Display for TableType {
///
/// Memories are described in units of pages (64KB) and represent contiguous
/// chunks of addressable memory.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, MemoryUsage)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct MemoryType {
/// The minimum number of pages in the memory.

View File

@@ -1,6 +1,7 @@
use crate::lib::std::convert::TryFrom;
use crate::lib::std::fmt;
use crate::lib::std::ops::{Add, Sub};
use loupe::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);

View File

@@ -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)]

View File

@@ -15,6 +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 = "0.1"
[features]
# Enable the `compiler` feature if you want the engine to compile

View File

@@ -2,6 +2,7 @@
//! done as separate steps.
use crate::engine::DummyEngine;
use loupe::MemoryUsage;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::sync::Arc;
@@ -21,6 +22,7 @@ use wasmer_vm::{
/// Serializable struct for the artifact
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(MemoryUsage)]
pub struct DummyArtifactMetadata {
pub module: Arc<ModuleInfo>,
pub features: Features,
@@ -34,10 +36,11 @@ pub struct DummyArtifactMetadata {
///
/// This artifact will point to fake finished functions and trampolines
/// as no functions are really compiled.
#[derive(MemoryUsage)]
pub struct DummyArtifact {
metadata: DummyArtifactMetadata,
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
#[loupe(skip)]
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,

View File

@@ -1,6 +1,7 @@
//! Dummy Engine.
use crate::DummyArtifact;
use loupe::MemoryUsage;
use std::sync::Arc;
use wasmer_compiler::{CompileError, Features, Target};
use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables};
@@ -20,7 +21,7 @@ extern "C" fn dummy_trampoline(
}
/// A WebAssembly `Dummy` Engine.
#[derive(Clone)]
#[derive(Clone, MemoryUsage)]
pub struct DummyEngine {
signatures: Arc<SignatureRegistry>,
func_data: Arc<FuncDataRegistry>,