mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 04:38:25 +00:00
Merge branch 'master' into feature/reference-types
This commit is contained in:
@@ -18,6 +18,9 @@
|
|||||||
- [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers
|
- [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers
|
||||||
|
|
||||||
### Changed
|
### 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.
|
- [#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
|
- [#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
|
- [#2144](https://github.com/wasmerio/wasmer/pull/2144) Bump cranelift version to 0.70
|
||||||
|
|||||||
93
Cargo.lock
generated
93
Cargo.lock
generated
@@ -545,9 +545,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "csv"
|
name = "csv"
|
||||||
version = "1.1.5"
|
version = "1.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97"
|
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bstr",
|
"bstr",
|
||||||
"csv-core",
|
"csv-core",
|
||||||
@@ -941,9 +941,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.6.1"
|
version = "1.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
|
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -1088,9 +1088,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.87"
|
version = "0.2.88"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213"
|
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libffi"
|
name = "libffi"
|
||||||
@@ -1154,6 +1154,27 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"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]]
|
[[package]]
|
||||||
name = "mach"
|
name = "mach"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -1372,9 +1393,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "paste"
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1"
|
checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peeking_take_while"
|
name = "peeking_take_while"
|
||||||
@@ -1393,9 +1414,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a"
|
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
@@ -1627,14 +1648,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.4.3"
|
version = "1.4.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
|
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
"thread_local",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1648,9 +1668,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.6.22"
|
version = "0.6.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
|
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "region"
|
name = "region"
|
||||||
@@ -1825,9 +1845,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.123"
|
version = "1.0.124"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
|
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
@@ -1853,9 +1873,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.123"
|
version = "1.0.124"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
|
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1922,9 +1942,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.60"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2041,15 +2061,6 @@ dependencies = [
|
|||||||
"syn",
|
"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]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.43"
|
version = "0.1.43"
|
||||||
@@ -2094,9 +2105,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.13"
|
version = "0.1.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07"
|
checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2120,9 +2131,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.12.0"
|
version = "1.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
|
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typetag"
|
name = "typetag"
|
||||||
@@ -2295,6 +2306,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"libc",
|
"libc",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
@@ -2390,6 +2402,7 @@ version = "1.0.2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"enumset",
|
"enumset",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -2410,6 +2423,7 @@ dependencies = [
|
|||||||
"gimli",
|
"gimli",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2432,6 +2446,7 @@ dependencies = [
|
|||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
"loupe",
|
||||||
"rayon",
|
"rayon",
|
||||||
"regex",
|
"regex",
|
||||||
"rustc_version 0.2.3",
|
"rustc_version 0.2.3",
|
||||||
@@ -2452,6 +2467,7 @@ dependencies = [
|
|||||||
"dynasmrt",
|
"dynasmrt",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2494,6 +2510,7 @@ dependencies = [
|
|||||||
"backtrace",
|
"backtrace",
|
||||||
"bincode",
|
"bincode",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
@@ -2511,6 +2528,7 @@ name = "wasmer-engine-dummy"
|
|||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"wasmer-compiler",
|
"wasmer-compiler",
|
||||||
@@ -2525,6 +2543,7 @@ version = "1.0.2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
|
"loupe",
|
||||||
"region",
|
"region",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
@@ -2543,6 +2562,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"leb128",
|
"leb128",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2562,6 +2582,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"leb128",
|
"leb128",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2584,6 +2605,7 @@ dependencies = [
|
|||||||
name = "wasmer-middlewares"
|
name = "wasmer-middlewares"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"loupe",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
@@ -2603,6 +2625,7 @@ dependencies = [
|
|||||||
name = "wasmer-types"
|
name = "wasmer-types"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
@@ -2616,6 +2639,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"libc",
|
"libc",
|
||||||
|
"loupe",
|
||||||
"memoffset",
|
"memoffset",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"region",
|
"region",
|
||||||
@@ -2680,6 +2704,7 @@ dependencies = [
|
|||||||
"criterion",
|
"criterion",
|
||||||
"glob",
|
"glob",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"rustc_version 0.3.3",
|
"rustc_version 0.3.3",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"test-generator",
|
"test-generator",
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ criterion = "0.3"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
|
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Don't add the compiler features in default, please add them on the Makefile
|
# Don't add the compiler features in default, please add them on the Makefile
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -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).
|
[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
|
## Features
|
||||||
|
|
||||||
* **Fast & Safe**. Wasmer runs WebAssembly at *near-native* speed in a fully sandboxed environment.
|
* **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=)
|
[👋 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
|
[rust integration]: https://github.com/wasmerio/wasmer/tree/master/lib/api
|
||||||
[`wasmer` rust crate]: https://crates.io/crates/wasmer/
|
[`wasmer` rust crate]: https://crates.io/crates/wasmer/
|
||||||
[rust docs]: https://wasmerio.github.io/wasmer/crates/wasmer_runtime
|
[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
|
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
|
||||||
[`wasmer.h` headers]: https://wasmerio.github.io/wasmer/c/
|
[`wasmer.h` headers]: https://wasmerio.github.io/wasmer/c/
|
||||||
[c docs]: 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
|
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
|
||||||
[`wasmersharp` nuget package]: https://www.nuget.org/packages/WasmerSharp/
|
[`wasmersharp` nuget package]: https://www.nuget.org/packages/WasmerSharp/
|
||||||
[c# docs]: https://migueldeicaza.github.io/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
|
[d integration]: https://github.com/chances/wasmer-d
|
||||||
[`wasmer` Dub package]: https://code.dlang.org/packages/wasmer
|
[`wasmer` Dub package]: https://code.dlang.org/packages/wasmer
|
||||||
[d docs]: https://chances.github.io/wasmer-d
|
[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
|
[python integration]: https://github.com/wasmerio/wasmer-python
|
||||||
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
|
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
|
||||||
[python docs]: https://github.com/wasmerio/wasmer-python#api-of-the-wasmer-extensionmodule
|
[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
|
[go integration]: https://github.com/wasmerio/wasmer-go
|
||||||
[`wasmer` go package]: https://pkg.go.dev/github.com/wasmerio/wasmer-go/wasmer
|
[`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
|
[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
|
[php integration]: https://github.com/wasmerio/wasmer-php
|
||||||
[`wasm` pecl package]: https://pecl.php.net/package/wasm
|
[`wasm` pecl package]: https://pecl.php.net/package/wasm
|
||||||
[php docs]: https://wasmerio.github.io/wasmer-php/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
|
[js integration]: https://github.com/wasmerio/wasmer-js
|
||||||
[`@wasmerio` npm packages]: https://www.npmjs.com/org/wasmer
|
[`@wasmerio` npm packages]: https://www.npmjs.com/org/wasmer
|
||||||
[js docs]: https://docs.wasmer.io/integrations/js/reference-api
|
[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
|
[ruby integration]: https://github.com/wasmerio/wasmer-ruby
|
||||||
[`wasmer` ruby gem]: https://rubygems.org/gems/wasmer
|
[`wasmer` ruby gem]: https://rubygems.org/gems/wasmer
|
||||||
[ruby docs]: https://www.rubydoc.info/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
|
[java integration]: https://github.com/wasmerio/wasmer-java
|
||||||
[`wasmer/wasmer-jni` bintray package]: https://bintray.com/wasmer/wasmer-jni/wasmer-jni
|
[`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
|
[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 integration]: https://github.com/tessi/wasmex
|
||||||
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
|
[elixir docs]: https://hexdocs.pm/wasmex/api-reference.html
|
||||||
[`wasmex` hex package]: https://hex.pm/packages/wasmex
|
[`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 integration]: https://github.com/dirkschumacher/wasmr
|
||||||
[r docs]: https://github.com/dirkschumacher/wasmr#example
|
[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 integration]: https://github.com/wasmerio/wasmer-postgres
|
||||||
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation
|
[postgres docs]: https://github.com/wasmerio/wasmer-postgres#usage--documentation
|
||||||
|
|
||||||
|
|||||||
192
docs/cn/README.md
Normal file
192
docs/cn/README.md
Normal 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支持不同的编译框架以最适合您的需求(LLVM,Cranelift ...).
|
||||||
|
|
||||||
|
* **普遍的**. 您可以在任何*平台*(macOS,Linux和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.
|
||||||
|
|
||||||
|
| | 语言 | 箱 | 文件资料 |
|
||||||
|
|-|-|-|-|
|
||||||
|
| ![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
191
docs/es/README.md
Normal 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_.
|
||||||
|
|
||||||
|
| | 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
191
docs/fr/README.md
Normal 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ù_.
|
||||||
|
|
||||||
|
| | 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)
|
||||||
@@ -45,6 +45,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// (`Cranelift`) and pass it to an engine (`JIT`). We then pass the engine to
|
// (`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!
|
// the store and are now ready to compile and run WebAssembly!
|
||||||
let store = Store::new(&JIT::new(Cranelift::default()).engine());
|
let store = Store::new(&JIT::new(Cranelift::default()).engine());
|
||||||
|
|
||||||
// We then use our store and Wasm bytes to compile a `Module`.
|
// 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.
|
// A `Module` is a compiled WebAssembly module that isn't ready to execute yet.
|
||||||
let module = Module::new(&store, wasm_bytes)?;
|
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
|
// An `Instance` is a compiled WebAssembly module that has been set up
|
||||||
// and is ready to execute.
|
// and is ready to execute.
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
// We get the `NativeFunc` with no parameters and no results from the instance.
|
// 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
|
// Recall that the Wasm module exported a function named "run", this is getting
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use wasmer::{
|
use wasmer::{
|
||||||
imports,
|
imports,
|
||||||
vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition},
|
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
|
/// After adjusting the memory limits, it delegates all other logic
|
||||||
/// to the base tunables.
|
/// to the base tunables.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct LimitingTunables<T: Tunables> {
|
pub struct LimitingTunables<T: Tunables> {
|
||||||
/// The maximum a linear memory is allowed to be (in Wasm pages, 64 KiB each).
|
/// 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
|
/// Since Wasmer ensures there is only none or one memory, this is practically
|
||||||
|
|||||||
58
fuzz/Cargo.lock
generated
58
fuzz/Cargo.lock
generated
@@ -28,9 +28,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.38"
|
version = "1.0.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
|
checksum = "81cddc5f91628367664cc7c69714ff08deee8a3efc54623011c772544d7b2767"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arbitrary"
|
name = "arbitrary"
|
||||||
@@ -454,9 +454,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.89"
|
version = "0.2.91"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6"
|
checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libfuzzer-sys"
|
name = "libfuzzer-sys"
|
||||||
@@ -509,6 +509,27 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"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]]
|
[[package]]
|
||||||
name = "mach"
|
name = "mach"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -822,6 +843,12 @@ dependencies = [
|
|||||||
"semver 0.9.0",
|
"semver 0.9.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -883,9 +910,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.124"
|
version = "1.0.125"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
|
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
@@ -901,9 +928,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.124"
|
version = "1.0.125"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
|
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1038,7 +1065,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-encoder"
|
name = "wasm-encoder"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasm-tools#ea17086f38b3bd452a99340109bfdc9759f109a1"
|
source = "git+https://github.com/bytecodealliance/wasm-tools#4e86f2a84fc54264388040b200eb32a165ec6453"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leb128",
|
"leb128",
|
||||||
]
|
]
|
||||||
@@ -1046,7 +1073,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-smith"
|
name = "wasm-smith"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasm-tools#ea17086f38b3bd452a99340109bfdc9759f109a1"
|
source = "git+https://github.com/bytecodealliance/wasm-tools#4e86f2a84fc54264388040b200eb32a165ec6453"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@@ -1060,6 +1087,7 @@ version = "1.0.2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
@@ -1096,6 +1124,7 @@ name = "wasmer-compiler"
|
|||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enumset",
|
"enumset",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -1114,6 +1143,7 @@ dependencies = [
|
|||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
"cranelift-frontend",
|
"cranelift-frontend",
|
||||||
"gimli",
|
"gimli",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -1135,6 +1165,7 @@ dependencies = [
|
|||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
"loupe",
|
||||||
"rayon",
|
"rayon",
|
||||||
"regex",
|
"regex",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
@@ -1154,6 +1185,7 @@ dependencies = [
|
|||||||
"dynasm",
|
"dynasm",
|
||||||
"dynasmrt",
|
"dynasmrt",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -1180,6 +1212,7 @@ dependencies = [
|
|||||||
"backtrace",
|
"backtrace",
|
||||||
"bincode",
|
"bincode",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"loupe",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
@@ -1198,6 +1231,7 @@ version = "1.0.2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
|
"loupe",
|
||||||
"region",
|
"region",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
@@ -1216,6 +1250,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"leb128",
|
"leb128",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -1231,6 +1266,7 @@ dependencies = [
|
|||||||
name = "wasmer-middlewares"
|
name = "wasmer-middlewares"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"loupe",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
@@ -1250,6 +1286,7 @@ dependencies = [
|
|||||||
name = "wasmer-types"
|
name = "wasmer-types"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"loupe",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
@@ -1263,6 +1300,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"libc",
|
"libc",
|
||||||
|
"loupe",
|
||||||
"memoffset",
|
"memoffset",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
"region",
|
"region",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ wat = { version = "1.0", optional = true }
|
|||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
more-asserts = "0.2"
|
more-asserts = "0.2"
|
||||||
target-lexicon = { version = "0.11", default-features = false }
|
target-lexicon = { version = "0.11", default-features = false }
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = "0.3"
|
winapi = "0.3"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::import_object::LikeNamespace;
|
|||||||
use crate::native::NativeFunc;
|
use crate::native::NativeFunc;
|
||||||
use crate::WasmTypeList;
|
use crate::WasmTypeList;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter::{ExactSizeIterator, FromIterator};
|
use std::iter::{ExactSizeIterator, FromIterator};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -61,7 +62,7 @@ pub enum ExportError {
|
|||||||
/// the types of instances.
|
/// the types of instances.
|
||||||
///
|
///
|
||||||
/// TODO: add examples of using exports
|
/// TODO: add examples of using exports
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default, MemoryUsage)]
|
||||||
pub struct Exports {
|
pub struct Exports {
|
||||||
map: Arc<IndexMap<String, Extern>>,
|
map: Arc<IndexMap<String, Extern>>,
|
||||||
}
|
}
|
||||||
|
|||||||
10
lib/api/src/externals/function.rs
vendored
10
lib/api/src/externals/function.rs
vendored
@@ -10,6 +10,7 @@ pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, Witho
|
|||||||
#[cfg(feature = "deprecated")]
|
#[cfg(feature = "deprecated")]
|
||||||
pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv};
|
pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv};
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -22,21 +23,22 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A function defined in the Wasm module
|
/// A function defined in the Wasm module
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, MemoryUsage)]
|
||||||
pub struct WasmFunctionDefinition {
|
pub struct WasmFunctionDefinition {
|
||||||
// Address of the trampoline to do the call.
|
// Address of the trampoline to do the call.
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) trampoline: VMTrampoline,
|
pub(crate) trampoline: VMTrampoline,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function defined in the Host
|
/// A function defined in the Host
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, MemoryUsage)]
|
||||||
pub struct HostFunctionDefinition {
|
pub struct HostFunctionDefinition {
|
||||||
/// If the host function has a custom environment attached
|
/// If the host function has a custom environment attached
|
||||||
pub(crate) has_env: bool,
|
pub(crate) has_env: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The inner helper
|
/// The inner helper
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, MemoryUsage)]
|
||||||
pub enum FunctionDefinition {
|
pub enum FunctionDefinition {
|
||||||
/// A function defined in the Wasm side
|
/// A function defined in the Wasm side
|
||||||
Wasm(WasmFunctionDefinition),
|
Wasm(WasmFunctionDefinition),
|
||||||
@@ -61,7 +63,7 @@ pub enum FunctionDefinition {
|
|||||||
/// with native functions. Attempting to create a native `Function` with one will
|
/// with native functions. Attempting to create a native `Function` with one will
|
||||||
/// result in a panic.
|
/// result in a panic.
|
||||||
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
|
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, MemoryUsage)]
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
pub(crate) store: Store,
|
pub(crate) store: Store,
|
||||||
pub(crate) definition: FunctionDefinition,
|
pub(crate) definition: FunctionDefinition,
|
||||||
|
|||||||
3
lib/api/src/externals/global.rs
vendored
3
lib/api/src/externals/global.rs
vendored
@@ -5,6 +5,7 @@ use crate::types::Val;
|
|||||||
use crate::GlobalType;
|
use crate::GlobalType;
|
||||||
use crate::Mutability;
|
use crate::Mutability;
|
||||||
use crate::RuntimeError;
|
use crate::RuntimeError;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_engine::{Export, ExportGlobal};
|
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.
|
/// 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>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#global-instances>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct Global {
|
pub struct Global {
|
||||||
store: Store,
|
store: Store,
|
||||||
global: Arc<RuntimeGlobal>,
|
global: Arc<RuntimeGlobal>,
|
||||||
|
|||||||
3
lib/api/src/externals/memory.rs
vendored
3
lib/api/src/externals/memory.rs
vendored
@@ -2,6 +2,7 @@ use crate::exports::{ExportError, Exportable};
|
|||||||
use crate::externals::Extern;
|
use crate::externals::Extern;
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
use crate::{MemoryType, MemoryView};
|
use crate::{MemoryType, MemoryView};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -23,7 +24,7 @@ use wasmer_vm::{Memory as RuntimeMemory, MemoryError, VMExportMemory};
|
|||||||
/// mutable from both host and WebAssembly.
|
/// mutable from both host and WebAssembly.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
pub struct Memory {
|
pub struct Memory {
|
||||||
store: Store,
|
store: Store,
|
||||||
memory: Arc<dyn RuntimeMemory>,
|
memory: Arc<dyn RuntimeMemory>,
|
||||||
|
|||||||
3
lib/api/src/externals/mod.rs
vendored
3
lib/api/src/externals/mod.rs
vendored
@@ -16,6 +16,7 @@ pub use self::table::Table;
|
|||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::store::{Store, StoreObject};
|
use crate::store::{Store, StoreObject};
|
||||||
use crate::ExternType;
|
use crate::ExternType;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use wasmer_engine::Export;
|
use wasmer_engine::Export;
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ use wasmer_engine::Export;
|
|||||||
/// can be imported or exported.
|
/// can be imported or exported.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub enum Extern {
|
pub enum Extern {
|
||||||
/// A external [`Function`].
|
/// A external [`Function`].
|
||||||
Function(Function),
|
Function(Function),
|
||||||
|
|||||||
3
lib/api/src/externals/table.rs
vendored
3
lib/api/src/externals/table.rs
vendored
@@ -4,6 +4,7 @@ use crate::store::Store;
|
|||||||
use crate::types::{Val, ValFuncRef};
|
use crate::types::{Val, ValFuncRef};
|
||||||
use crate::RuntimeError;
|
use crate::RuntimeError;
|
||||||
use crate::TableType;
|
use crate::TableType;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_engine::{Export, ExportTable};
|
use wasmer_engine::{Export, ExportTable};
|
||||||
use wasmer_vm::{Table as RuntimeTable, TableReference, VMExportTable};
|
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.
|
/// mutable from both host and WebAssembly.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
store: Store,
|
store: Store,
|
||||||
table: Arc<dyn RuntimeTable>,
|
table: Arc<dyn RuntimeTable>,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::externals::Extern;
|
|||||||
use crate::module::Module;
|
use crate::module::Module;
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
use crate::{HostEnvInitError, LinkError, RuntimeError};
|
use crate::{HostEnvInitError, LinkError, RuntimeError};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@@ -17,7 +18,7 @@ use wasmer_vm::{InstanceHandle, VMContext};
|
|||||||
/// interacting with WebAssembly.
|
/// interacting with WebAssembly.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct Instance {
|
pub struct Instance {
|
||||||
handle: Arc<Mutex<InstanceHandle>>,
|
handle: Arc<Mutex<InstanceHandle>>,
|
||||||
module: Module,
|
module: Module,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
use crate::types::{ExportType, ImportType};
|
use crate::types::{ExportType, ImportType};
|
||||||
use crate::InstantiationError;
|
use crate::InstantiationError;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -30,7 +31,7 @@ pub enum IoCompileError {
|
|||||||
///
|
///
|
||||||
/// Cloning a module is cheap: it does a shallow copy of the compiled
|
/// Cloning a module is cheap: it does a shallow copy of the compiled
|
||||||
/// contents rather than a deep copy.
|
/// contents rather than a deep copy.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
store: Store,
|
store: Store,
|
||||||
artifact: Arc<dyn Artifact>,
|
artifact: Arc<dyn Artifact>,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::tunables::BaseTunables;
|
use crate::tunables::BaseTunables;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(all(feature = "compiler", feature = "engine"))]
|
#[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).
|
/// [`Tunables`] (that are used to create the memories, tables and globals).
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct Store {
|
pub struct Store {
|
||||||
engine: Arc<dyn Engine + Send + Sync>,
|
engine: Arc<dyn Engine + Send + Sync>,
|
||||||
tunables: Arc<dyn Tunables + Send + Sync>,
|
tunables: Arc<dyn Tunables + Send + Sync>,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::{MemoryType, Pages, TableType};
|
use crate::{MemoryType, Pages, TableType};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -19,7 +20,7 @@ use wasmer_vm::{
|
|||||||
/// implementation or use composition to wrap your Tunables around
|
/// implementation or use composition to wrap your Tunables around
|
||||||
/// this one. The later approach is demonstrated in the
|
/// this one. The later approach is demonstrated in the
|
||||||
/// tunables-limit-memory example.
|
/// tunables-limit-memory example.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct BaseTunables {
|
pub struct BaseTunables {
|
||||||
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
|
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
|
||||||
pub static_memory_bound: Pages,
|
pub static_memory_bound: Pages,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
more-asserts = "0.2"
|
more-asserts = "0.2"
|
||||||
gimli = { version = "0.23", optional = true }
|
gimli = { version = "0.23", optional = true }
|
||||||
smallvec = "1.6"
|
smallvec = "1.6"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
target-lexicon = { version = "0.11", default-features = false }
|
target-lexicon = { version = "0.11", default-features = false }
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use cranelift_codegen::print_errors::pretty_error;
|
|||||||
use cranelift_codegen::{binemit, Context};
|
use cranelift_codegen::{binemit, Context};
|
||||||
#[cfg(feature = "unwind")]
|
#[cfg(feature = "unwind")]
|
||||||
use gimli::write::{Address, EhFrame, FrameTable};
|
use gimli::write::{Address, EhFrame, FrameTable};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_compiler::CompileError;
|
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,
|
/// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR,
|
||||||
/// optimizing it and then translating to assembly.
|
/// optimizing it and then translating to assembly.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct CraneliftCompiler {
|
pub struct CraneliftCompiler {
|
||||||
config: Cranelift,
|
config: Cranelift,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::compiler::CraneliftCompiler;
|
use crate::compiler::CraneliftCompiler;
|
||||||
use cranelift_codegen::isa::{lookup, TargetIsa};
|
use cranelift_codegen::isa::{lookup, TargetIsa};
|
||||||
use cranelift_codegen::settings::{self, Configurable};
|
use cranelift_codegen::settings::{self, Configurable};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_compiler::{
|
use wasmer_compiler::{
|
||||||
Architecture, Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target,
|
Architecture, Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target,
|
||||||
@@ -10,7 +11,7 @@ use wasmer_compiler::{
|
|||||||
|
|
||||||
/// Possible optimization levels for the Cranelift codegen backend.
|
/// Possible optimization levels for the Cranelift codegen backend.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, MemoryUsage)]
|
||||||
pub enum CraneliftOptLevel {
|
pub enum CraneliftOptLevel {
|
||||||
/// No optimizations performed, minimizes compilation time by disabling most
|
/// No optimizations performed, minimizes compilation time by disabling most
|
||||||
/// optimizations.
|
/// optimizations.
|
||||||
@@ -27,7 +28,7 @@ pub enum CraneliftOptLevel {
|
|||||||
///
|
///
|
||||||
/// This structure exposes a builder-like interface and is primarily
|
/// This structure exposes a builder-like interface and is primarily
|
||||||
/// consumed by `wasmer_engine::Engine::new`.
|
/// consumed by `wasmer_engine::Engine::new`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
pub struct Cranelift {
|
pub struct Cranelift {
|
||||||
enable_nan_canonicalization: bool,
|
enable_nan_canonicalization: bool,
|
||||||
enable_verifier: bool,
|
enable_verifier: bool,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ libc = { version = "^0.2", default-features = false }
|
|||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
rayon = "1.5"
|
rayon = "1.5"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[dependencies.inkwell]
|
[dependencies.inkwell]
|
||||||
version = "=0.1.0-beta.2"
|
version = "=0.1.0-beta.2"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use inkwell::memory_buffer::MemoryBuffer;
|
|||||||
use inkwell::module::{Linkage, Module};
|
use inkwell::module::{Linkage, Module};
|
||||||
use inkwell::targets::FileType;
|
use inkwell::targets::FileType;
|
||||||
use inkwell::DLLStorageClass;
|
use inkwell::DLLStorageClass;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use rayon::iter::ParallelBridge;
|
use rayon::iter::ParallelBridge;
|
||||||
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||||
use std::sync::Arc;
|
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,
|
/// A compiler that compiles a WebAssembly module with LLVM, translating the Wasm to LLVM IR,
|
||||||
/// optimizing it and then translating to assembly.
|
/// optimizing it and then translating to assembly.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct LLVMCompiler {
|
pub struct LLVMCompiler {
|
||||||
config: LLVM,
|
config: LLVM,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use inkwell::targets::{
|
|||||||
};
|
};
|
||||||
pub use inkwell::OptimizationLevel as LLVMOptLevel;
|
pub use inkwell::OptimizationLevel as LLVMOptLevel;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use target_lexicon::Architecture;
|
use target_lexicon::Architecture;
|
||||||
@@ -37,12 +38,14 @@ pub trait LLVMCallbacks: Debug + Send + Sync {
|
|||||||
fn obj_memory_buffer(&self, function: &CompiledKind, memory_buffer: &InkwellMemoryBuffer);
|
fn obj_memory_buffer(&self, function: &CompiledKind, memory_buffer: &InkwellMemoryBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
pub struct LLVM {
|
pub struct LLVM {
|
||||||
pub(crate) enable_nan_canonicalization: bool,
|
pub(crate) enable_nan_canonicalization: bool,
|
||||||
pub(crate) enable_verifier: bool,
|
pub(crate) enable_verifier: bool,
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) opt_level: LLVMOptLevel,
|
pub(crate) opt_level: LLVMOptLevel,
|
||||||
is_pic: bool,
|
is_pic: bool,
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) callbacks: Option<Arc<dyn LLVMCallbacks>>,
|
pub(crate) callbacks: Option<Arc<dyn LLVMCallbacks>>,
|
||||||
/// The middleware chain.
|
/// The middleware chain.
|
||||||
pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
|
pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ dynasmrt = "1.0"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
smallvec = "1.6"
|
smallvec = "1.6"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
target-lexicon = { version = "0.11", default-features = false }
|
target-lexicon = { version = "0.11", default-features = false }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use crate::codegen_x64::{
|
|||||||
CodegenError, FuncGen,
|
CodegenError, FuncGen,
|
||||||
};
|
};
|
||||||
use crate::config::Singlepass;
|
use crate::config::Singlepass;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
use rayon::prelude::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_compiler::TrapInformation;
|
use wasmer_compiler::TrapInformation;
|
||||||
@@ -22,6 +23,7 @@ use wasmer_vm::{ModuleInfo, TrapCode, VMOffsets};
|
|||||||
|
|
||||||
/// A compiler that compiles a WebAssembly module with Singlepass.
|
/// A compiler that compiles a WebAssembly module with Singlepass.
|
||||||
/// It does the compilation in one pass
|
/// It does the compilation in one pass
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct SinglepassCompiler {
|
pub struct SinglepassCompiler {
|
||||||
config: Singlepass,
|
config: Singlepass,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
#![allow(unused_imports, dead_code)]
|
#![allow(unused_imports, dead_code)]
|
||||||
|
|
||||||
use crate::compiler::SinglepassCompiler;
|
use crate::compiler::SinglepassCompiler;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target};
|
use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, ModuleMiddleware, Target};
|
||||||
use wasmer_types::Features;
|
use wasmer_types::Features;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
pub struct Singlepass {
|
pub struct Singlepass {
|
||||||
pub(crate) enable_nan_canonicalization: bool,
|
pub(crate) enable_nan_canonicalization: bool,
|
||||||
pub(crate) enable_stack_check: bool,
|
pub(crate) enable_stack_check: bool,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
|
|||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
serde_bytes = { version = "0.11", optional = true }
|
serde_bytes = { version = "0.11", optional = true }
|
||||||
smallvec = "1.6"
|
smallvec = "1.6"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "enable-serde"]
|
default = ["std", "enable-serde"]
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
use crate::sourceloc::SourceLoc;
|
use crate::sourceloc::SourceLoc;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Single source location to generated address mapping.
|
/// Single source location to generated address mapping.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct InstructionAddressMap {
|
pub struct InstructionAddressMap {
|
||||||
/// Original source location.
|
/// Original source location.
|
||||||
pub srcloc: SourceLoc,
|
pub srcloc: SourceLoc,
|
||||||
@@ -22,7 +23,7 @@ pub struct InstructionAddressMap {
|
|||||||
|
|
||||||
/// Function and its instructions addresses mappings.
|
/// Function and its instructions addresses mappings.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
|
||||||
pub struct FunctionAddressMap {
|
pub struct FunctionAddressMap {
|
||||||
/// Instructions maps.
|
/// Instructions maps.
|
||||||
/// The array is sorted by the InstructionAddressMap::code_offset field.
|
/// The array is sorted by the InstructionAddressMap::code_offset field.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use crate::translator::ModuleMiddleware;
|
|||||||
use crate::FunctionBodyData;
|
use crate::FunctionBodyData;
|
||||||
use crate::ModuleTranslationState;
|
use crate::ModuleTranslationState;
|
||||||
use crate::SectionIndex;
|
use crate::SectionIndex;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use wasmer_types::entity::PrimaryMap;
|
use wasmer_types::entity::PrimaryMap;
|
||||||
use wasmer_types::{Features, FunctionIndex, LocalFunctionIndex, SignatureIndex};
|
use wasmer_types::{Features, FunctionIndex, LocalFunctionIndex, SignatureIndex};
|
||||||
use wasmparser::{Validator, WasmFeatures};
|
use wasmparser::{Validator, WasmFeatures};
|
||||||
@@ -58,7 +59,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An implementation of a Compiler from parsed WebAssembly module to Compiled native code.
|
/// 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.
|
/// Validates a module.
|
||||||
///
|
///
|
||||||
/// It returns the a succesful Result in case is valid, `CompileError` in case is not.
|
/// It returns the a succesful Result in case is valid, `CompileError` in case is not.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use crate::lib::std::vec::Vec;
|
|||||||
use crate::section::{CustomSection, SectionIndex};
|
use crate::section::{CustomSection, SectionIndex};
|
||||||
use crate::trap::TrapInformation;
|
use crate::trap::TrapInformation;
|
||||||
use crate::{CompiledFunctionUnwindInfo, FunctionAddressMap, JumpTableOffsets, Relocation};
|
use crate::{CompiledFunctionUnwindInfo, FunctionAddressMap, JumpTableOffsets, Relocation};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_types::entity::PrimaryMap;
|
use wasmer_types::entity::PrimaryMap;
|
||||||
@@ -22,7 +23,7 @@ use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex};
|
|||||||
/// This structure is only used for reconstructing
|
/// This structure is only used for reconstructing
|
||||||
/// the frame information after a `Trap`.
|
/// the frame information after a `Trap`.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, MemoryUsage)]
|
||||||
pub struct CompiledFunctionFrameInfo {
|
pub struct CompiledFunctionFrameInfo {
|
||||||
/// The traps (in the function body).
|
/// The traps (in the function body).
|
||||||
///
|
///
|
||||||
@@ -35,7 +36,7 @@ pub struct CompiledFunctionFrameInfo {
|
|||||||
|
|
||||||
/// The function body.
|
/// The function body.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct FunctionBody {
|
pub struct FunctionBody {
|
||||||
/// The function body bytes.
|
/// The function body bytes.
|
||||||
#[cfg_attr(feature = "enable-serde", serde(with = "serde_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
|
/// In the future this structure may also hold other information useful
|
||||||
/// for debugging.
|
/// for debugging.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone, MemoryUsage)]
|
||||||
pub struct Dwarf {
|
pub struct Dwarf {
|
||||||
/// The section index in the [`Compilation`] that corresponds to the exception frames.
|
/// The section index in the [`Compilation`] that corresponds to the exception frames.
|
||||||
/// [Learn
|
/// [Learn
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
//! [Learn more](https://en.wikipedia.org/wiki/Branch_table).
|
//! [Learn more](https://en.wikipedia.org/wiki/Branch_table).
|
||||||
|
|
||||||
use super::CodeOffset;
|
use super::CodeOffset;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_types::entity::{entity_impl, SecondaryMap};
|
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,
|
/// `JumpTable`s are used for indirect branching and are specialized for dense,
|
||||||
/// 0-based jump offsets.
|
/// 0-based jump offsets.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[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);
|
pub struct JumpTable(u32);
|
||||||
|
|
||||||
entity_impl!(JumpTable, "jt");
|
entity_impl!(JumpTable, "jt");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::lib::std::sync::Arc;
|
use crate::lib::std::sync::Arc;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_types::entity::PrimaryMap;
|
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
|
/// This differs from [`ModuleInfo`] because it have extra info only
|
||||||
/// possible after translation (such as the features used for compiling,
|
/// possible after translation (such as the features used for compiling,
|
||||||
/// or the `MemoryStyle` and `TableStyle`).
|
/// or the `MemoryStyle` and `TableStyle`).
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||||
pub struct CompileModuleInfo {
|
pub struct CompileModuleInfo {
|
||||||
/// The features used for compiling the module
|
/// The features used for compiling the module
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use crate::lib::std::fmt;
|
|||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
use crate::section::SectionIndex;
|
use crate::section::SectionIndex;
|
||||||
use crate::{Addend, CodeOffset, JumpTable};
|
use crate::{Addend, CodeOffset, JumpTable};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_types::entity::PrimaryMap;
|
use wasmer_types::entity::PrimaryMap;
|
||||||
@@ -21,7 +22,7 @@ use wasmer_vm::libcalls::LibCall;
|
|||||||
|
|
||||||
/// Relocation kinds for every ISA.
|
/// Relocation kinds for every ISA.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, MemoryUsage)]
|
||||||
pub enum RelocationKind {
|
pub enum RelocationKind {
|
||||||
/// absolute 4-byte
|
/// absolute 4-byte
|
||||||
Abs4,
|
Abs4,
|
||||||
@@ -79,7 +80,7 @@ impl fmt::Display for RelocationKind {
|
|||||||
|
|
||||||
/// A record of a relocation to perform.
|
/// A record of a relocation to perform.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct Relocation {
|
pub struct Relocation {
|
||||||
/// The relocation kind.
|
/// The relocation kind.
|
||||||
pub kind: RelocationKind,
|
pub kind: RelocationKind,
|
||||||
@@ -93,7 +94,7 @@ pub struct Relocation {
|
|||||||
|
|
||||||
/// Destination function. Can be either user function or some special one, like `memory.grow`.
|
/// Destination function. Can be either user function or some special one, like `memory.grow`.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub enum RelocationTarget {
|
pub enum RelocationTarget {
|
||||||
/// A relocation to a function defined locally in the wasm (not an imported one).
|
/// A relocation to a function defined locally in the wasm (not an imported one).
|
||||||
LocalFunc(LocalFunctionIndex),
|
LocalFunc(LocalFunctionIndex),
|
||||||
|
|||||||
@@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
use crate::Relocation;
|
use crate::Relocation;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_types::entity::entity_impl;
|
use wasmer_types::entity::entity_impl;
|
||||||
|
|
||||||
/// Index type of a Section defined inside a WebAssembly `Compilation`.
|
/// Index type of a Section defined inside a WebAssembly `Compilation`.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[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);
|
pub struct SectionIndex(u32);
|
||||||
|
|
||||||
entity_impl!(SectionIndex);
|
entity_impl!(SectionIndex);
|
||||||
@@ -22,7 +23,7 @@ entity_impl!(SectionIndex);
|
|||||||
///
|
///
|
||||||
/// Determines how a custom section may be used.
|
/// Determines how a custom section may be used.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub enum CustomSectionProtection {
|
pub enum CustomSectionProtection {
|
||||||
/// A custom section with read permission.
|
/// A custom section with read permission.
|
||||||
Read,
|
Read,
|
||||||
@@ -36,7 +37,7 @@ pub enum CustomSectionProtection {
|
|||||||
/// This is used so compilers can store arbitrary information
|
/// This is used so compilers can store arbitrary information
|
||||||
/// in the emitted module.
|
/// in the emitted module.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct CustomSection {
|
pub struct CustomSection {
|
||||||
/// Memory protection that applies to this section.
|
/// Memory protection that applies to this section.
|
||||||
pub protection: CustomSectionProtection,
|
pub protection: CustomSectionProtection,
|
||||||
@@ -55,7 +56,7 @@ pub struct CustomSection {
|
|||||||
|
|
||||||
/// The bytes in the section.
|
/// The bytes in the section.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[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>);
|
pub struct SectionBody(#[cfg_attr(feature = "enable-serde", serde(with = "serde_bytes"))] Vec<u8>);
|
||||||
|
|
||||||
impl SectionBody {
|
impl SectionBody {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
//! and tracing errors.
|
//! and tracing errors.
|
||||||
|
|
||||||
use crate::lib::std::fmt;
|
use crate::lib::std::fmt;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
serde(transparent)
|
serde(transparent)
|
||||||
)]
|
)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct SourceLoc(u32);
|
pub struct SourceLoc(u32);
|
||||||
|
|
||||||
impl SourceLoc {
|
impl SourceLoc {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::error::ParseCpuFeatureError;
|
|||||||
use crate::lib::std::str::FromStr;
|
use crate::lib::std::str::FromStr;
|
||||||
use crate::lib::std::string::{String, ToString};
|
use crate::lib::std::string::{String, ToString};
|
||||||
use enumset::{EnumSet, EnumSetType};
|
use enumset::{EnumSet, EnumSetType};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
pub use target_lexicon::{
|
pub use target_lexicon::{
|
||||||
Architecture, BinaryFormat, CallingConvention, Endianness, OperatingSystem, PointerWidth,
|
Architecture, BinaryFormat, CallingConvention, Endianness, OperatingSystem, PointerWidth,
|
||||||
Triple,
|
Triple,
|
||||||
@@ -160,9 +161,11 @@ impl ToString for CpuFeature {
|
|||||||
|
|
||||||
/// This is the target that we will use for compiling
|
/// This is the target that we will use for compiling
|
||||||
/// the WebAssembly ModuleInfo, and then run it.
|
/// the WebAssembly ModuleInfo, and then run it.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, MemoryUsage)]
|
||||||
pub struct Target {
|
pub struct Target {
|
||||||
|
#[loupe(skip)]
|
||||||
triple: Triple,
|
triple: Triple,
|
||||||
|
#[loupe(skip)]
|
||||||
cpu_features: EnumSet<CpuFeature>,
|
cpu_features: EnumSet<CpuFeature>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//! The middleware parses the function binary bytecodes and transform them
|
//! The middleware parses the function binary bytecodes and transform them
|
||||||
//! with the chosen functions.
|
//! with the chosen functions.
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
@@ -12,7 +13,7 @@ use wasmparser::{BinaryReader, Operator, Type};
|
|||||||
use crate::error::{MiddlewareError, WasmResult};
|
use crate::error::{MiddlewareError, WasmResult};
|
||||||
|
|
||||||
/// A shared builder for function middlewares.
|
/// 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.
|
/// Generates a `FunctionMiddleware` for a given function.
|
||||||
///
|
///
|
||||||
/// Here we generate a separate object for each function instead of executing directly on per-function operators,
|
/// Here we generate a separate object for each function instead of executing directly on per-function operators,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use crate::CodeOffset;
|
use crate::CodeOffset;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_vm::TrapCode;
|
use wasmer_vm::TrapCode;
|
||||||
|
|
||||||
/// Information about trap.
|
/// Information about trap.
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq, MemoryUsage)]
|
||||||
pub struct TrapInformation {
|
pub struct TrapInformation {
|
||||||
/// The offset of the trapping instruction in native code. It is relative to the beginning of the function.
|
/// The offset of the trapping instruction in native code. It is relative to the beginning of the function.
|
||||||
pub code_offset: CodeOffset,
|
pub code_offset: CodeOffset,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [Learn more](https://en.wikipedia.org/wiki/Call_stack).
|
//! [Learn more](https://en.wikipedia.org/wiki/Call_stack).
|
||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
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
|
/// [unwind info]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, MemoryUsage)]
|
||||||
pub enum CompiledFunctionUnwindInfo {
|
pub enum CompiledFunctionUnwindInfo {
|
||||||
/// Windows UNWIND_INFO.
|
/// Windows UNWIND_INFO.
|
||||||
WindowsX64(Vec<u8>),
|
WindowsX64(Vec<u8>),
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ serde = { version = "1.0", features = ["derive", "rc"] }
|
|||||||
serde_bytes = { version = "0.11" }
|
serde_bytes = { version = "0.11" }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
cfg-if = "0.1"
|
cfg-if = "0.1"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["winnt", "impl-default"] }
|
winapi = { version = "0.3", features = ["winnt", "impl-default"] }
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::link::link_module;
|
|||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
use crate::serialize::SerializableCompilation;
|
use crate::serialize::SerializableCompilation;
|
||||||
use crate::serialize::SerializableModule;
|
use crate::serialize::SerializableModule;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use wasmer_compiler::{CompileError, Features, Triple};
|
use wasmer_compiler::{CompileError, Features, Triple};
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
@@ -27,9 +28,11 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A compiled wasm module, ready to be instantiated.
|
/// A compiled wasm module, ready to be instantiated.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct JITArtifact {
|
pub struct JITArtifact {
|
||||||
serializable: SerializableModule,
|
serializable: SerializableModule,
|
||||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
|
#[loupe(skip)]
|
||||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
//! Memory management for executable code.
|
//! Memory management for executable code.
|
||||||
use crate::unwind::UnwindRegistry;
|
use crate::unwind::UnwindRegistry;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use wasmer_compiler::{CompiledFunctionUnwindInfo, CustomSection, FunctionBody};
|
use wasmer_compiler::{CompiledFunctionUnwindInfo, CustomSection, FunctionBody};
|
||||||
use wasmer_vm::{Mmap, VMFunctionBody};
|
use wasmer_vm::{Mmap, VMFunctionBody};
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ const ARCH_FUNCTION_ALIGNMENT: usize = 16;
|
|||||||
const DATA_SECTION_ALIGNMENT: usize = 64;
|
const DATA_SECTION_ALIGNMENT: usize = 64;
|
||||||
|
|
||||||
/// Memory manager for executable code.
|
/// Memory manager for executable code.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct CodeMemory {
|
pub struct CodeMemory {
|
||||||
unwind_registry: UnwindRegistry,
|
unwind_registry: UnwindRegistry,
|
||||||
mmap: Mmap,
|
mmap: Mmap,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//! JIT compilation.
|
//! JIT compilation.
|
||||||
|
|
||||||
use crate::{CodeMemory, JITArtifact};
|
use crate::{CodeMemory, JITArtifact};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
use wasmer_compiler::Compiler;
|
use wasmer_compiler::Compiler;
|
||||||
@@ -17,7 +18,7 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A WebAssembly `JIT` Engine.
|
/// A WebAssembly `JIT` Engine.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct JITEngine {
|
pub struct JITEngine {
|
||||||
inner: Arc<Mutex<JITEngineInner>>,
|
inner: Arc<Mutex<JITEngineInner>>,
|
||||||
/// The target for the compiler
|
/// The target for the compiler
|
||||||
@@ -145,6 +146,7 @@ impl Engine for JITEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The inner contents of `JITEngine`
|
/// The inner contents of `JITEngine`
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct JITEngineInner {
|
pub struct JITEngineInner {
|
||||||
/// The compiler
|
/// The compiler
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_compiler::{
|
use wasmer_compiler::{
|
||||||
CompileModuleInfo, CustomSection, Dwarf, FunctionBody, JumpTableOffsets, Relocation,
|
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
|
/// The compilation related data for a serialized modules
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, MemoryUsage)]
|
||||||
pub struct SerializableCompilation {
|
pub struct SerializableCompilation {
|
||||||
pub function_bodies: PrimaryMap<LocalFunctionIndex, FunctionBody>,
|
pub function_bodies: PrimaryMap<LocalFunctionIndex, FunctionBody>,
|
||||||
pub function_relocations: PrimaryMap<LocalFunctionIndex, Vec<Relocation>>,
|
pub function_relocations: PrimaryMap<LocalFunctionIndex, Vec<Relocation>>,
|
||||||
@@ -37,7 +38,7 @@ pub struct SerializableCompilation {
|
|||||||
|
|
||||||
/// Serializable struct that is able to serialize from and to
|
/// Serializable struct that is able to serialize from and to
|
||||||
/// a `JITArtifactInfo`.
|
/// a `JITArtifactInfo`.
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, MemoryUsage)]
|
||||||
pub struct SerializableModule {
|
pub struct SerializableModule {
|
||||||
pub compilation: SerializableCompilation,
|
pub compilation: SerializableCompilation,
|
||||||
pub compile_info: CompileModuleInfo,
|
pub compile_info: CompileModuleInfo,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
//! Module for Dummy unwind registry.
|
//! Module for Dummy unwind registry.
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
||||||
|
|
||||||
/// Represents a registry of function unwind information when the host system
|
/// Represents a registry of function unwind information when the host system
|
||||||
/// support any one in specific.
|
/// support any one in specific.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct DummyUnwindRegistry {}
|
pub struct DummyUnwindRegistry {}
|
||||||
|
|
||||||
impl DummyUnwindRegistry {
|
impl DummyUnwindRegistry {
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
||||||
|
|
||||||
//! Module for System V ABI unwind registry.
|
//! Module for System V ABI unwind registry.
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
||||||
|
|
||||||
/// Represents a registry of function unwind information for System V ABI.
|
/// Represents a registry of function unwind information for System V ABI.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct UnwindRegistry {
|
pub struct UnwindRegistry {
|
||||||
registrations: Vec<usize>,
|
registrations: Vec<usize>,
|
||||||
published: bool,
|
published: bool,
|
||||||
@@ -65,7 +68,11 @@ impl UnwindRegistry {
|
|||||||
// deregistering it. We must avoid this
|
// deregistering it. We must avoid this
|
||||||
// scenario. Usually, this is handled upstream by the
|
// scenario. Usually, this is handled upstream by the
|
||||||
// compilers.
|
// 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
|
// On gnu (libgcc), `__register_frame` will walk the FDEs until an entry of length 0
|
||||||
let ptr = eh_frame.as_ptr();
|
let ptr = eh_frame.as_ptr();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
||||||
|
|
||||||
//! Module for Windows x64 ABI unwind registry.
|
//! Module for Windows x64 ABI unwind registry.
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
use wasmer_compiler::CompiledFunctionUnwindInfo;
|
||||||
use winapi::um::winnt;
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ leb128 = "0.2"
|
|||||||
libloading = "0.7"
|
libloading = "0.7"
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
which = "4.0"
|
which = "4.0"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Enable the `compiler` feature if you want the engine to compile
|
# Enable the `compiler` feature if you want the engine to compile
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
use crate::engine::{NativeEngine, NativeEngineInner};
|
use crate::engine::{NativeEngine, NativeEngineInner};
|
||||||
use crate::serialize::ModuleMetadata;
|
use crate::serialize::ModuleMetadata;
|
||||||
use libloading::{Library, Symbol as LibrarySymbol};
|
use libloading::{Library, Symbol as LibrarySymbol};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
@@ -37,10 +38,12 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A compiled wasm module, ready to be instantiated.
|
/// A compiled wasm module, ready to be instantiated.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct NativeArtifact {
|
pub struct NativeArtifact {
|
||||||
sharedobject_path: PathBuf,
|
sharedobject_path: PathBuf,
|
||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
|
#[loupe(skip)]
|
||||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||||
func_data_registry: Arc<FuncDataRegistry>,
|
func_data_registry: Arc<FuncDataRegistry>,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use crate::NativeArtifact;
|
use crate::NativeArtifact;
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
@@ -17,7 +18,7 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A WebAssembly `Native` Engine.
|
/// A WebAssembly `Native` Engine.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct NativeEngine {
|
pub struct NativeEngine {
|
||||||
inner: Arc<Mutex<NativeEngineInner>>,
|
inner: Arc<Mutex<NativeEngineInner>>,
|
||||||
/// The target for the compiler
|
/// The target for the compiler
|
||||||
@@ -183,7 +184,7 @@ impl Engine for NativeEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, MemoryUsage)]
|
||||||
pub(crate) enum Linker {
|
pub(crate) enum Linker {
|
||||||
None,
|
None,
|
||||||
Clang11,
|
Clang11,
|
||||||
@@ -228,29 +229,39 @@ impl Linker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The inner contents of `NativeEngine`
|
/// The inner contents of `NativeEngine`
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct NativeEngineInner {
|
pub struct NativeEngineInner {
|
||||||
/// The compiler
|
/// The compiler
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
compiler: Option<Box<dyn Compiler>>,
|
compiler: Option<Box<dyn Compiler>>,
|
||||||
|
|
||||||
/// The WebAssembly features to use
|
/// The WebAssembly features to use
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
features: Features,
|
features: Features,
|
||||||
|
|
||||||
/// The signature registry is used mainly to operate with trampolines
|
/// The signature registry is used mainly to operate with trampolines
|
||||||
/// performantly.
|
/// performantly.
|
||||||
signatures: SignatureRegistry,
|
signatures: SignatureRegistry,
|
||||||
|
|
||||||
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
|
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
|
||||||
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
|
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
|
||||||
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
|
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
|
||||||
func_data: Arc<FuncDataRegistry>,
|
func_data: Arc<FuncDataRegistry>,
|
||||||
|
|
||||||
/// The prefixer returns the a String to prefix each of
|
/// The prefixer returns the a String to prefix each of
|
||||||
/// the functions in the shared object generated by the `NativeEngine`,
|
/// the functions in the shared object generated by the `NativeEngine`,
|
||||||
/// so we can assure no collisions.
|
/// so we can assure no collisions.
|
||||||
|
#[loupe(skip)]
|
||||||
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
||||||
|
|
||||||
/// Whether the native engine will cross-compile.
|
/// Whether the native engine will cross-compile.
|
||||||
is_cross_compiling: bool,
|
is_cross_compiling: bool,
|
||||||
|
|
||||||
/// The linker to use.
|
/// The linker to use.
|
||||||
linker: Linker,
|
linker: Linker,
|
||||||
|
|
||||||
/// List of libraries loaded by this engine.
|
/// List of libraries loaded by this engine.
|
||||||
|
#[loupe(skip)]
|
||||||
libraries: Vec<Library>,
|
libraries: Vec<Library>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
||||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
||||||
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
||||||
|
|
||||||
/// Serializable struct that represents the compiled metadata.
|
/// Serializable struct that represents the compiled metadata.
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
|
||||||
pub struct ModuleMetadata {
|
pub struct ModuleMetadata {
|
||||||
pub compile_info: CompileModuleInfo,
|
pub compile_info: CompileModuleInfo,
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ bincode = "1.3"
|
|||||||
leb128 = "0.2"
|
leb128 = "0.2"
|
||||||
libloading = "0.7"
|
libloading = "0.7"
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Enable the `compiler` feature if you want the engine to compile
|
# Enable the `compiler` feature if you want the engine to compile
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
use crate::engine::{ObjectFileEngine, ObjectFileEngineInner};
|
use crate::engine::{ObjectFileEngine, ObjectFileEngineInner};
|
||||||
use crate::serialize::{ModuleMetadata, ModuleMetadataSymbolRegistry};
|
use crate::serialize::{ModuleMetadata, ModuleMetadataSymbolRegistry};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
@@ -31,10 +32,12 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A compiled wasm module, ready to be instantiated.
|
/// A compiled wasm module, ready to be instantiated.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct ObjectFileArtifact {
|
pub struct ObjectFileArtifact {
|
||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
module_bytes: Vec<u8>,
|
module_bytes: Vec<u8>,
|
||||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
|
#[loupe(skip)]
|
||||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::ObjectFileArtifact;
|
use crate::ObjectFileArtifact;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -14,7 +15,7 @@ use wasmer_vm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// A WebAssembly `ObjectFile` Engine.
|
/// A WebAssembly `ObjectFile` Engine.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct ObjectFileEngine {
|
pub struct ObjectFileEngine {
|
||||||
inner: Arc<Mutex<ObjectFileEngineInner>>,
|
inner: Arc<Mutex<ObjectFileEngineInner>>,
|
||||||
/// The target for the compiler
|
/// The target for the compiler
|
||||||
@@ -174,23 +175,29 @@ impl Engine for ObjectFileEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The inner contents of `ObjectFileEngine`
|
/// The inner contents of `ObjectFileEngine`
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct ObjectFileEngineInner {
|
pub struct ObjectFileEngineInner {
|
||||||
/// The compiler
|
/// The compiler
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
compiler: Option<Box<dyn Compiler>>,
|
compiler: Option<Box<dyn Compiler>>,
|
||||||
|
|
||||||
/// The WebAssembly features to use
|
/// The WebAssembly features to use
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
features: Features,
|
features: Features,
|
||||||
|
|
||||||
/// The signature registry is used mainly to operate with trampolines
|
/// The signature registry is used mainly to operate with trampolines
|
||||||
/// performantly.
|
/// performantly.
|
||||||
signatures: SignatureRegistry,
|
signatures: SignatureRegistry,
|
||||||
|
|
||||||
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
|
/// The backing storage of `VMFuncRef`s. This centralized store ensures that 2
|
||||||
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
|
/// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`.
|
||||||
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
|
/// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped.
|
||||||
func_data: Arc<FuncDataRegistry>,
|
func_data: Arc<FuncDataRegistry>,
|
||||||
|
|
||||||
/// The prefixer returns the a String to prefix each of
|
/// The prefixer returns the a String to prefix each of
|
||||||
/// the functions in the shared object generated by the `ObjectFileEngine`,
|
/// the functions in the shared object generated by the `ObjectFileEngine`,
|
||||||
/// so we can assure no collisions.
|
/// so we can assure no collisions.
|
||||||
|
#[loupe(skip)]
|
||||||
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
use wasmer_compiler::{CompileModuleInfo, SectionIndex, Symbol, SymbolRegistry};
|
||||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
||||||
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
||||||
|
|
||||||
/// Serializable struct that represents the compiled metadata.
|
/// Serializable struct that represents the compiled metadata.
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug, MemoryUsage)]
|
||||||
pub struct ModuleMetadata {
|
pub struct ModuleMetadata {
|
||||||
pub compile_info: CompileModuleInfo,
|
pub compile_info: CompileModuleInfo,
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
@@ -13,6 +14,7 @@ pub struct ModuleMetadata {
|
|||||||
pub function_body_lengths: PrimaryMap<LocalFunctionIndex, u64>,
|
pub function_body_lengths: PrimaryMap<LocalFunctionIndex, u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct ModuleMetadataSymbolRegistry {
|
pub struct ModuleMetadataSymbolRegistry {
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ serde = { version = "1.0", features = ["derive", "rc"] }
|
|||||||
serde_bytes = { version = "0.11" }
|
serde_bytes = { version = "0.11" }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
resolve_imports, InstantiationError, Resolver, RuntimeError, SerializeError, Tunables,
|
resolve_imports, InstantiationError, Resolver, RuntimeError, SerializeError, Tunables,
|
||||||
};
|
};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -22,7 +23,7 @@ use wasmer_vm::{
|
|||||||
/// The `Artifact` contains the compiled data for a given
|
/// The `Artifact` contains the compiled data for a given
|
||||||
/// module as well as extra information needed to run the
|
/// module as well as extra information needed to run the
|
||||||
/// module at runtime, such as [`ModuleInfo`] and [`Features`].
|
/// 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
|
/// Return a reference-counted pointer to the module
|
||||||
fn module(&self) -> Arc<ModuleInfo>;
|
fn module(&self) -> Arc<ModuleInfo>;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use crate::tunables::Tunables;
|
use crate::tunables::Tunables;
|
||||||
use crate::{Artifact, DeserializeError};
|
use crate::{Artifact, DeserializeError};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use memmap2::Mmap;
|
use memmap2::Mmap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
|
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
|
||||||
@@ -16,7 +17,7 @@ use wasmer_vm::{VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex};
|
|||||||
/// such as: JIT or Native.
|
/// such as: JIT or Native.
|
||||||
///
|
///
|
||||||
/// The product that an `Engine` produces and consumes is the [`Artifact`].
|
/// The product that an `Engine` produces and consumes is the [`Artifact`].
|
||||||
pub trait Engine {
|
pub trait Engine: MemoryUsage {
|
||||||
/// Gets the target
|
/// Gets the target
|
||||||
fn target(&self) -> &Target;
|
fn target(&self) -> &Target;
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ pub trait Engine {
|
|||||||
fn cloned(&self) -> Arc<dyn Engine + Send + Sync>;
|
fn cloned(&self) -> Arc<dyn Engine + Send + Sync>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, MemoryUsage)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
/// A unique identifier for an Engine.
|
/// A unique identifier for an Engine.
|
||||||
pub struct EngineId {
|
pub struct EngineId {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
|
use std::sync::Arc;
|
||||||
use wasmer_vm::{
|
use wasmer_vm::{
|
||||||
ImportInitializerFuncPtr, VMExport, VMExportFunction, VMExportGlobal, VMExportMemory,
|
ImportInitializerFuncPtr, VMExport, VMExportFunction, VMExportGlobal, VMExportMemory,
|
||||||
VMExportTable,
|
VMExportTable,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// The value of an export passed from one instance to another.
|
/// The value of an export passed from one instance to another.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Export {
|
pub enum Export {
|
||||||
@@ -54,7 +54,7 @@ impl From<VMExport> for Export {
|
|||||||
///
|
///
|
||||||
/// This struct owns the original `host_env`, thus when it gets dropped
|
/// This struct owns the original `host_env`, thus when it gets dropped
|
||||||
/// it calls the `drop` function on it.
|
/// it calls the `drop` function on it.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, MemoryUsage)]
|
||||||
pub struct ExportFunctionMetadata {
|
pub struct ExportFunctionMetadata {
|
||||||
/// This field is stored here to be accessible by `Drop`.
|
/// 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
|
/// See `wasmer_vm::export::VMExportFunction::vmctx` for the version of
|
||||||
/// this pointer that is used by the VM when creating an `Instance`.
|
/// this pointer that is used by the VM when creating an `Instance`.
|
||||||
pub(crate) host_env: *mut std::ffi::c_void,
|
pub(crate) host_env: *mut std::ffi::c_void,
|
||||||
|
|
||||||
/// Function pointer to `WasmerEnv::init_with_instance(&mut self, instance: &Instance)`.
|
/// Function pointer to `WasmerEnv::init_with_instance(&mut self, instance: &Instance)`.
|
||||||
///
|
///
|
||||||
/// This function is called to finish setting up the environment after
|
/// This function is called to finish setting up the environment after
|
||||||
/// we create the `api::Instance`.
|
/// we create the `api::Instance`.
|
||||||
// This one is optional for now because dynamic host envs need the rest
|
// This one is optional for now because dynamic host envs need the rest
|
||||||
// of this without the init fn
|
// of this without the init fn
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) import_init_function_ptr: Option<ImportInitializerFuncPtr>,
|
pub(crate) import_init_function_ptr: Option<ImportInitializerFuncPtr>,
|
||||||
|
|
||||||
/// A function analogous to `Clone::clone` that returns a leaked `Box`.
|
/// 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,
|
pub(crate) host_env_clone_fn: fn(*mut std::ffi::c_void) -> *mut std::ffi::c_void,
|
||||||
|
|
||||||
/// The destructor to free the host environment.
|
/// The destructor to free the host environment.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// - This function should only be called in when properly synchronized.
|
/// - This function should only be called in when properly synchronized.
|
||||||
/// For example, in the `Drop` implementation of this type.
|
/// For example, in the `Drop` implementation of this type.
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) host_env_drop_fn: unsafe fn(*mut std::ffi::c_void),
|
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
|
/// A function export value with an extra function pointer to initialize
|
||||||
/// host environments.
|
/// host environments.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, MemoryUsage)]
|
||||||
pub struct ExportFunction {
|
pub struct ExportFunction {
|
||||||
/// The VM function, containing most of the data.
|
/// The VM function, containing most of the data.
|
||||||
pub vm_function: VMExportFunction,
|
pub vm_function: VMExportFunction,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::de::{Deserializer, Visitor};
|
use serde::de::{Deserializer, Visitor};
|
||||||
use serde::ser::Serializer;
|
use serde::ser::Serializer;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -5,7 +6,7 @@ use std::fmt;
|
|||||||
use wasmer_compiler::CompiledFunctionFrameInfo;
|
use wasmer_compiler::CompiledFunctionFrameInfo;
|
||||||
|
|
||||||
/// This is the unserialized verison of `CompiledFunctionFrameInfo`.
|
/// This is the unserialized verison of `CompiledFunctionFrameInfo`.
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize, MemoryUsage)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct UnprocessedFunctionFrameInfo {
|
pub struct UnprocessedFunctionFrameInfo {
|
||||||
@@ -44,7 +45,7 @@ impl UnprocessedFunctionFrameInfo {
|
|||||||
/// of compiling at the same time that emiting the JIT.
|
/// of compiling at the same time that emiting the JIT.
|
||||||
/// In that case, we don't need to deserialize/process anything
|
/// In that case, we don't need to deserialize/process anything
|
||||||
/// as the data is already in memory.
|
/// as the data is already in memory.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub enum SerializableFunctionFrameInfo {
|
pub enum SerializableFunctionFrameInfo {
|
||||||
/// The unprocessed frame info (binary)
|
/// The unprocessed frame info (binary)
|
||||||
Unprocessed(UnprocessedFunctionFrameInfo),
|
Unprocessed(UnprocessedFunctionFrameInfo),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
//! FRAME_INFO.register(module, compiled_functions);
|
//! FRAME_INFO.register(module, compiled_functions);
|
||||||
//! ```
|
//! ```
|
||||||
use crate::serialize::SerializableFunctionFrameInfo;
|
use crate::serialize::SerializableFunctionFrameInfo;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::{Arc, RwLock};
|
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
|
/// An RAII structure used to unregister a module's frame information when the
|
||||||
/// module is destroyed.
|
/// module is destroyed.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct GlobalFrameInfoRegistration {
|
pub struct GlobalFrameInfoRegistration {
|
||||||
/// The key that will be removed from the global `ranges` map when this is
|
/// The key that will be removed from the global `ranges` map when this is
|
||||||
/// dropped.
|
/// dropped.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::error::LinkError;
|
use crate::error::LinkError;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
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
|
/// An engine delegates the creation of memories, tables, and globals
|
||||||
/// to a foreign implementor of this trait.
|
/// to a foreign implementor of this trait.
|
||||||
pub trait Tunables {
|
pub trait Tunables: MemoryUsage {
|
||||||
/// Construct a `MemoryStyle` for the provided `MemoryType`
|
/// Construct a `MemoryStyle` for the provided `MemoryType`
|
||||||
fn memory_style(&self, memory: &MemoryType) -> MemoryStyle;
|
fn memory_style(&self, memory: &MemoryType) -> MemoryStyle;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ edition = "2018"
|
|||||||
wasmer = { path = "../api", version = "1.0.2" }
|
wasmer = { path = "../api", version = "1.0.2" }
|
||||||
wasmer-types = { path = "../wasmer-types", version = "1.0.2" }
|
wasmer-types = { path = "../wasmer-types", version = "1.0.2" }
|
||||||
wasmer-vm = { path = "../vm", version = "1.0.2" }
|
wasmer-vm = { path = "../vm", version = "1.0.2" }
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
//! `metering` is a middleware for tracking how many operators are executed in total
|
//! `metering` is a middleware for tracking how many operators are executed in total
|
||||||
//! and putting a limit on the total number of operators executed.
|
//! and putting a limit on the total number of operators executed.
|
||||||
|
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::mem;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use wasmer::wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
|
use wasmer::wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
|
||||||
use wasmer::{
|
use wasmer::{
|
||||||
@@ -12,7 +14,7 @@ use wasmer::{
|
|||||||
use wasmer_types::GlobalIndex;
|
use wasmer_types::GlobalIndex;
|
||||||
use wasmer_vm::ModuleInfo;
|
use wasmer_vm::ModuleInfo;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
struct MeteringGlobalIndexes(GlobalIndex, GlobalIndex);
|
struct MeteringGlobalIndexes(GlobalIndex, GlobalIndex);
|
||||||
|
|
||||||
impl MeteringGlobalIndexes {
|
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> {
|
impl<F: Fn(&Operator) -> u64 + Send + Sync> fmt::Debug for FunctionMetering<F> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("FunctionMetering")
|
f.debug_struct("FunctionMetering")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ more-asserts = "0.2"
|
|||||||
cfg-if = "0.1"
|
cfg-if = "0.1"
|
||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
|
loupe = { version = "0.1", features = ["enable-indexmap"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] }
|
winapi = { version = "0.3", features = ["winbase", "memoryapi", "errhandlingapi"] }
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::instance::InstanceRef;
|
|||||||
use crate::memory::{Memory, MemoryStyle};
|
use crate::memory::{Memory, MemoryStyle};
|
||||||
use crate::table::{Table, TableStyle};
|
use crate::table::{Table, TableStyle};
|
||||||
use crate::vmcontext::{VMFunctionBody, VMFunctionEnvironment, VMFunctionKind, VMTrampoline};
|
use crate::vmcontext::{VMFunctionBody, VMFunctionEnvironment, VMFunctionKind, VMTrampoline};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_types::{FunctionType, MemoryType, TableType};
|
use wasmer_types::{FunctionType, MemoryType, TableType};
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ pub enum VMExport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A function export value.
|
/// A function export value.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, MemoryUsage)]
|
||||||
pub struct VMExportFunction {
|
pub struct VMExportFunction {
|
||||||
/// The address of the native-code function.
|
/// The address of the native-code function.
|
||||||
pub address: *const VMFunctionBody,
|
pub address: *const VMFunctionBody,
|
||||||
@@ -46,6 +47,7 @@ pub struct VMExportFunction {
|
|||||||
///
|
///
|
||||||
/// May be `None` when the function is a host function (`FunctionType`
|
/// May be `None` when the function is a host function (`FunctionType`
|
||||||
/// == `Dynamic` or `vmctx` == `nullptr`).
|
/// == `Dynamic` or `vmctx` == `nullptr`).
|
||||||
|
#[loupe(skip)]
|
||||||
pub call_trampoline: Option<VMTrampoline>,
|
pub call_trampoline: Option<VMTrampoline>,
|
||||||
|
|
||||||
/// A “reference” to the instance through the
|
/// A “reference” to the instance through the
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
//! long as we need them to.
|
//! long as we need them to.
|
||||||
|
|
||||||
use crate::vmcontext::VMCallerCheckedAnyfunc;
|
use crate::vmcontext::VMCallerCheckedAnyfunc;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
/// The registry that holds the values that `VMFuncRef`s point to.
|
/// The registry that holds the values that `VMFuncRef`s point to.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
pub struct FuncDataRegistry {
|
pub struct FuncDataRegistry {
|
||||||
// This structure is stored in an `Engine` and is intended to be shared
|
// This structure is stored in an `Engine` and is intended to be shared
|
||||||
// across many instances. Ideally instances can themselves be sent across
|
// 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.
|
/// A function reference. A single word that points to metadata about a function.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, MemoryUsage)]
|
||||||
pub struct VMFuncRef(pub(crate) *const VMCallerCheckedAnyfunc);
|
pub struct VMFuncRef(pub(crate) *const VMCallerCheckedAnyfunc);
|
||||||
|
|
||||||
impl wasmer_types::NativeWasmType for VMFuncRef {
|
impl wasmer_types::NativeWasmType for VMFuncRef {
|
||||||
@@ -86,7 +87,7 @@ impl std::ops::DerefMut for VMFuncRef {
|
|||||||
unsafe impl Send for VMFuncRef {}
|
unsafe impl Send for VMFuncRef {}
|
||||||
unsafe impl Sync for VMFuncRef {}
|
unsafe impl Sync for VMFuncRef {}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, MemoryUsage)]
|
||||||
struct Inner {
|
struct Inner {
|
||||||
func_data: Vec<Box<VMCallerCheckedAnyfunc>>,
|
func_data: Vec<Box<VMCallerCheckedAnyfunc>>,
|
||||||
anyfunc_to_index: HashMap<VMCallerCheckedAnyfunc, usize>,
|
anyfunc_to_index: HashMap<VMCallerCheckedAnyfunc, usize>,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use crate::vmcontext::VMGlobalDefinition;
|
use crate::vmcontext::VMGlobalDefinition;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmer_types::{GlobalType, Mutability, Type, Value, ValueEnumType};
|
use wasmer_types::{GlobalType, Mutability, Type, Value, ValueEnumType};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
/// A Global instance
|
/// A Global instance
|
||||||
pub struct Global {
|
pub struct Global {
|
||||||
ty: GlobalType,
|
ty: GlobalType,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use crate::vmcontext::{
|
|||||||
};
|
};
|
||||||
use crate::{FunctionBodyPtr, ModuleInfo, VMOffsets};
|
use crate::{FunctionBodyPtr, ModuleInfo, VMOffsets};
|
||||||
use crate::{VMExportFunction, VMExportGlobal, VMExportMemory, VMExportTable};
|
use crate::{VMExportFunction, VMExportGlobal, VMExportMemory, VMExportTable};
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use memoffset::offset_of;
|
use memoffset::offset_of;
|
||||||
use more_asserts::assert_lt;
|
use more_asserts::assert_lt;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
@@ -36,9 +37,10 @@ use std::collections::HashMap;
|
|||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
use std::ffi;
|
use std::ffi;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ptr::NonNull;
|
use std::mem;
|
||||||
|
use std::ptr::{self, NonNull};
|
||||||
|
use std::slice;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{mem, ptr, slice};
|
|
||||||
use wasmer_types::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
|
use wasmer_types::entity::{packed_option::ReservedValue, BoxedSlice, EntityRef, PrimaryMap};
|
||||||
use wasmer_types::{
|
use wasmer_types::{
|
||||||
DataIndex, DataInitializer, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, GlobalInit,
|
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
|
/// contain various data. That's why the type has a C representation
|
||||||
/// to ensure that the `vmctx` field is last. See the documentation of
|
/// to ensure that the `vmctx` field is last. See the documentation of
|
||||||
/// the `vmctx` field to learn more.
|
/// the `vmctx` field to learn more.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub(crate) struct Instance {
|
pub(crate) struct Instance {
|
||||||
/// The `ModuleInfo` this `Instance` was instantiated from.
|
/// The `ModuleInfo` this `Instance` was instantiated from.
|
||||||
@@ -78,6 +81,7 @@ pub(crate) struct Instance {
|
|||||||
functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
|
|
||||||
/// Pointers to function call trampolines in executable memory.
|
/// Pointers to function call trampolines in executable memory.
|
||||||
|
#[loupe(skip)]
|
||||||
function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||||
|
|
||||||
/// Passive elements in this instantiation. As `elem.drop`s happen, these
|
/// Passive elements in this instantiation. As `elem.drop`s happen, these
|
||||||
@@ -95,6 +99,7 @@ pub(crate) struct Instance {
|
|||||||
host_state: Box<dyn Any>,
|
host_state: Box<dyn Any>,
|
||||||
|
|
||||||
/// Handler run when `SIGBUS`, `SIGFPE`, `SIGILL`, or `SIGSEGV` are caught by the instance thread.
|
/// Handler run when `SIGBUS`, `SIGFPE`, `SIGILL`, or `SIGSEGV` are caught by the instance thread.
|
||||||
|
#[loupe(skip)]
|
||||||
pub(crate) signal_handler: Cell<Option<Box<SignalHandler>>>,
|
pub(crate) signal_handler: Cell<Option<Box<SignalHandler>>>,
|
||||||
|
|
||||||
/// Functions to operate on host environments in the imports
|
/// 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
|
/// field is last, and represents a dynamically-sized array that
|
||||||
/// extends beyond the nominal end of the struct (similar to a
|
/// extends beyond the nominal end of the struct (similar to a
|
||||||
/// flexible array member).
|
/// flexible array member).
|
||||||
|
#[loupe(skip)]
|
||||||
vmctx: VMContext,
|
vmctx: VMContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +133,7 @@ pub enum ImportFunctionEnv {
|
|||||||
/// The function environment. This is not always the user-supplied
|
/// The function environment. This is not always the user-supplied
|
||||||
/// env.
|
/// env.
|
||||||
env: *mut ffi::c_void,
|
env: *mut ffi::c_void,
|
||||||
|
|
||||||
/// A clone function for duplicating the env.
|
/// A clone function for duplicating the env.
|
||||||
clone: fn(*mut ffi::c_void) -> *mut ffi::c_void,
|
clone: fn(*mut ffi::c_void) -> *mut ffi::c_void,
|
||||||
/// This field is not always present. When it is present, it
|
/// 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 {
|
impl fmt::Debug for Instance {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
formatter.debug_struct("Instance").finish()
|
formatter.debug_struct("Instance").finish()
|
||||||
@@ -872,7 +885,7 @@ impl Instance {
|
|||||||
///
|
///
|
||||||
/// This is more or less a public facade of the private `Instance`,
|
/// This is more or less a public facade of the private `Instance`,
|
||||||
/// providing useful higher-level API.
|
/// providing useful higher-level API.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, MemoryUsage)]
|
||||||
pub struct InstanceHandle {
|
pub struct InstanceHandle {
|
||||||
/// The [`InstanceRef`]. See its documentation to learn more.
|
/// The [`InstanceRef`]. See its documentation to learn more.
|
||||||
instance: InstanceRef,
|
instance: InstanceRef,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use super::Instance;
|
use super::Instance;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use std::alloc::Layout;
|
use std::alloc::Layout;
|
||||||
|
use std::mem;
|
||||||
use std::ptr::{self, NonNull};
|
use std::ptr::{self, NonNull};
|
||||||
use std::sync::{atomic, Arc};
|
use std::sync::{atomic, Arc};
|
||||||
|
|
||||||
@@ -208,3 +210,13 @@ impl Drop for InstanceRef {
|
|||||||
unsafe { Self::deallocate_instance(self) };
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,13 +58,14 @@ pub use crate::vmcontext::{
|
|||||||
VMTableImport, VMTrampoline,
|
VMTableImport, VMTrampoline,
|
||||||
};
|
};
|
||||||
pub use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
|
pub use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
pub use wasmer_types::VMExternRef;
|
pub use wasmer_types::VMExternRef;
|
||||||
|
|
||||||
/// Version number of this crate.
|
/// Version number of this crate.
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
/// A safe wrapper around `VMFunctionBody`.
|
/// A safe wrapper around `VMFunctionBody`.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, MemoryUsage)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct FunctionBodyPtr(pub *const VMFunctionBody);
|
pub struct FunctionBodyPtr(pub *const VMFunctionBody);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ use crate::table::{TableElement, TableReference};
|
|||||||
use crate::trap::{raise_lib_trap, Trap, TrapCode};
|
use crate::trap::{raise_lib_trap, Trap, TrapCode};
|
||||||
use crate::vmcontext::VMContext;
|
use crate::vmcontext::VMContext;
|
||||||
use crate::VMExternRef;
|
use crate::VMExternRef;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use wasmer_types::{
|
use wasmer_types::{
|
||||||
@@ -680,7 +681,7 @@ pub static wasmer_vm_probestack: unsafe extern "C" fn() = PROBESTACK;
|
|||||||
/// The name of a runtime library routine.
|
/// The name of a runtime library routine.
|
||||||
///
|
///
|
||||||
/// This list is likely to grow over time.
|
/// 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 {
|
pub enum LibCall {
|
||||||
/// ceil.f32
|
/// ceil.f32
|
||||||
CeilF32,
|
CeilF32,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
use crate::mmap::Mmap;
|
use crate::mmap::Mmap;
|
||||||
use crate::vmcontext::VMMemoryDefinition;
|
use crate::vmcontext::VMMemoryDefinition;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use more_asserts::assert_ge;
|
use more_asserts::assert_ge;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
@@ -61,7 +62,7 @@ pub enum MemoryError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation styles for WebAssembly linear memory.
|
/// 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 {
|
pub enum MemoryStyle {
|
||||||
/// The actual memory can be resized and moved.
|
/// The actual memory can be resized and moved.
|
||||||
Dynamic {
|
Dynamic {
|
||||||
@@ -96,7 +97,7 @@ impl MemoryStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Trait for implementing Wasm Memory used by Wasmer.
|
/// 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.
|
/// Returns the memory type for this memory.
|
||||||
fn ty(&self) -> &MemoryType;
|
fn ty(&self) -> &MemoryType;
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ pub trait Memory: fmt::Debug + Send + Sync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A linear memory instance.
|
/// A linear memory instance.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
pub struct LinearMemory {
|
pub struct LinearMemory {
|
||||||
// The underlying allocation.
|
// The underlying allocation.
|
||||||
mmap: Mutex<WasmMmap>,
|
mmap: Mutex<WasmMmap>,
|
||||||
@@ -144,7 +145,7 @@ pub struct LinearMemory {
|
|||||||
|
|
||||||
/// A type to help manage who is responsible for the backing memory of them
|
/// A type to help manage who is responsible for the backing memory of them
|
||||||
/// `VMMemoryDefinition`.
|
/// `VMMemoryDefinition`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
enum VMMemoryDefinitionOwnership {
|
enum VMMemoryDefinitionOwnership {
|
||||||
/// The `VMMemoryDefinition` is owned by the `Instance` and we should use
|
/// 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.
|
/// 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.
|
/// This is correct because all internal mutability is protected by a mutex.
|
||||||
unsafe impl Sync for LinearMemory {}
|
unsafe impl Sync for LinearMemory {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
struct WasmMmap {
|
struct WasmMmap {
|
||||||
// Our OS allocation of mmap'd memory.
|
// Our OS allocation of mmap'd memory.
|
||||||
alloc: Mmap,
|
alloc: Mmap,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
//! Low-level abstraction for allocating and managing zero-filled pages
|
//! Low-level abstraction for allocating and managing zero-filled pages
|
||||||
//! of memory.
|
//! of memory.
|
||||||
|
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use more_asserts::assert_le;
|
use more_asserts::assert_le;
|
||||||
use more_asserts::assert_lt;
|
use more_asserts::assert_lt;
|
||||||
use std::io;
|
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() {
|
||||||
fn _assert_send_sync<T: Send + Sync>() {}
|
fn _assert_send_sync<T: Send + Sync>() {}
|
||||||
_assert_send_sync::<Mmap>();
|
_assert_send_sync::<Mmap>();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
//! `wasmer::Module`.
|
//! `wasmer::Module`.
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -19,7 +20,7 @@ use wasmer_types::{
|
|||||||
TableIndex, TableInitializer, TableType,
|
TableIndex, TableInitializer, TableType,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
pub struct ModuleId {
|
pub struct ModuleId {
|
||||||
id: usize,
|
id: usize,
|
||||||
}
|
}
|
||||||
@@ -41,7 +42,7 @@ impl Default for ModuleId {
|
|||||||
|
|
||||||
/// A translated WebAssembly module, excluding the function bodies and
|
/// A translated WebAssembly module, excluding the function bodies and
|
||||||
/// memory initializers.
|
/// memory initializers.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, MemoryUsage)]
|
||||||
pub struct ModuleInfo {
|
pub struct ModuleInfo {
|
||||||
/// A unique identifier (within this process) for this module.
|
/// A unique identifier (within this process) for this module.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
//! signature checking.
|
//! signature checking.
|
||||||
|
|
||||||
use crate::vmcontext::VMSharedSignatureIndex;
|
use crate::vmcontext::VMSharedSignatureIndex;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use more_asserts::{assert_lt, debug_assert_lt};
|
use more_asserts::{assert_lt, debug_assert_lt};
|
||||||
use std::collections::{hash_map, HashMap};
|
use std::collections::{hash_map, HashMap};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
@@ -15,7 +16,7 @@ use wasmer_types::FunctionType;
|
|||||||
/// call must match. To implement this efficiently, keep a registry of all
|
/// 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
|
/// signatures, shared by all instances, so that call sites can just do an
|
||||||
/// index comparison.
|
/// index comparison.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
pub struct SignatureRegistry {
|
pub struct SignatureRegistry {
|
||||||
// This structure is stored in an `Engine` and is intended to be shared
|
// This structure is stored in an `Engine` and is intended to be shared
|
||||||
// across many instances. Ideally instances can themselves be sent across
|
// across many instances. Ideally instances can themselves be sent across
|
||||||
@@ -25,7 +26,7 @@ pub struct SignatureRegistry {
|
|||||||
inner: RwLock<Inner>,
|
inner: RwLock<Inner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, MemoryUsage)]
|
||||||
struct Inner {
|
struct Inner {
|
||||||
signature2index: HashMap<FunctionType, VMSharedSignatureIndex>,
|
signature2index: HashMap<FunctionType, VMSharedSignatureIndex>,
|
||||||
index2signature: HashMap<VMSharedSignatureIndex, FunctionType>,
|
index2signature: HashMap<VMSharedSignatureIndex, FunctionType>,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crate::func_data_registry::VMFuncRef;
|
|||||||
use crate::trap::{Trap, TrapCode};
|
use crate::trap::{Trap, TrapCode};
|
||||||
use crate::vmcontext::VMTableDefinition;
|
use crate::vmcontext::VMTableDefinition;
|
||||||
use crate::VMExternRef;
|
use crate::VMExternRef;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::borrow::{Borrow, BorrowMut};
|
use std::borrow::{Borrow, BorrowMut};
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
@@ -19,14 +20,14 @@ use std::sync::Mutex;
|
|||||||
use wasmer_types::{ExternRef, TableType, Type as ValType};
|
use wasmer_types::{ExternRef, TableType, Type as ValType};
|
||||||
|
|
||||||
/// Implementation styles for WebAssembly tables.
|
/// Implementation styles for WebAssembly tables.
|
||||||
#[derive(Debug, Clone, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||||
pub enum TableStyle {
|
pub enum TableStyle {
|
||||||
/// Signatures are stored in the table and checked in the caller.
|
/// Signatures are stored in the table and checked in the caller.
|
||||||
CallerChecksSignature,
|
CallerChecksSignature,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait for implementing the interface of a Wasm table.
|
/// 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.
|
/// Returns the style for this Table.
|
||||||
fn style(&self) -> &TableStyle;
|
fn style(&self) -> &TableStyle;
|
||||||
|
|
||||||
@@ -134,6 +135,12 @@ pub union TableElement {
|
|||||||
pub(crate) func_ref: VMFuncRef,
|
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 {
|
impl fmt::Debug for TableElement {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
f.debug_struct("TableElement").finish()
|
f.debug_struct("TableElement").finish()
|
||||||
@@ -155,7 +162,7 @@ impl Default for TableReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A table instance.
|
/// A table instance.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
pub struct LinearTable {
|
pub struct LinearTable {
|
||||||
// TODO: we can remove the mutex by using atomic swaps and preallocating the max table size
|
// TODO: we can remove the mutex by using atomic swaps and preallocating the max table size
|
||||||
vec: Mutex<Vec<TableElement>>,
|
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
|
/// A type to help manage who is responsible for the backing table of the
|
||||||
/// `VMTableDefinition`.
|
/// `VMTableDefinition`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
enum VMTableDefinitionOwnership {
|
enum VMTableDefinitionOwnership {
|
||||||
/// The `VMTableDefinition` is owned by the `Instance` and we should use
|
/// 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.
|
/// its table. This is how a local table that's exported should be stored.
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
|
|
||||||
use core::fmt::{self, Display, Formatter};
|
use core::fmt::{self, Display, Formatter};
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// A trap code describing the reason for a trap.
|
/// A trap code describing the reason for a trap.
|
||||||
///
|
///
|
||||||
/// All trap instructions have an explicit trap code.
|
/// 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)]
|
#[repr(u32)]
|
||||||
pub enum TrapCode {
|
pub enum TrapCode {
|
||||||
/// The current stack space was exhausted.
|
/// The current stack space was exhausted.
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ use crate::memory::Memory;
|
|||||||
use crate::table::Table;
|
use crate::table::Table;
|
||||||
use crate::trap::{Trap, TrapCode};
|
use crate::trap::{Trap, TrapCode};
|
||||||
use crate::VMExternRef;
|
use crate::VMExternRef;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker, POINTER_BYTE_SIZE};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::mem;
|
||||||
use std::ptr::{self, NonNull};
|
use std::ptr::{self, NonNull};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::u32;
|
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.
|
/// An imported function.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct VMFunctionImport {
|
pub struct VMFunctionImport {
|
||||||
/// A pointer to the imported function body.
|
/// 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.
|
/// 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)]
|
#[repr(C)]
|
||||||
pub enum VMFunctionKind {
|
pub enum VMFunctionKind {
|
||||||
/// A static function has the native signature:
|
/// 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
|
/// The fields compiled code needs to access to utilize a WebAssembly table
|
||||||
/// imported from another instance.
|
/// imported from another instance.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct VMTableImport {
|
pub struct VMTableImport {
|
||||||
/// A pointer to the imported table description.
|
/// 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
|
/// The fields compiled code needs to access to utilize a WebAssembly linear
|
||||||
/// memory imported from another instance.
|
/// memory imported from another instance.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct VMMemoryImport {
|
pub struct VMMemoryImport {
|
||||||
/// A pointer to the imported memory description.
|
/// 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
|
/// The fields compiled code needs to access to utilize a WebAssembly global
|
||||||
/// variable imported from another instance.
|
/// variable imported from another instance.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct VMGlobalImport {
|
pub struct VMGlobalImport {
|
||||||
/// A pointer to the imported global variable description.
|
/// 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.
|
/// correctness in a multi-threaded context is concerned.
|
||||||
unsafe impl Sync for VMMemoryDefinition {}
|
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 {
|
impl VMMemoryDefinition {
|
||||||
/// Do an unsynchronized, non-atomic `memory.copy` for the memory.
|
/// Do an unsynchronized, non-atomic `memory.copy` for the memory.
|
||||||
///
|
///
|
||||||
@@ -455,6 +473,16 @@ pub struct VMTableDefinition {
|
|||||||
pub current_elements: u32,
|
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)]
|
#[cfg(test)]
|
||||||
mod test_vmtable_definition {
|
mod test_vmtable_definition {
|
||||||
use super::VMTableDefinition;
|
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.
|
/// The storage for a WebAssembly global defined within the instance.
|
||||||
///
|
///
|
||||||
/// TODO: Pack the globals more densely, rather than using the same size
|
/// TODO: Pack the globals more densely, rather than using the same size
|
||||||
/// for every type.
|
/// for every type.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
#[repr(C, align(16))]
|
#[repr(C, align(16))]
|
||||||
pub struct VMGlobalDefinition {
|
pub struct VMGlobalDefinition {
|
||||||
storage: VMGlobalDefinitionStorage,
|
storage: VMGlobalDefinitionStorage,
|
||||||
@@ -756,7 +790,7 @@ impl VMGlobalDefinition {
|
|||||||
/// An index into the shared signature registry, usable for checking signatures
|
/// An index into the shared signature registry, usable for checking signatures
|
||||||
/// at indirect calls.
|
/// at indirect calls.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash, MemoryUsage)]
|
||||||
pub struct VMSharedSignatureIndex(u32);
|
pub struct VMSharedSignatureIndex(u32);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -801,7 +835,7 @@ impl Default for VMSharedSignatureIndex {
|
|||||||
/// The VM caller-checked "anyfunc" record, for caller-side signature checking.
|
/// 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
|
/// It consists of the actual function pointer and a signature id to be checked
|
||||||
/// by the caller.
|
/// by the caller.
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, MemoryUsage)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct VMCallerCheckedAnyfunc {
|
pub struct VMCallerCheckedAnyfunc {
|
||||||
/// Function body.
|
/// Function body.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
use crate::module::ModuleInfo;
|
use crate::module::ModuleInfo;
|
||||||
use crate::VMBuiltinFunctionIndex;
|
use crate::VMBuiltinFunctionIndex;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use more_asserts::assert_lt;
|
use more_asserts::assert_lt;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use wasmer_types::{
|
use wasmer_types::{
|
||||||
@@ -33,7 +34,7 @@ const fn align(offset: u32, width: u32) -> u32 {
|
|||||||
/// related structs that JIT code accesses directly.
|
/// related structs that JIT code accesses directly.
|
||||||
///
|
///
|
||||||
/// [`VMContext`]: crate::vmcontext::VMContext
|
/// [`VMContext`]: crate::vmcontext::VMContext
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, MemoryUsage)]
|
||||||
pub struct VMOffsets {
|
pub struct VMOffsets {
|
||||||
/// The size in bytes of a pointer on the target.
|
/// The size in bytes of a pointer on the target.
|
||||||
pub pointer_size: u8,
|
pub pointer_size: u8,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true, default-features = false }
|
serde = { version = "1.0", features = ["derive"], optional = true, default-features = false }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "enable-serde"]
|
default = ["std", "enable-serde"]
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use crate::lib::std::boxed::Box;
|
|||||||
use crate::lib::std::marker::PhantomData;
|
use crate::lib::std::marker::PhantomData;
|
||||||
use crate::lib::std::ops::{Index, IndexMut};
|
use crate::lib::std::ops::{Index, IndexMut};
|
||||||
use crate::lib::std::slice;
|
use crate::lib::std::slice;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
/// A slice mapping `K -> V` allocating dense entity references.
|
/// 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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ use crate::lib::std::marker::PhantomData;
|
|||||||
use crate::lib::std::ops::{Index, IndexMut};
|
use crate::lib::std::ops::{Index, IndexMut};
|
||||||
use crate::lib::std::slice;
|
use crate::lib::std::slice;
|
||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
/// A primary mapping `K -> V` allocating dense entity references.
|
/// 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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ use crate::lib::std::marker::PhantomData;
|
|||||||
use crate::lib::std::ops::{Index, IndexMut};
|
use crate::lib::std::ops::{Index, IndexMut};
|
||||||
use crate::lib::std::slice;
|
use crate::lib::std::slice;
|
||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{Deserializer, SeqAccess, Visitor},
|
de::{Deserializer, SeqAccess, Visitor},
|
||||||
ser::{SerializeSeq, Serializer},
|
ser::{SerializeSeq, Serializer},
|
||||||
Deserialize, Serialize,
|
Deserialize, Serialize,
|
||||||
};
|
};
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
/// A mapping `K -> V` for densely indexed entity references.
|
/// 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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -5,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
/// Features usually have a corresponding [WebAssembly proposal].
|
/// Features usually have a corresponding [WebAssembly proposal].
|
||||||
///
|
///
|
||||||
/// [WebAssembly proposal]: https://github.com/WebAssembly/proposals
|
/// [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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Features {
|
pub struct Features {
|
||||||
/// Threads proposal should be enabled
|
/// Threads proposal should be enabled
|
||||||
|
|||||||
@@ -1,83 +1,84 @@
|
|||||||
//! Helper functions and structures for the translation.
|
//! Helper functions and structures for the translation.
|
||||||
use crate::entity::entity_impl;
|
use crate::entity::entity_impl;
|
||||||
use core::u32;
|
use core::u32;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Index type of a function defined locally inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LocalFunctionIndex(u32);
|
pub struct LocalFunctionIndex(u32);
|
||||||
entity_impl!(LocalFunctionIndex);
|
entity_impl!(LocalFunctionIndex);
|
||||||
|
|
||||||
/// Index type of a table defined locally inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LocalTableIndex(u32);
|
pub struct LocalTableIndex(u32);
|
||||||
entity_impl!(LocalTableIndex);
|
entity_impl!(LocalTableIndex);
|
||||||
|
|
||||||
/// Index type of a memory defined locally inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LocalMemoryIndex(u32);
|
pub struct LocalMemoryIndex(u32);
|
||||||
entity_impl!(LocalMemoryIndex);
|
entity_impl!(LocalMemoryIndex);
|
||||||
|
|
||||||
/// Index type of a global defined locally inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct LocalGlobalIndex(u32);
|
pub struct LocalGlobalIndex(u32);
|
||||||
entity_impl!(LocalGlobalIndex);
|
entity_impl!(LocalGlobalIndex);
|
||||||
|
|
||||||
/// Index type of a function (imported or local) inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct FunctionIndex(u32);
|
pub struct FunctionIndex(u32);
|
||||||
entity_impl!(FunctionIndex);
|
entity_impl!(FunctionIndex);
|
||||||
|
|
||||||
/// Index type of a table (imported or local) inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct TableIndex(u32);
|
pub struct TableIndex(u32);
|
||||||
entity_impl!(TableIndex);
|
entity_impl!(TableIndex);
|
||||||
|
|
||||||
/// Index type of a global variable (imported or local) inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct GlobalIndex(u32);
|
pub struct GlobalIndex(u32);
|
||||||
entity_impl!(GlobalIndex);
|
entity_impl!(GlobalIndex);
|
||||||
|
|
||||||
/// Index type of a linear memory (imported or local) inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct MemoryIndex(u32);
|
pub struct MemoryIndex(u32);
|
||||||
entity_impl!(MemoryIndex);
|
entity_impl!(MemoryIndex);
|
||||||
|
|
||||||
/// Index type of a signature (imported or local) inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct SignatureIndex(u32);
|
pub struct SignatureIndex(u32);
|
||||||
entity_impl!(SignatureIndex);
|
entity_impl!(SignatureIndex);
|
||||||
|
|
||||||
/// Index type of a passive data segment inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct DataIndex(u32);
|
pub struct DataIndex(u32);
|
||||||
entity_impl!(DataIndex);
|
entity_impl!(DataIndex);
|
||||||
|
|
||||||
/// Index type of a passive element segment inside the WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct ElemIndex(u32);
|
pub struct ElemIndex(u32);
|
||||||
entity_impl!(ElemIndex);
|
entity_impl!(ElemIndex);
|
||||||
|
|
||||||
/// Index type of a custom section inside a WebAssembly module.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct CustomSectionIndex(u32);
|
pub struct CustomSectionIndex(u32);
|
||||||
entity_impl!(CustomSectionIndex);
|
entity_impl!(CustomSectionIndex);
|
||||||
|
|
||||||
/// An entity to export.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum ExportIndex {
|
pub enum ExportIndex {
|
||||||
/// Function export.
|
/// Function export.
|
||||||
@@ -91,7 +92,7 @@ pub enum ExportIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An entity to import.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum ImportIndex {
|
pub enum ImportIndex {
|
||||||
/// Function import.
|
/// Function import.
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex};
|
use crate::indexes::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex};
|
||||||
use crate::lib::std::boxed::Box;
|
use crate::lib::std::boxed::Box;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
|
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A WebAssembly table initializer.
|
/// A WebAssembly table initializer.
|
||||||
#[derive(Clone, Debug, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Hash, Serialize, Deserialize, MemoryUsage)]
|
||||||
pub struct TableInitializer {
|
pub struct TableInitializer {
|
||||||
/// The index of a table to initialize.
|
/// The index of a table to initialize.
|
||||||
pub table_index: TableIndex,
|
pub table_index: TableIndex,
|
||||||
@@ -19,7 +20,7 @@ pub struct TableInitializer {
|
|||||||
|
|
||||||
/// A memory index and offset within that memory where a data initialization
|
/// A memory index and offset within that memory where a data initialization
|
||||||
/// should be performed.
|
/// should be performed.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, MemoryUsage)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct DataInitializerLocation {
|
pub struct DataInitializerLocation {
|
||||||
/// The index of the memory to initialize.
|
/// The index of the memory to initialize.
|
||||||
@@ -45,7 +46,7 @@ pub struct DataInitializer<'data> {
|
|||||||
|
|
||||||
/// As `DataInitializer` but owning the data rather than
|
/// As `DataInitializer` but owning the data rather than
|
||||||
/// holding a reference to it
|
/// holding a reference to it
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, MemoryUsage)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct OwnedDataInitializer {
|
pub struct OwnedDataInitializer {
|
||||||
/// The location where the initialization is to be performed.
|
/// The location where the initialization is to be performed.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::lib::std::string::{String, ToString};
|
|||||||
use crate::lib::std::vec::Vec;
|
use crate::lib::std::vec::Vec;
|
||||||
use crate::units::Pages;
|
use crate::units::Pages;
|
||||||
use crate::values::{Value, ValueEnumType};
|
use crate::values::{Value, ValueEnumType};
|
||||||
|
use loupe::{MemoryUsage, MemoryUsageTracker};
|
||||||
|
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -15,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
// Value Types
|
// Value Types
|
||||||
|
|
||||||
/// A list of all possible value types in WebAssembly.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
/// Signed 32 bit integer.
|
/// 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
|
// External Types
|
||||||
|
|
||||||
/// A list of all possible types which can be externally referenced from a
|
/// 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.
|
/// in a Wasm module or exposed to Wasm by the host.
|
||||||
///
|
///
|
||||||
/// WebAssembly functions can have 0 or more parameters and results.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct FunctionType {
|
pub struct FunctionType {
|
||||||
/// The parameters of the function
|
/// The parameters of the function
|
||||||
@@ -310,7 +317,7 @@ impl From<&FunctionType> for FunctionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Indicator of whether a global is mutable or not
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum Mutability {
|
pub enum Mutability {
|
||||||
/// The global is constant and its value does not change
|
/// The global is constant and its value does not change
|
||||||
@@ -346,7 +353,7 @@ impl From<Mutability> for bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// WebAssembly global.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct GlobalType {
|
pub struct GlobalType {
|
||||||
/// The type of the value stored in the global.
|
/// 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.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum GlobalInit {
|
pub enum GlobalInit {
|
||||||
/// An `i32.const`.
|
/// An `i32.const`.
|
||||||
@@ -441,7 +448,7 @@ impl GlobalInit {
|
|||||||
/// Tables are contiguous chunks of a specific element, typically a `funcref` or
|
/// 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
|
/// an `externref`. The most common use for tables is a function table through
|
||||||
/// which `call_indirect` can invoke other functions.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct TableType {
|
pub struct TableType {
|
||||||
/// The type of data stored in elements of the table.
|
/// 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
|
/// Memories are described in units of pages (64KB) and represent contiguous
|
||||||
/// chunks of addressable memory.
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct MemoryType {
|
pub struct MemoryType {
|
||||||
/// The minimum number of pages in the memory.
|
/// The minimum number of pages in the memory.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::lib::std::convert::TryFrom;
|
use crate::lib::std::convert::TryFrom;
|
||||||
use crate::lib::std::fmt;
|
use crate::lib::std::fmt;
|
||||||
use crate::lib::std::ops::{Add, Sub};
|
use crate::lib::std::ops::{Add, Sub};
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
@@ -19,7 +20,7 @@ pub const WASM_MAX_PAGES: u32 = 0x10000;
|
|||||||
pub const WASM_MIN_PAGES: u32 = 0x100;
|
pub const WASM_MIN_PAGES: u32 = 0x100;
|
||||||
|
|
||||||
/// Units of WebAssembly pages (as specified to be 65,536 bytes).
|
/// 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))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Pages(pub u32);
|
pub struct Pages(pub u32);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use crate::utils::get_store_with_middlewares;
|
use crate::utils::get_store_with_middlewares;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer::wasmparser::Operator;
|
use wasmer::wasmparser::Operator;
|
||||||
use wasmer::*;
|
use wasmer::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
struct Add2MulGen {
|
struct Add2MulGen {
|
||||||
value_off: i32,
|
value_off: i32,
|
||||||
}
|
}
|
||||||
@@ -47,7 +48,7 @@ impl FunctionMiddleware for Add2Mul {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, MemoryUsage)]
|
||||||
struct FusionGen;
|
struct FusionGen;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ wasmer-engine = { path = "../../../lib/engine", version = "1.0.2" }
|
|||||||
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
|
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
|
||||||
serde_bytes = { version = "0.11", optional = true }
|
serde_bytes = { version = "0.11", optional = true }
|
||||||
bincode = { version = "1.2", optional = true }
|
bincode = { version = "1.2", optional = true }
|
||||||
|
loupe = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Enable the `compiler` feature if you want the engine to compile
|
# Enable the `compiler` feature if you want the engine to compile
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
//! done as separate steps.
|
//! done as separate steps.
|
||||||
|
|
||||||
use crate::engine::DummyEngine;
|
use crate::engine::DummyEngine;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -21,6 +22,7 @@ use wasmer_vm::{
|
|||||||
|
|
||||||
/// Serializable struct for the artifact
|
/// Serializable struct for the artifact
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct DummyArtifactMetadata {
|
pub struct DummyArtifactMetadata {
|
||||||
pub module: Arc<ModuleInfo>,
|
pub module: Arc<ModuleInfo>,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
@@ -34,10 +36,11 @@ pub struct DummyArtifactMetadata {
|
|||||||
///
|
///
|
||||||
/// This artifact will point to fake finished functions and trampolines
|
/// This artifact will point to fake finished functions and trampolines
|
||||||
/// as no functions are really compiled.
|
/// as no functions are really compiled.
|
||||||
|
#[derive(MemoryUsage)]
|
||||||
pub struct DummyArtifact {
|
pub struct DummyArtifact {
|
||||||
metadata: DummyArtifactMetadata,
|
metadata: DummyArtifactMetadata,
|
||||||
|
|
||||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
|
#[loupe(skip)]
|
||||||
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
finished_function_call_trampolines: BoxedSlice<SignatureIndex, VMTrampoline>,
|
||||||
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
finished_dynamic_function_trampolines: BoxedSlice<FunctionIndex, FunctionBodyPtr>,
|
||||||
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
signatures: BoxedSlice<SignatureIndex, VMSharedSignatureIndex>,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//! Dummy Engine.
|
//! Dummy Engine.
|
||||||
|
|
||||||
use crate::DummyArtifact;
|
use crate::DummyArtifact;
|
||||||
|
use loupe::MemoryUsage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer_compiler::{CompileError, Features, Target};
|
use wasmer_compiler::{CompileError, Features, Target};
|
||||||
use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables};
|
use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables};
|
||||||
@@ -20,7 +21,7 @@ extern "C" fn dummy_trampoline(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A WebAssembly `Dummy` Engine.
|
/// A WebAssembly `Dummy` Engine.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct DummyEngine {
|
pub struct DummyEngine {
|
||||||
signatures: Arc<SignatureRegistry>,
|
signatures: Arc<SignatureRegistry>,
|
||||||
func_data: Arc<FuncDataRegistry>,
|
func_data: Arc<FuncDataRegistry>,
|
||||||
|
|||||||
Reference in New Issue
Block a user