This commit makes it so that the library type for core dumps is serializable
into the standard binary format for core dumps.
Additionally, this commit makes it so that we use the library type for
generating core dumps in the CLI. We previously were using a one-off
implementation of core dump generation that only had backtrace information and
no instances, modules, globals, or memories included. The library type has all
that information, so the core dumps produced by our CLI will both be more
featureful and be generated by shared code paths going forward.
Along the way, implementing all this required some new helper methods sprinkled
throughout `wasmtime` and `wasmtime-runtime`:
* `wasmtime::Instance::module`: get the module that a `wasmtime::Instance` is an
instance of. This is public, since it seems generally useful. This involved
adding a new return value from `ModuleRegistry::register_module` that is an
identifier that can be used to recover a reference to the registered module.
* `wasmtime::Instance::all_{globals,memories}`: get the full global/memory index
space. I made these `pub(crate)` out of caution. I don't think we want to commit
to exposing non-exported things in the public API, even if we internally need
them for debugging-related features like core dumps. These also needed
corresponding methods inside `wasmtime-runtime`.
* `wasmtime::{Global,Memory}::hash_key`: this was needed to work around the fact
that each time you call `{Global,Memory}::from_wasmtime`, it creates a new
entry in the `StoreData` and so you can get duplicates. But we need to key some
hash maps on globals and memories when constructing core dumps, so we can't
treat the underlying `Stored<T>` as a hash key because it isn't stable across
duplicate `StoreData` entries. So we have these new methods. They are only
`pub(crate)`, are definitely implementation details, and aren't exposed in the
public API.
* `wasmtime::FrameInfo::module`: Each frame in a backtrace now keeps a handle to
its associated module instead of just the name. This is publicly exposed
because it seems generally useful. This means I also deprecated
`wasmtime::FrameInfo::module_name` since you can now instead do
`frame.module().name()` to get that exact same info. I updated callers inside
the repo.
* Include Wasm-defined globals and memories in core dumps
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
* Narrow scope of unsafe block
* Add missing skip-miri attribute for test that calls into Wasm
---------
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
* Support resource maps in `component::bindgen!`
This commit adds support to `component::bindgen!` to specify resource
types using the `with` key of the macro. This can be used to configure
the `T` of `Resource<T>` to use a preexisting type rather than
unconditionally generating a new empty enum to have a fresh type.
* Reenable tests
* Start refactoring wasi-http
* Checkpoint
* Initial implementation of response future handling
* Lazily initialize response headers and body
* make wasmtime-wasi-http compile
* wasi-http wit: make a way to reject outgoing-request in outgoing-handler
before waiting for the future to resolve
* wasi: sync wit from wasi-http
* outgoing handler impl: report errors to userland
* test-programs: get wasi-http-components kicking over, delete modules and components-sync tests
wasi-http-components-sync will come back once we get done with other
stuff, but its superfulous for now. wasi-http-modules will not be
returning.
* Process headers
* Add HostIncomingBody::new
* Add trailers functions
* Add TODO for body task outline
* Rework incoming-response-consume to return a future-trailers value as well
* Fix the wit
* First cut at the worker loop
* wasi-http: change how we represent bodies/trailers, and annotate own/borrow/child throughout
* Update types_impl.rs for wit changes
* Split body management into its own module
* Checkpoint
* more work on incoming body and future trailers
* Fill out some more functions
* Implement future-trailers-{subscribe,get}
* Implement drop-future-trailers
* Rework fields, but make the borrow checker mad
* Fix borrow error
* wasi-http-tests: fix build
* test-runner: report errors with stdout/stderr properly
* fix two trivial wasi-http tests
the error type here changed from a types::Error to an
outbound_handler::Error
* Remove unnecessary drops
* Convert a `bail!` to a `todo!`
* Remove a TODO that documented the body worker structure
* fill in a bunch more of OutputBody
* Remove the custom FrameFut future in favor of using http_body_util
* Move the outgoing body types to body.rs
* Rework the handling of outgoing bodies
* Fix the `outgoing request get` test
* Avoid deadlocking the post tests
* future_incoming_request_get shouldn't delete the resource
* Fix the invalid_dnsname test
* implement drop-future-incoming-response
* Fix invalid_port and invalid_dnsname tests
* Fix the post test
* Passing a too large string to println! caused the large post test to fail
* Format
* Plumb through `between_bytes_timeout`
* Downgrade hyper
* Revert "Downgrade hyper"
This reverts commit fa0750e0c42823cb785288fcf6c0507c5ae9fd64.
* Restore old https connection setup
* Sync the wasi and wasi-http http deps
* Fix tests
* Remove the module and component-sync tests, as they are currently not
supported
* Fix the reference to the large_post test in the components test
* Fix wasi-http integration
* sync implementation of wasi-http
* Slightly more robust error checking
* Ignore the wasi-http cli test
prtest:full
* Consistent ignore attributes between sync and async tests
* Fix doc errors
* code motion: introduce intermediate `HostIncomingBodyBuilder` rather than a tuple
* explain design
* Turn FieldMap into a type synonym
* Tidy up some future state (#7073)
Co-authored-by: Pat Hickey <phickey@fastly.com>
* body HostInputStream: report runtime errors with StreamRuntimeError
HostInputStream is designed wrong to need that in the first place. We
will fix it in a follow-up as soon as resources land.
---------
Co-authored-by: Pat Hickey <phickey@fastly.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
Instead of relying purely on the assumption that type handles can be compared
cheaply by pointer equality, fallback to a more expensive walk of the
type tree that recursively compares types structurally.
This allows different components to call into each other as long as
their types are structurally equivalent.
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
* Fix documentation typos
While working on integrating MPK into Wasmtime, I found these typos and
line-wrapping issues. This fix is a separate commit to separate it from
the already-complex MPK implementation.
* fix: remove extra changes
* Fix character boundary issues in preview1 host adapter
This fixes two separate issues in the preview1-to-preview2 host-side
adapter in the `wasmtime-wasi` crate. Both instances were copying a
truncated string to the guest program but the truncation was happening
in the middle of a unicode character so truncation now happens on bytes
instead of a string.
* Update `write_bytes` to take `&[u8]`
Try to weed out any accidental string-related issues for the future.
* wasi: Fix a few issues around stdin
This commit is intended to address #6986 and some other issues related
to stdin and reading it, notably:
* Previously once EOF was reached the `closed` flag was mistakenly not
set.
* Previously data would be infinitely buffered regardless of how fast
the guest program would consume it.
* Previously stdin would be immediately ready by Wasmtime regardless of
whether the guest wanted to read stdin or not.
* The host-side preview1-to-preview2 adapter didn't perform a blocking
read meaning that it never blocked.
These issues are addressed by refactoring the code in question.
Note that this is similar to the logic of `AsyncReadStream` somewhat but
that type is not appropriate in this context due to the singleton nature
of stdin meaning that the per-stream helper task and per-stream buffer
of `AsyncReadStream` are not appropriate.
Closees #6986
* Increase slop size for windows
This commit is a follow-up to #6833 to remove the `unix` module for
handling stdio which sets stdin to nonblocking mode. I've just now
discovered that on macOS at least configuring `O_NONBLOCK` for stdin
affects the stdout/stderr descriptors too. This program for example will
panic:
fn main() {
unsafe {
let r = libc::fcntl(
libc::STDIN_FILENO,
libc::F_SETFL,
libc::fcntl(libc::STDIN_FILENO, libc::F_GETFL) | libc::O_NONBLOCK,
);
assert_eq!(r, 0);
}
loop {
println!("hello");
}
}
It was originally assumed that updating the flags for stdin wouldn't
affect anything else except Wasmtime, but because this looks to not be
the case this commit removes the logic of registering stdin raw with
Tokio and instead unconditionally using the worker thread solution which
should work in all situations.
* Update wasm-tools family of crates
Mostly minor updates, but staying up-to-date.
* Update text format syntax
* Update cargo vet entries
* Update more old text syntax
* riscv64: Deduplicate Trap Instruction
* riscv64: Use `defer_trap` in TrapIf instruction
This places the actual trap opcode at the end.
* riscv64: Emit islands before `br_table` sequence
This fixes a slightly subtle issue with our island emission in BrTable.
We used to emit islands right before the jump table targets. This
causes issues because if the island is actually emitted, we have
the potential to jump right into the middle of it. This happens
because we have calculated a fixed offset from the `auipc` instruction
assuming no island is emitted.
This commit changes the island to be emitted right at the start of the
br_table sequence so that this cannot happen.
* riscv64: Add trapz and trapnz helpers
* riscv64: Emit inline traps on `TrapIf`
* cranelift: Add support for public labels
* cranelift: Allow targeting labels with relocations
* cranelift: Emit label related relocations in module
* riscv64: Implement TLS GD
* cranelift: Rename `label_is_public` field
* cranelift: Avoid making MachLabel part of the exposed API
* Implement support for exported resources in `bindgen!`
This commit updates the `wasmtime::component::bindgen!` to support
exported resources. Exported resources are themselves always modeled as
`ResourceAny` at runtime and are required to perform dynamic type checks
to ensure that the right type of resource is passed in. Exported
resources have their own `GuestXXX` structure exported to namespace all
of their methods. Otherwise, like imports, there's not a whole lot of
special treatment of exported resources.
* Work around `heck` issue
Looks like `to_snake_case` behaves differently if the `unicode` feature
is enabled or not so bypass that entirely.
* fix(wasi-http): honor permit in output stream
* chore: enable large body test for wasi http
* chore: disable large body test
* fix(wasi-http): ensure output stream is flushed
* fix(wasi-http): logical error in io check-write wrap
* chore: fix outbound issue in usize casting
* chore: enable large request test
* chore: fix warnings
* prtest:full
* chore: call unreachable only on wasm32 arch
prtest:full
* chore: disable wasi http tests failing on windows
* chore: use renamed large request test
I was curious to poke around the riscv64 backend and I wanted to touch
up the handling of `Imm{12,20}` a bit after reading it. This commit is a
refactoring of these two types with the following changes:
* The payload of these types is now unsigned and guarantees that
irrelevant bits are set to zero. For example `Imm12` is stored as
`u16` where the upper four bits are guaranteed to be zero. This fixes
a discrepancy where `Imm12::maybe_from_i64` was masked for example but
`Imm12::from_bits` wasn't.
* The `Neg for Imm12` impl was removed because -2048 is a valid
`Imm12` but 2048 is not in-range for `Imm12` meaning that it is not an
infallible operation.
* Accessors are now named `bits` to get the `u32` representation
suitable to be encoded into an instruction. Acquiring the underlying
value is now done with `as_i{16,32}` depending on the type. The signed
accessor does sign-extension as required to produce the semantically
equivalent value.
* Manual constructors were renamed to `from_{i16,i32}` instead of
`from_bits`. This in theory helps convey that they're constructors for
logical values rather than literal bit-wise values. Additionally
asserts are now placed in these constructors asserting that the
provided value is in-range.
* The `FALSE` and `TRUE` constants were renamed `ZERO` and `ONE` and
`Imm20::ZERO` was added.
This commit ended up changing many runtests, but only their CLIF
printing rather than their encoding. This change is due to the fact that
`Display` now prints the logical value of the immediate rather than the
raw bit representation as a base 10 integer. It's not intended that this
commit actually changes any behavior, instead it should purely be
internal refactorings.
* riscv64: Update funct4 field width on CR type
It's only 4 bits, not 5
* riscv64: Add CA Ops
* riscv64: Encode `c.j` instructions
* riscv64: Use uncompressed instructions where labels are used.
Not doing so could cause a compressed instruction to be emitted with the wrong label type.
* riscv64: Implement `c.jr` instruction
* riscv64: Implement `c.jalr` instruction
This also update CallIndirect to allow compressing Jalr
* riscv64: Update RVCJump label range
It is only +-2KiB instead of +-4KiB
This commit attempts to simplify the `preview2::bindings` module by
consolidating everything into a single invocation of `bindgen!`.
Previously this was separated out (I think) to handle some methods being
`async` and not others, but the `bindgen!` macro has since grown the
capability to have some functions async and not all.
* x64: Fix an off-by-one in in `i64x2.shr_s`
This commit fixes a mistake from #6372 where one of the immediates to a
`pshufd` instruction was off-by-one in terms of bits. This fixes the
behavior of the wasm `i64x2.shr_s` instruction with constant shift
amounts larger than 32.
* Update release notes
We run in a unique environment with very little memory, so
it's possible if there are many modules that we run out of memory,
callers should be able to handle this gracefully.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* Add support for `v128` to the typed function API
This commit adds a Rust type `V128` which corresponds to the wasm
`v128` type. This is intended to perhaps one day have accessors for
lanes of various sizes but in the meantime only supports conversion back
and forth between `u128`. The intention of this type is to allow
platforms to perform typed between to functions that take or return
`v128` wasm values.
Previously this was not implemented because it's a bit tricky ABI-wise.
Typed functions work by passing arguments in registers which requires
the calling convention to match in both Cranelift and in Rust. This
should be the case for supported platforms and the default calling
convention, especially now that the wasm calling convention is separate
from the platform calling convention. This does mean, however, that this
feature can only be supported on x86_64 and AArch64. Currently neither
s390x nor RISC-V have a means of supporting the vector calling
convention since the vector types aren't available on stable in Rust
itself. This means that it's now unfortunately possible to write a
Wasmtime embedding that compiles on x86_64 that doesn't compile on s390x
for example, but given how niche this feature is that seems like an ok
tradeoff for now and by the time it's a problem Rust might have native
stable support for vector types on these platforms.
prtest:full
* Fix compile of C API
* Conditionally enable typed v128 tests
* Review comments
* Fix compiler warnings
This commit implements a new behavior for the CLI of the `wasmtime`
executable which will require that options for Wasmtime itself come
before the wasm module being run. Currently they're allowed to come
afterwards, but instead all arguments and flags coming after a module
will be interpreted as arguments for the module itself.
This feature has a bit of a storied history at this point, and the
breadcrumbs are:
* Originally landed in #6737
* Reverted for 12.0.0 in #6830
* Reverted for 13.0.0 in #6944
This PR is intended to be landed as a sibling of #6925, another
independent overhaul of Wasmtime's own options on the CLI, for the
Wasmtime 14.0.0 release. More information about the motivation for this
change, as well as consequences of the fallout, can be found on #6737.
Due to a bug in the qemu emulation of the corresponding instruction,
tests for pseudo min/max support had been disabled. After moving
to qemu 8.0.4, where the bug is fixed, these can be re-enabled.
* add new wasi-test printing unicode on stdout
there's not yet a way to show this test is actually doing what we
intend, I'm using CI to see how this runs on all platforms
Reported in #6824
prtest:full
* cap-std-sync: use std::io::Std{in,out,err}'s {read,write}_vectored directly
instead of using AsFilelike to view these as a File.
This means we also have to use std's mutexes to access these descriptors,
which also seems like a good idea.
We believe will fix unicode output on windows issues:
https://github.com/bytecodealliance/wasmtime/issues/6824
This was removed in #6195 but re-added in #6877, I believe by accident,
so this re-deletes it. I've also edited `.gitmodules` a bit while I was
here to remove it and additionally keep other entries up-to-date with
matching paths.
The MachineEnv structure contains the allocatable and preferred
register sets. This is currently fixed per TargetIsa - however,
conceptually these register sets can differ between ABIs on the
same ISA.
To allow for this, replace the TargetIsa machine_env routine with
an ABIMachineSpec get_machine_env routine. To ensure the structure
is still only allocated once, cache it via static OnceLock variables.
No functional change intended.
This patch refactors all of the ISA/ABI specific prolog/epilog
generation code around the following two ideas:
1. Separate *planning* of the function's frame layout from the
actual *implementation* within prolog / epilog code.
2. No longer overload different purposes (middle-end register
tracking, platform-specific details like authorization modes,
and pop-stack-on-return) into a single return instruction.
As to 1., the new approach is based around a FrameLayout data
structure, which collects all information needed to emit prolog
and epilog code, specifically the list of clobbered registers,
and the sizes of all areas of the function's stack frame.
This data structure is now computed *once*, before any code is
emitted, and stored in the Callee data structure. ABIs need to
implement this via a new compute_frame_layout callback, which
gets all data from common code needed to make all decisions
around stack layout in one place.
The FrameLayout is then used going forward to answer all questions
about frame sizes, and it is passed to all ABI routines involved
in prolog / epilog code generation. [ This removes a lot of
duplicated calculation, e.g. the list of clobbered registers is
now only computed once and re-used everywhere. ]
This in turn allows to reduce the number of distinct callbacks
ABIs need to implement, and simplifies common code logic around
how and when to call them. In particular, we now only have the
following four routines, which are always called in this order:
gen_prologue_frame_setup
gen_clobber_save
gen_clobber_restore
gen_epilogue_frame_restore
The main differences to before are:
- frame_setup/restore are now called unconditionally (the target
ABI can look in the FrameLayout to detect the case where no
frame setup is required and skip whatever it thinks appropriate
in that case)
- there is no separate gen_prologue_start; if the target needs
to do anything here, it can now just do it instead in
gen_prologue_frame_setup
- common code no longer attempts to emit a return instruction;
instead the target can do whatever is necessary/optimal in
gen_epilogue_frame_restore
[ In principle we could also just have a single gen_prologue
and gen_epilogue callback - I didn't implement this because
then all the stack checking / probing logic would have to be
moved to target code as well. ]
As to 2., currently targets are required to implement a single
"Ret" return instruction. This is initially used during
register allocation to hold a list of return preg/vreg pairs.
During epilog emission, this is replaced by another copy of
the same "Ret" instruction that now carries various platform
specific data (e.g. authorization modes on aarch64), and is
also overloaded to handle the case where the ABI requires
that a number of bytes are popped during return.
This is a bit unfortunate in that it blows up the size of
the instruction data, and also forces targets (that do not
have a "ret N" instruction like Intel) into duplicated and
possible sub-optimal implementations of stack adjustment
during low-level emission of the return instruction.
The new approach separates these concerns. Initially, common
code emits a new "Rets" instruction that is completely parallel
to the existing "Args", and is used only during register
allocation holding the preg/vreg pairs. That instruction
-like now- is replaced during epilog emission - but unlike
now the replacement is now completely up to the target, which
can do whatever it needs in gen_epilogue_frame_restore.
This would typically emit some platform-specific low-level
"Ret" instruction instead of the regalloc "Rets". It also
allows non-Intel targets to just create a normal (or even
optimized) stack adjustment sequence before its low-level "Ret".
[ In particular, on riscv64 pop-stack-before-return currently
emits two distinct stack adjustment instructions immediately
after one another. These could now be easily merged, but that's
not yet done in this patch. ]
No functional change intended on any target.
* Stream backpressure v2
Co-authored-by: Pat Hickey <phickey@fastly.com>
Co-authored-by: Trevor Elliott <telliott@fastly.com>
Co-authored-by: Dan Gohman <dev@sunfishcode.online>
Stop testing pseudocode
Restructure when notifications are sent, and make sure to flush the writer
Fix the wasi-http module versions of flush and blocking_flush
Use blocking_write_and_flush for blocking writes in the adapters
Fix a warning in wasi-http
Remove an unused DropPollable
add comment explaining try_write for tcpstream
refactor: separate struct for representing TcpReadStream
by factoring into HostTcpSocket a little bit
tcp read stream: handle stream closing
tcp tests: use blocking_read where its expecting to wait for input
move common test body into wasi-sockets-tests/src/lib.rs
ensure parent socket outlives pollable
input and output streams can be children now
tcp's streams are the sockets children
tcp.wit: document child relationships
tcp tests: fix to drop socket after its child streams
review feedback: propogate worker task panic
style
error source fix
tcp: use preview2::spawn, and propogate worker panics
join handle await always propogates panic
background task handles ewouldblock as well
document choice of constant
* sync wit notes into wasi-http
* improve wit docs for output-stream
* doc: document `HostOutputStream` (#6980)
* doc: document `HostOutputStream`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Pat Hickey <pat@moreproductive.org>
* fix(wasi): fail when `MemoryOutputStream` buffer is full
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Pat Hickey <pat@moreproductive.org>
* rustfmt
prtest:full
* windows and doc fixes
* cli test wasi-http: use blocking-write-and-flush
* Disable some tests, and adjust timeouts when running under qemu
* Try to reproduce the riscv64 failures
* Update riscv to LLVM 17 with beta rust
* Revert "Try to reproduce the riscv64 failures"
This reverts commit 8ac678171f.
* Pin the beta version for riscv64
* Fix a warning on nightly
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com>
Co-authored-by: Trevor Elliott <telliott@fastly.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
Running cargo license on the c-api crate reports that this crate is
unlicensed.
We use cargo-license to automate our license tracking for this library
in our C++ application and it'd be nice to just have a license in here.
I used the standard license that wasmtime uses, but happy to use
another.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* x64: Add support for sarx, shlx, and shrx
These instructions are in the BMI2 instruction set and unconditionally
used by LLVM for shifts which don't have an immediate. They're
equivalent to the sar, shl, and shr instructions except they use
3-operand form to lessen register allocation pressure.
Currently the integration here doesn't add new lowering but instead
takes an AVX-like approach by updating the `x64_sar` and related helpers
to use `sarx` instead if it fits. This means that the
shift-a-value-stored-in-memory functionality of `sarx` and friends isn't
exposed, so that's left for a future PR.
* x64: Add support for BMI2 `rorx` instruction
This is similar to `rol` and `ror` but requires an immediate argument
and additionally has no constraints on registers.
* x64: Add support for BMI2 `bzhi` instruction
This commit adds support for the `bzhi` instruction which is part of
BMI2. This instruction is used to zero out the upper bits of a register
indexed by a register operand. Emission of this instruction is
pattern-matched on CLIF which looks like this pattern. Equivalent code
fed to LLVM will additionally generate the `bzhi` instruction.
Relative to the alternative lowerings x64 provides this gives a little
bit more register freedom and additionally cuts down on a few
instructions. Note that the raw functionality of `bzhi` can't be exposed
though because the semantics of when the index is out-of-bounds doesn't
match easily to a CLIF instruction, so usage of `bzhi` is always
preceded by an `and` instruction. This matches LLVM as well, but LLVM
probably has fancy logic where if it can prove the range of values of
the index it probably elides the `and`.
* Pattern match more `x - 1` patterns
Looks like LLVM generates this as `x + (-1)` which is equivalent to `x - 1`
so create a custom partial constructor to pattern match the
possibilities of a decremented value.
* Add tests for BMI{1,2} coming from wasm
These are intended to serve as integration tests to ensure that even
coming from wasm these instructions are all emitted.
This change is a small refactoring to some of the MacroAssembler functions to
use `Reg` instead of `RegImm` where appropriate (e.g. when the operand is a
destination).
@elliottt pointed this out while working on https://github.com/bytecodealliance/wasmtime/pull/6982
This change also changes the signature of `float_abs` and `float_neg`, which can
be simplified to take a single register.
* riscv64: Add compressed extension instructions
The C extension has been split a little bit since its introduction
let's support the finer grained instructions.
This also disables compressed instruction support by default.
* ci: Enable zcb extension on RISC-V QEMU
* riscv64: Enable RVC mode in capstone
Conditionally enable compressed instruction disassembly.
* riscv64: Prepare to emit compressed instructions
This commit reorganizes our emit function to first
try a special case for compressed instruction, before
falling back to uncompressed instructions.
Currently the compressed case does nothing.
* riscv64: Move emit register allocation to separate function
We can only emit compressed instructions if they have a
specific physical register. For example `c.mv` does not support
using the `x0` register.
Thus, move the allocation function that converts from
virtual registers to physical registers into a separate step
before trying to emit the instruction.
This allows us to know the real register when emitting
compressed instructions.
* riscv64: Emit BrTable as uncompressed
`br_table` computes physical offsets from a certain instruction.
Thus we need to force these instructions to be uncompressed
in order to not jump into the wrong target.
* riscv64: Mark DWARF CIE code alignment as 2 bytes
* riscv64: Make minimum function alignment 2 bytes
* riscv64: Emit `c.add`
* riscv64: Add `c.mv`
* riscv64: Add c runtests
* Revert "ci: Enable zcb extension on RISC-V QEMU"
This reverts commit 212dec48d4ef0ab2d92ad55e3a649b914ca0fb39.
It looks like the version of QEMU that CI uses does not yet
support Zcb.
* Redesign Wasmtime's CLI
This commit follows through on discussion from #6741 to redesign the
flags that the `wasmtime` binary accepts on the CLI. Almost all flags
have been renamed/moved and will require callers to update. The main
motivation here is to cut down on the forest of options in `wasmtime -h`
which are difficult to mentally group together and understand.
The main change implemented here is to move options behind "option
groups" which are intended to be abbreviated with a single letter:
* `-O foo` - an optimization or performance-tuning related option
* `-C foo` - a codegen option affecting the compilation process.
* `-D foo` - a debug-related option
* `-W foo` - a wasm-related option, for example changing wasm semantics
* `-S foo` - a WASI-related option, configuring various proposals for example
Each option group can be explored by passing `help`, for example `-O
help`. This will print all options within the group along with their
help message. Additionally `-O help-long` can be passed to print the
full comment for each option if desired.
Option groups can be specified multiple times on the command line, for
example `-Wrelaxed-simd -Wthreads`. They can also be combined together
with commas as `-Wrelaxed-simd,threads`. Configuration works as a "last
option wins" so `-Ccache,cache=n` would end up with a compilation
cache disabled.
Boolean options can be specified as `-C foo` to enable `foo`, or they
can be specified with `-Cfoo=$val` with any of `y`, `n`, `yes`, `no`,
`true`, or `false`. All other options require a `=foo` value to be
passed and the parsing depends on the type.
This commit additionally applies a few small refactorings to the CLI as
well. For example the help text no longer prints information about wasm
features after printing the option help. This is still available via
`-Whelp` as all wasm features have moved from `--wasm-features` to `-W`.
Additionally flags are no longer conditionally compiled in, but instead
all flags are always supported. A runtime error is returned if support
for a flag is not compiled in. Additionally the "experimental" name of
WASI proposals has been dropped in favor of just the name of the
proposal, for example `--wasi nn` instead of `--wasi-modules
experimental-wasi-nn`. This is intended to mirror how wasm proposals
don't have "experimental" in the name and an opt-in is required
regardless.
A full listing of flags and how they have changed is:
| old cli flag | new cli flag |
|-----------------------------------------------|-------------------------------------------------|
| `-O, --optimize` | removed |
| `--opt-level <LEVEL>` | `-O opt-level=N` |
| `--dynamic-memory-guard-size <SIZE>` | `-O dynamic-memory-guard-size=...` |
| `--static-memory-forced` | `-O static-memory-forced` |
| `--static-memory-guard-size <SIZE>` | `-O static-memory-guard-size=N` |
| `--static-memory-maximum-size <MAXIMUM>` | `-O static-memory-maximum-size=N` |
| `--dynamic-memory-reserved-for-growth <SIZE>` | `-O dynamic-memory-reserved-for-growth=...` |
| `--pooling-allocator` | `-O pooling-allocator` |
| `--disable-memory-init-cow` | `-O memory-init-cow=no` |
| `--compiler <COMPILER>` | `-C compiler=..` |
| `--enable-cranelift-debug-verifier` | `-C cranelift-debug-verifier` |
| `--cranelift-enable <SETTING>` | `-C cranelift-NAME` |
| `--cranelift-set <NAME=VALUE>` | `-C cranelift-NAME=VALUE` |
| `--config <CONFIG_PATH>` | `-C cache-config=..` |
| `--disable-cache` | `-C cache=no` |
| `--disable-parallel-compilation` | `-C parallel-compilation=no` |
| `-g` | `-D debug-info` |
| `--disable-address-map` | `-D address-map=no` |
| `--disable-logging` | `-D logging=no` |
| `--log-to-files` | `-D log-to-files` |
| `--coredump-on-trap <PATH>` | `-D coredump=..` |
| `--wasm-features all` | `-W all-proposals` |
| `--wasm-features -all` | `-W all-proposals=n` |
| `--wasm-features bulk-memory` | `-W bulk-memory` |
| `--wasm-features multi-memory` | `-W multi-memory` |
| `--wasm-features multi-value` | `-W multi-value` |
| `--wasm-features reference-types` | `-W reference-types` |
| `--wasm-features simd` | `-W simd` |
| `--wasm-features tail-call` | `-W tail-call` |
| `--wasm-features threads` | `-W threads` |
| `--wasm-features memory64` | `-W memory64` |
| `--wasm-features copmonent-model` | `-W component-model` |
| `--wasm-features function-references` | `-W function-references` |
| `--relaxed-simd-deterministic` | `-W relaxed-simd-deterministic` |
| `--enable-cranelift-nan-canonicalization` | `-W nan-canonicalization` |
| `--fuel <N>` | `-W fuel=N` |
| `--epoch-interruption` | `-W epoch-interruption` |
| `--allow-unknown-exports` | `-W unknown-exports-allow` |
| `--trap-unknown-imports` | `-W unknown-imports-trap` |
| `--default-values-unknown-imports` | `-W unknown-imports-default` |
| `--max-instances <MAX_INSTANCES>` | `-W max-instances=N` |
| `--max-memories <MAX_MEMORIES>` | `-W max-memories=N` |
| `--max-memory-size <BYTES>` | `-W max-memory-size=N` |
| `--max-table-elements <MAX_TABLE_ELEMENTS>` | `-W max-table-elements=N` |
| `--max-tables <MAX_TABLES>` | `-W max-tables=N` |
| `--max-wasm-stack <MAX_WASM_STACK>` | `-W max-wasm-stack=N` |
| `--trap-on-grow-failure` | `-W trap-on-grow-failure` |
| `--wasm-timeout <TIME>` | `-W timeout=N` |
| `--wmemcheck` | `-W wmemcheck` |
| `--wasi-modules default` | removed |
| `--wasi-modules -default` | removed |
| `--wasi-modules wasi-common` | `-S common` |
| `--wasi-modules -wasi-common` | `-S common=n` |
| `--wasi-modules experimental-wasi-nn` | `-S nn` |
| `--wasi-modules experimental-wasi-threads` | `-S threads` |
| `--wasi-modules experimental-wasi-http` | `-S http` |
| `--listenfd` | `-S listenfd` |
| `--tcplisten <SOCKET ADDRESS>` | `-S tcplisten=...` |
| `--wasi-nn-graph <FORMAT::HOST>` | `-S nn-graph=FORMAT::HOST` |
| `--preview2` | `-S preview2` |
| `--dir <DIRECTORY>` | `--dir ...` |
| `--mapdir <GUEST_DIR::HOST_DIR>` | `--dir a::b` |
* Be more descriptive with help text
* Document `=val` is optional for `-Ccranelift-xxx`
* Fix compile after rebase
* Fix rebase of `--inherit-network`
* Fix wasi-http test
* Fix compile without pooling allocator support
* Update some flags in docs
* Fix bench-api build
* Update flags for gdb/lldb tests
* Fixup optimization flags
prtest:full
* [wasmtime-wasi] fix logic error in `monotonic-clock/subscribe`
When calculating the number of nanoseconds to wait, we should subtract the
current time from the deadline, not vice-versa. This was causing guests to
sleep indefinitely due to integer underflow.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add `sleep` test to `wasi-tests`
Note that this is annotated `should_panic` when testing preview1 scenarios,
since those won't have preview2 imports.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Remove tutorial/wasm-writing documentation
This commit removes the tutorial and "Writing WebAssembly" documentation
sections from Wasmtime's documentation. These sections are quite dated
at this point (they still recommend `cargo wasi`!) and haven't been
updated much since their inception, especially in the arena of
components. Today it seems best to leave this sort of documentation to
[other resources] which are more tailored towards documentation of
writing wasm.
[other resources]: https://component-model.bytecodealliance.org/
* Remove markdown example from docs
Like the previous commit this is quite dated and recommends
effectively-deprecated tooling and doesn't take into account components.
* Update our intro docs a bit
* Link security blog post from docs
* Fold docs of wasm proposals into tier docs
This was already a bit duplicated so consolidate into one location.
Additionally add some proposals that weren't previously documented and
move some around based on their implementation status.
* Document unsupported features
In an effort to head off questions about platform support I figure it
might be a good idea to start documenting what's not supported at this
time. This is intended to mirror the current state, not future, of
Wasmtime. In other words this should answer the question of "Does
Wasmtime support X?" as opposed to "Does Wasmtime want to support X?"
since we want to eventually support all of these features in the limit.
* Fold WASI docs into tier docs
Similar to the previous commit but for WASI proposals.