|
|
|
[package]
|
|
|
|
name = "wasmtime-cli"
|
|
|
|
version = "0.28.0"
|
|
|
|
authors = ["The Wasmtime Project Developers"]
|
|
|
|
description = "Command-line interface for Wasmtime"
|
|
|
|
license = "Apache-2.0 WITH LLVM-exception"
|
|
|
|
documentation = "https://bytecodealliance.github.io/wasmtime/cli.html"
|
|
|
|
categories = ["wasm"]
|
|
|
|
keywords = ["webassembly", "wasm"]
|
|
|
|
repository = "https://github.com/bytecodealliance/wasmtime"
|
|
|
|
readme = "README.md"
|
|
|
|
edition = "2018"
|
|
|
|
default-run = "wasmtime"
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
doctest = false
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "wasmtime"
|
|
|
|
path = "src/bin/wasmtime.rs"
|
|
|
|
doc = false
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
# Enable all supported architectures by default.
|
|
|
|
wasmtime = { path = "crates/wasmtime", version = "0.28.0", default-features = false, features = ['cache'] }
|
|
|
|
wasmtime-cache = { path = "crates/cache", version = "0.28.0" }
|
|
|
|
wasmtime-debug = { path = "crates/debug", version = "0.28.0" }
|
|
|
|
wasmtime-environ = { path = "crates/environ", version = "0.28.0" }
|
|
|
|
wasmtime-jit = { path = "crates/jit", version = "0.28.0" }
|
|
|
|
wasmtime-obj = { path = "crates/obj", version = "0.28.0" }
|
|
|
|
wasmtime-wast = { path = "crates/wast", version = "0.28.0" }
|
|
|
|
wasmtime-wasi = { path = "crates/wasi", version = "0.28.0" }
|
|
|
|
wasmtime-wasi-crypto = { path = "crates/wasi-crypto", version = "0.28.0", optional = true }
|
|
|
|
wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "0.28.0", optional = true }
|
|
|
|
structopt = { version = "0.3.5", features = ["color", "suggestions"] }
|
|
|
|
object = { version = "0.26.0", default-features = false, features = ["write"] }
|
|
|
|
anyhow = "1.0.19"
|
cranelift: add support for the Mac aarch64 calling convention
This bumps target-lexicon and adds support for the AppleAarch64 calling
convention. Specifically for WebAssembly support, we only have to worry
about the new stack slots convention. Stack slots don't need to be at
least 8-bytes, they can be as small as the data type's size. For
instance, if we need stack slots for (i32, i32), they can be located at
offsets (+0, +4). Note that they still need to be properly aligned on
the data type they're containing, though, so if we need stack slots for
(i32, i64), we can't start the i64 slot at the +4 offset (it must start
at the +8 offset).
Added one test that was failing on the Mac M1, as well as other tests
stressing different yet similar situations.
4 years ago
|
|
|
target-lexicon = { version = "0.12.0", default-features = false }
|
|
|
|
pretty_env_logger = "0.4.0"
|
|
|
|
file-per-thread-logger = "0.1.1"
|
|
|
|
wat = "1.0.38"
|
|
|
|
libc = "0.2.60"
|
externref: implement stack map-based garbage collection
For host VM code, we use plain reference counting, where cloning increments
the reference count, and dropping decrements it. We can avoid many of the
on-stack increment/decrement operations that typically plague the
performance of reference counting via Rust's ownership and borrowing system.
Moving a `VMExternRef` avoids mutating its reference count, and borrowing it
either avoids the reference count increment or delays it until if/when the
`VMExternRef` is cloned.
When passing a `VMExternRef` into compiled Wasm code, we don't want to do
reference count mutations for every compiled `local.{get,set}`, nor for
every function call. Therefore, we use a variation of **deferred reference
counting**, where we only mutate reference counts when storing
`VMExternRef`s somewhere that outlives the activation: into a global or
table. Simultaneously, we over-approximate the set of `VMExternRef`s that
are inside Wasm function activations. Periodically, we walk the stack at GC
safe points, and use stack map information to precisely identify the set of
`VMExternRef`s inside Wasm activations. Then we take the difference between
this precise set and our over-approximation, and decrement the reference
count for each of the `VMExternRef`s that are in our over-approximation but
not in the precise set. Finally, the over-approximation is replaced with the
precise set.
The `VMExternRefActivationsTable` implements the over-approximized set of
`VMExternRef`s referenced by Wasm activations. Calling a Wasm function and
passing it a `VMExternRef` moves the `VMExternRef` into the table, and the
compiled Wasm function logically "borrows" the `VMExternRef` from the
table. Similarly, `global.get` and `table.get` operations clone the gotten
`VMExternRef` into the `VMExternRefActivationsTable` and then "borrow" the
reference out of the table.
When a `VMExternRef` is returned to host code from a Wasm function, the host
increments the reference count (because the reference is logically
"borrowed" from the `VMExternRefActivationsTable` and the reference count
from the table will be dropped at the next GC).
For more general information on deferred reference counting, see *An
Examination of Deferred Reference Counting and Cycle Detection* by Quinane:
https://openresearch-repository.anu.edu.au/bitstream/1885/42030/2/hon-thesis.pdf
cc #929
Fixes #1804
4 years ago
|
|
|
log = "0.4.8"
|
|
|
|
rayon = "1.5.0"
|
|
|
|
humantime = "2.0.0"
|
|
|
|
wasmparser = "0.79.0"
|
|
|
|
lazy_static = "1.4.0"
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
env_logger = "0.8.1"
|
|
|
|
filecheck = "0.5.0"
|
|
|
|
more-asserts = "0.2.1"
|
|
|
|
tempfile = "3.1.0"
|
|
|
|
test-programs = { path = "crates/test-programs" }
|
|
|
|
wasmtime-fuzzing = { path = "crates/fuzzing" }
|
|
|
|
wasmtime-runtime = { path = "crates/runtime" }
|
|
|
|
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
|
|
|
|
tracing-subscriber = "0.2.16"
|
|
|
|
wast = "36.0.0"
|
|
|
|
criterion = "0.3.4"
|
|
|
|
num_cpus = "1.13.0"
|
Add guard pages to the front of linear memories (#2977)
* Add guard pages to the front of linear memories
This commit implements a safety feature for Wasmtime to place guard
pages before the allocation of all linear memories. Guard pages placed
after linear memories are typically present for performance (at least)
because it can help elide bounds checks. Guard pages before a linear
memory, however, are never strictly needed for performance or features.
The intention of a preceding guard page is to help insulate against bugs
in Cranelift or other code generators, such as CVE-2021-32629.
This commit adds a `Config::guard_before_linear_memory` configuration
option, defaulting to `true`, which indicates whether guard pages should
be present both before linear memories as well as afterwards. Guard
regions continue to be controlled by
`{static,dynamic}_memory_guard_size` methods.
The implementation here affects both on-demand allocated memories as
well as the pooling allocator for memories. For on-demand memories this
adjusts the size of the allocation as well as adjusts the calculations
for the base pointer of the wasm memory. For the pooling allocator this
will place a singular extra guard region at the very start of the
allocation for memories. Since linear memories in the pooling allocator
are contiguous every memory already had a preceding guard region in
memory, it was just the previous memory's guard region afterwards. Only
the first memory needed this extra guard.
I've attempted to write some tests to help test all this, but this is
all somewhat tricky to test because the settings are pretty far away
from the actual behavior. I think, though, that the tests added here
should help cover various use cases and help us have confidence in
tweaking the various `Config` settings beyond their defaults.
Note that this also contains a semantic change where
`InstanceLimits::memory_reservation_size` has been removed. Instead this
field is now inferred from the `static_memory_maximum_size` and guard
size settings. This should hopefully remove some duplication in these
settings, canonicalizing on the guard-size/static-size settings as the
way to control memory sizes and virtual reservations.
* Update config docs
* Fix a typo
* Fix benchmark
* Fix wasmtime-runtime tests
* Fix some more tests
* Try to fix uffd failing test
* Review items
* Tweak 32-bit defaults
Makes the pooling allocator a bit more reasonable by default on 32-bit
with these settings.
3 years ago
|
|
|
winapi = { version = "0.3.9", features = ['memoryapi'] }
|
|
|
|
|
|
|
|
[build-dependencies]
|
|
|
|
anyhow = "1.0.19"
|
|
|
|
|
|
|
|
[profile.release.build-override]
|
|
|
|
opt-level = 0
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
resolver = '2'
|
|
|
|
members = [
|
|
|
|
"cranelift",
|
|
|
|
"crates/bench-api",
|
|
|
|
"crates/c-api",
|
|
|
|
"crates/misc/run-examples",
|
|
|
|
"examples/fib-debug/wasm",
|
|
|
|
"examples/wasi/wasm",
|
|
|
|
"examples/tokio/wasm",
|
|
|
|
"fuzz",
|
|
|
|
]
|
|
|
|
exclude = ['crates/wasi-common/WASI/tools/witx-cli']
|
|
|
|
|
|
|
|
[features]
|
|
|
|
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation", "wasi-nn"]
|
|
|
|
lightbeam = ["wasmtime/lightbeam"]
|
|
|
|
jitdump = ["wasmtime/jitdump"]
|
|
|
|
vtune = ["wasmtime/vtune"]
|
|
|
|
wasi-crypto = ["wasmtime-wasi-crypto"]
|
|
|
|
wasi-nn = ["wasmtime-wasi-nn"]
|
|
|
|
uffd = ["wasmtime/uffd"]
|
|
|
|
all-arch = ["wasmtime/all-arch"]
|
|
|
|
posix-signals-on-macos = ["wasmtime/posix-signals-on-macos"]
|
|
|
|
|
|
|
|
# Stub feature that does nothing, for Cargo-features compatibility: the new
|
|
|
|
# backend is the default now.
|
|
|
|
experimental_x64 = []
|
|
|
|
|
|
|
|
# Use the old x86 backend.
|
Fully support multiple returns in Wasmtime (#2806)
* Fully support multiple returns in Wasmtime
For quite some time now Wasmtime has "supported" multiple return values,
but only in the mose bare bones ways. Up until recently you couldn't get
a typed version of functions with multiple return values, and never have
you been able to use `Func::wrap` with functions that return multiple
values. Even recently where `Func::typed` can call functions that return
multiple values it uses a double-indirection by calling a trampoline
which calls the real function.
The underlying reason for this lack of support is that cranelift's ABI
for returning multiple values is not possible to write in Rust. For
example if a wasm function returns two `i32` values there is no Rust (or
C!) function you can write to correspond to that. This commit, however
fixes that.
This commit adds two new ABIs to Cranelift: `WasmtimeSystemV` and
`WasmtimeFastcall`. The intention is that these Wasmtime-specific ABIs
match their corresponding ABI (e.g. `SystemV` or `WindowsFastcall`) for
everything *except* how multiple values are returned. For multiple
return values we simply define our own version of the ABI which Wasmtime
implements, which is that for N return values the first is returned as
if the function only returned that and the latter N-1 return values are
returned via an out-ptr that's the last parameter to the function.
These custom ABIs provides the ability for Wasmtime to bind these in
Rust meaning that `Func::wrap` can now wrap functions that return
multiple values and `Func::typed` no longer uses trampolines when
calling functions that return multiple values. Although there's lots of
internal changes there's no actual changes in the API surface area of
Wasmtime, just a few more impls of more public traits which means that
more types are supported in more places!
Another change made with this PR is a consolidation of how the ABI of
each function in a wasm module is selected. The native `SystemV` ABI,
for example, is more efficient at returning multiple values than the
wasmtime version of the ABI (since more things are in more registers).
To continue to take advantage of this Wasmtime will now classify some
functions in a wasm module with the "fast" ABI. Only functions that are
not reachable externally from the module are classified with the fast
ABI (e.g. those not exported, used in tables, or used with `ref.func`).
This should enable purely internal functions of modules to have a faster
calling convention than those which might be exposed to Wasmtime itself.
Closes #1178
* Tweak some names and add docs
* "fix" lightbeam compile
* Fix TODO with dummy environ
* Unwind info is a property of the target, not the ABI
* Remove lightbeam unused imports
* Attempt to fix arm64
* Document new ABIs aren't stable
* Fix filetests to use the right target
* Don't always do 64-bit stores with cranelift
This was overwriting upper bits when 32-bit registers were being stored
into return values, so fix the code inline to do a sized store instead
of one-size-fits-all store.
* At least get tests passing on the old backend
* Fix a typo
* Add some filetests with mixed abi calls
* Get `multi` example working
* Fix doctests on old x86 backend
* Add a mixture of wasmtime/system_v tests
4 years ago
|
|
|
old-x86-backend = ["wasmtime/old-x86-backend"]
|
|
|
|
|
|
|
|
[badges]
|
|
|
|
maintenance = { status = "actively-developed" }
|
|
|
|
|
|
|
|
[[test]]
|
|
|
|
name = "host_segfault"
|
|
|
|
harness = false
|
externref: implement stack map-based garbage collection
For host VM code, we use plain reference counting, where cloning increments
the reference count, and dropping decrements it. We can avoid many of the
on-stack increment/decrement operations that typically plague the
performance of reference counting via Rust's ownership and borrowing system.
Moving a `VMExternRef` avoids mutating its reference count, and borrowing it
either avoids the reference count increment or delays it until if/when the
`VMExternRef` is cloned.
When passing a `VMExternRef` into compiled Wasm code, we don't want to do
reference count mutations for every compiled `local.{get,set}`, nor for
every function call. Therefore, we use a variation of **deferred reference
counting**, where we only mutate reference counts when storing
`VMExternRef`s somewhere that outlives the activation: into a global or
table. Simultaneously, we over-approximate the set of `VMExternRef`s that
are inside Wasm function activations. Periodically, we walk the stack at GC
safe points, and use stack map information to precisely identify the set of
`VMExternRef`s inside Wasm activations. Then we take the difference between
this precise set and our over-approximation, and decrement the reference
count for each of the `VMExternRef`s that are in our over-approximation but
not in the precise set. Finally, the over-approximation is replaced with the
precise set.
The `VMExternRefActivationsTable` implements the over-approximized set of
`VMExternRef`s referenced by Wasm activations. Calling a Wasm function and
passing it a `VMExternRef` moves the `VMExternRef` into the table, and the
compiled Wasm function logically "borrows" the `VMExternRef` from the
table. Similarly, `global.get` and `table.get` operations clone the gotten
`VMExternRef` into the `VMExternRefActivationsTable` and then "borrow" the
reference out of the table.
When a `VMExternRef` is returned to host code from a Wasm function, the host
increments the reference count (because the reference is logically
"borrowed" from the `VMExternRefActivationsTable` and the reference count
from the table will be dropped at the next GC).
For more general information on deferred reference counting, see *An
Examination of Deferred Reference Counting and Cycle Detection* by Quinane:
https://openresearch-repository.anu.edu.au/bitstream/1885/42030/2/hon-thesis.pdf
cc #929
Fixes #1804
4 years ago
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "tokio"
|
|
|
|
required-features = ["wasmtime-wasi/tokio"]
|
|
|
|
|
|
|
|
[profile.dev.package.backtrace]
|
|
|
|
debug = false # FIXME(#1813)
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "instantiation"
|
|
|
|
harness = false
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "thread_eager_init"
|
|
|
|
harness = false
|