* Attempt to automatically configure release notes
This commit is an attempt to tackle #7068 by configuring the release
notes in Github Releases with the handwritten release notes from
`RELEASES.md`. The basic idea here is to split the markdown file on
`-----` delimiters and then find the one which matches the version being
released. Once one is found the `body` field of the API call to create
the release is configured.
* Update .github/actions/github-release/main.js
---------
Co-authored-by: Andrew Brown <andrew.brown@intel.com>
In Wasmtime 13 and prior the `--dir` argument was unconditionally used
to open a host dir as the same name and in the guest. In Wasmtime 14+
though this argument is being repurposed with an optional trailing
`::GUEST` to configure the guest directory. This means that
`--dir`-with-remapping behavior is actually unusable without the
environment variable configuration from #7385 due to it parsing
differently in the old and the new.
This commit updates the situation by adding `::`-parsing to the old CLI
meaning that both the old and the new parse this the same way. This will
break any scripts that open host directories with two colons in their
path, but that seems niche enough we can handle that later.
This commit updates the parsing of the old CLI to understand new
subcommands to ensure that `wasmtime serve foo.wasm` isn't mistakenly
interpreted in the old CLI as executing the module `serve` with the
argument `foo.wasm`.
Closes#7396
* Add compatibility shims for Wasmtime 13 CLI
This commit introduces a compatibility shim for the Wasmtime 13 CLI and
prior. The goal of this commit is to address concerns raised in #7336
and other locations as well. While the new CLI cannot be un-shipped at
this point this PR attempts to ameliorate the situation somewhat through
a few avenues:
* A complete copy of the old CLI parser is now included in `wasmtime` by
default.
* The `WASMTIME_NEW_CLI=0` environment variable can force usage of the
old CLI parser for the `run` and `compile` commands.
* The `WASMTIME_NEW_CLI=1` environment variable can force usage of the
new CLI parser.
* Otherwise both the old and the new CLI parser are executed. Depending
on the result one is selected to be executed, possibly with a warning
printed.
* If both CLI parsers succeed but produce the same result, then no
warning is emitted and execution continues as usual.
* If both CLI parsers succeed but produce different results then a
warning is emitted indicating this. The warning points to #7384 which
has further examples of how to squash the warning. The warning also
mentions the above env var to turn the warning off. In this situation
the old semantics are used at this time instead of the new semantics.
It's intended that eventually this will change in the future.
* If the new CLI succeeds and the old CLI fails then the new semantics
are executed without warning.
* If the old CLI succeeds and the new CLI fails then a warning is issued
and the old semantics are used.
* If both the old and the new CLI fail to parse then the error message
for the new CLI is emitted.
Note that this doesn't add up to a perfect transition. The hope is that
most of the major cases of change at the very least have something
printed. My plan is to land this on `main` and then backport it to the
14.0.0 branch as a 14.0.3 release.
* Wordsmith messages
* Update messages
* More wording updates
* Fix grammar
* More updates
This enables the `serve` subcommand by default on the CLI instead of
having it behind an off-by-default feature. In general our default build
is the "most featureful" while we still retain the ability to turn off
everything if desired for custom builds. This additionally matches the
current `main` branch where through other refactorings the `serve`
command is now enabled by default.
* Release Wasmtime 14.0.2
[automatically-tag-and-release-this-commit]
* Add release notes for 14.0.1 (#7346)
* Add release notes for 14.0.1
Closes#7342
* Clarify this was just a cranelift point release
* Add release notes for 14.0.2
* Update release date
* More notes
---------
Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This is required to compile for a target which doesn't have a cranelift
backend. Before this change using any of the cranelift crates that
depend on cranelift-codegen would forcefully enable all default features
and thus host-arch. With this change only the std and unwind features
are still forcefully enabled as cranelift-codegen doesn't compile with
either disabled.
This follows up #6807 and removes the last remaining reference to
the removed `posix-signals-on-macos` feature flag.
Note that `lib.rs` now imports `mod unix` on MacOS. This change
is similar to the change in `traphandlers.rs` in #6807. It is
needed for hosts that use signals instead of Mach ports on MacOs.
This commit changes the `--dir` argument on the `wasmtime` CLI to be
`HOST::GUEST` rather than `GUEST::HOST`. This matches Docker for example
and is a little more consistent with only `--dir path` where the first
argument is always treated as a host directory.
In terms of breaking-ness the movement from `--mapdir` to `--dir` hasn't
been released with Wasmtime 14 yet so my hope is that this can land on
both `main` and Wasmtime 14.0.0 before it's released to avoid any
breakage other than existing scripts migrating from `--mapdir` to
`--dir`.
* Put versions in all WASI WIT files
This commit starts exercising the versioning feature of WIT by ensuring
that all WASI descriptions have a version associated with them. The
version chosen is 0.2.0 which reflects the upcoming "preview 2" release
where in theory 0.1.0 was claimed by preview1. This is intended to stay
as 0.2.0 for now and we'll determine how best to update these numbers in
the future once preview2 is released.
Closes#7171
* Allow omitting versions in `with` keys
As a convenience for now this enables omitting the version of an
interface from a `with` key. This has a risk of not working well if two
packages are present and one has a version and one doesn't, but that's
left as a PR to fix in the future as the benefit of avoiding repetition
seems good for now.
* Allow omitting versions in trappable_error_types
* Use 0.2.0-rc-2023-10-18 as a version number
* More test fixes
* Fix another test
This is a backport of https://github.com/bytecodealliance/wasmtime/pull/7288,
minus the tests. The test suite has been refactored since the release-14.0.0
branch was created, so backporting the tests would be complicated and not worth
the effort.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
To prepare this commit I've run `WIT_REQUIRE_SEMICOLONS=1 ./ci/run-tests.sh`
locally which configures `wit-parser` to generate an error for missing
semicolons in WIT files. This led me to add quite a few semicolons in
quite a few places in what is going to be the first of a few batches of
semicolons.
CI checks for this cannot be added just yet because the wasi-nn spec is
a submodule which needs to be updated with semicolons before this
repository can require semicolons. Nevertheless that doesn't stop us
from using semicolons in the meantime (yay gradual rollout of changes!)
so I figure this would be good to get in sooner rather than later.
* wasi-sockets: Simplify & clarify TCP errors (#7120)
* Use Rustix::Errno to unify error code mapping.
* Clarify Connect failure state
* Allow accept() to return transient errors.
The original provision was added to align with preview3 streams that may only fail once. However, after discussing with Dan Gohman, we came to the conclusion that a stream of result<> could do the trick fine too.
Fixes: https://github.com/WebAssembly/wasi-sockets/issues/22
* Fold `ephemeral-ports-exhausted` into `address-in-use`
There is no cross-platform way to know the distinction between them
* Clarify `local-address` behavior on unbound socket
* Remove `concurrency-conflict` clutter,
and just document it to be always possible.
* Simplify state errors.
They were unnecessarily detailed and mostly have no standardized equivalent in POSIX, so wasi-libc will probably just map them all back into a single EOPNOTSUPP or EINVAL or ...
EISCONN/ENOTCONN can be derived in wasi-libc based on context and/or by checking `remote-address`. For example, `shutdown` can only be called on connected sockets, so if it returns `invalid-state` it can be unambiguously mapped to ENOTCONN.
* Document that connect may return ECONNABORTED
* Remove create-tcp/udp-socket not supported errors.
These stem from back when the entire wasi-sockets proposal was one big single thing. In this day and age, when an implementation doesn't want to support TCP and/or UDP, it can simply _not_ implement that interface, rather than returning an error at runtime.
* Simplify "not supported" and "invalid argument" error cases.
There is a myriad of reasons why an argument might be invalid or an operation might be not supported. But there is few cross platform consistency in which of those error cases result in which error codes.
The error codes that have been removed were fairly specific, but:
- Were still missing error cases. So additional error codes would have needed to be created.
- Implementations would have to bend over backwards to make it work cross platform, especially beyond just Win/Mac/Linux.
- Didn't all have an equivalent in POSIX, so they would map back into a generic EINVAL anyways.
* Move example_body out of lib.rs into its own test-case make room for other tests.
* Refactor TCP integration tests:
- Ad-hoc skeleton implementation of resources.
- Add blocking wrappers around async operations.
* Fix get/set_unicast_hop_limit on Linux
* Test TCP socket states
* Keep track of address family ourselves.
Because I need the family for input validation.
And the resulting code is more straightforward.
* Add more tests and make it work on Linux
* Fix Windows
* Simplify integration tests.
All platforms supported by wasmtime also support dualstack sockets.
* Test ipv6_only inheritence
* Test that socket options keep being respected, even if listen() has already been called
* cargo fmt
* Duplicate .wit changes to wasi-http
* prtest:full
* Fix BSD behavior of SO_SNDBUF/SO_RCVBUF
* fmt
* Fix type error
* Got lost during merge
* Implement listen backlog tests
* Manually inherit buffer size from listener on MacOS.
I suspect that these changes apply to any BSD platform, but I can't test that.
* Keep track of IPV6_V6ONLY ourselves.
- This provides cross-platform behaviour for `ipv6-only`
- This eliminates the syscall in `validate_address_family`
* Reject IPv4-compatible IPv6 addresses.
* Remove intermediate SystemError trait
* Fix ambiguous .into()'s
* Fix IPV6_UNICAST_HOPS inheritance on MacOS
* feat(wasi-sockets): implement UDP (#7148)
* feat(wasi-sockets): implement UDP
This is based on TCP implementation
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(wasi-sockets): simplify UDP implementation
This introduces quite a few changes compared to TCP, which should most probably be integrated there as well
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat(wasi-sockets): store UDP connect address in state
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* fix(wasi-sockets): avoid `shutdown` on `drop`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* Remove explicit bind
* Simplify start_connect&finish_connect.
On UDP sockets, `connect` never blocks.
* Move UDP test to single file, similar to `tcp_sample_application.rs`
* Update UDP tests
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Dave Bakker <github@davebakker.io>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Dave Bakker <github@davebakker.io>
* Support multiple versions in `bindgen!` (#7172)
This commit fixes a bug in the `bindgen!` macro where when faced with
multiple packages that differ only in version number invalid bindings
were generated. The fix here is to add version number information to
package module names if necessary in situations such as this. This
required some refactoring internally to have a single source of truth
for what the name of a module should be and avoid having it implicitly
calculated in two locations.
* Ensure exports are properly namespaced (#7196)
Continuation of #7172 where imports and export _definitions_ are
properly namespaced by version by the usage of exports was not.
---------
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
* chore: convert wasi http cli test to component
* fix(wasmtime-cli): wrong linker in wasi http
* fix(wasmtime-cli): fix multiple functions added to linker
We will allow shadowing in linker when using
WASI HTTP in order to prevent the following
error:
> import of `wasi:clocks/wall-clock` defined
twice
* chore: update to latest io streams wit definition
* chore: rename main function of core module
prtest:full
* fix(wasmtime-cli): add only http functions to linker
* chore: add test building http request and response
* chore: disable temporarily wasi http test
Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
This allows embedders to implement those traits themselves rather than be
restricted to using the built-in implementations.
Fixes https://github.com/bytecodealliance/wasmtime/issues/7149
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Change `bindgen!`'s trappable error to take an input type
This commit removes the generated type for `trappable_error_type` from
the `bindgen!` macro to allow users to provide a type instead. This
works similarly as before with new conversion functions generated in
traits which are used to convert the custom error into the ABI
representation of what a WIT world expects.
There are a few motivations for this commit:
* This enables reducing the number of errors in play between async/sync
bindings by using the same error type there.
* This avoids an auto-generated type which is more difficult to inspect
than one that's written down already and the source can more easily be
inspected.
* This enables richer conversions using `self` (e.g. `self.table_mut()`)
between error types rather than purely relying on `Into`. This is
important for #7017 where an error is going to be inserted into the
table as it gets converted.
* Fix tests
* Update WASI to use new trappable errors
This commit deals with the fallout of the previous commit for the WASI
preview2 implementation. The main changes here are:
* Bindgen-generated `Error` types no longer exist. These are replaced
with `TrappableError<T>` where type aliases are used such as
```rust
type FsError = TrappableError<wasi::filesystem::types::ErrorCode>;
```
* Type synonyms such as `FsResult<T>` are now added for more
conveniently writing down fallible signatures.
* Some various error conversions are updated from converting to the old
`Error` type to now instead directly into corresponding `ErrorCode` types.
* A number of cases where unknown errors were turned into traps now
return bland error codes and log the error instead since these aren't
fatal events.
* The `StreamError` type does not use `TrappableError` since it has
other variants that it's concerned with such as a
`LastOperationFailed` variant which has an `anyhow::Error` payload.
* Some minor preview1 issues were fixed such as trapping errors being
turned into normal I/O errors by accident.
* Add an `error` resource to WASI streams
This commit adds a new `error` resource to the `wasi:io/streams`
interface. This `error` resource is returned as part of
`last-operation-failed` and serves as a means to discover through other
interfaces more granular type information than a generic string. This
error type has a new function in the `filesystem` interface, for
example, which enables getting filesystem-related error codes from I/O
performed on filesystem-originating streams. This is plumbed through to
the adapter as well to return more than `ERRNO_IO` from failed
read/write operations now too.
This is not super fancy just yet but is intended to be a vector through
which future additions can be done. The main thing this enables is to
avoid dropping errors on the floor in the host and enabling the guest to
discover further information about I/O errors on streams.
Closes#7017
* Update crates/wasi-http/wit/deps/io/streams.wit
* Update wasi-http wit too
* Remove unnecessary clone
---------
Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>
* riscv64: Add codegen tests for min/max
* riscv64: Remove unused `Type` payload from `Select`
* riscv64: Add codegen test for brif
* riscv64: Consolidate conditional moves into one instruction
This commit removes the `IntSelect` and `SelectReg` pseudo-instructions
from the riscv64 backend and consolidates them into the `Select`
instruction. Additionally the `Select` instruction is updated to subsume
the functionality of these two previous instructions. Namely `Select`
now operates with `ValueRegs` to handle i128 and additionally takes an
`IntegerCompare` as the condition for the conditional branch to use.
This commit touches a fair bit of the backend since conditional
selection of registers was used in quite a few places. The previous
`gen_select_*` functions are replaced with new typed equivalents of
`gen_select_{xreg,vreg,freg,regs}`. Furthermore new `cmp_*` helpers were
added to create `IntegerCompare` instructions which sort-of match
conditional branch instructions, or at least the pnemonics they use.
Finally since this affected the `select` CLIF instruction itself I went
ahead and did some refactoring there too. The `select` instruction
creates an `IntegerCompare` from its argument to use to generate the
appropriate register selection instruction. This is basically the same
thing that `brif` does and now both go through a new helper,
`lower_int_compare`, which takes a `Value` and produces an
`IntegerCompare` representing if that value is either true or false.
This enables folding an `icmp` or an `fcmp`, for example, directly into
a branching instruction.
* Fix a test
* Favor sign-extension in equality comparisons
* Refactor option handling in the `run` and `serve` commands
* Use a real thread to manage epoch increments
* Move module/component loading into src/common.rs
* Require wasi-http and component-model to not be disabled in serve
This allows embedders to implement those traits themselves rather than be
restricted to using the built-in implementations.
Fixes https://github.com/bytecodealliance/wasmtime/issues/7149
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Refactor HTTP tests to be less flaky and more robust
This commit refactors the wasi-http tests we have in this repository
with a few changes:
* Each test now uses a dedicated port for the test. The port 0 is bound
and whatever the OS gives is used for the duration of the test. This
prevents tests from possibly interfering with each other.
* Server spawning is abstracted behind a single `Server` type now which
internally has http1/2 constructors.
* Timeouts for server shutdown are removed since they were failing in CI
and are likely best handled for each test individually if necessary.
As a minor cleanup the `tokio` usage in guest programs was removed as it
was boilerplate in this case. This shouldn't affect the runtimes of
tests, however.
* Remove unused import
* Don't panic from worker thread
* Improve failure error message
prtest:full
* Fix some windows-specific issues
* Fix async tests
* Relax test assertion string
* Implement the `wasi:sockets/ip-name-lookup` interface
This commit is an initial implementation of the new `ip-name-lookup`
interface from the `wasi-sockets` proposal. The intention is to get a
sketch of what an implementation would look like for the preview2
release later this year. Notable features of this implementation are:
* Name lookups are disabled by default and must be explicitly enabled in
`WasiCtx`. This seems like a reasonable default for now while the full
set of configuration around this is settled.
* I've added new "typed" methods to `preview2::Table` to avoid the need
for extra helpers when using resources.
* A new `-Sallow-ip-name-lookup` option is added to control this on the
CLI.
* Implementation-wise this uses the blocking resolution in the Rust
standard library, built on `getaddrinfo`. This doesn't invoke
`getaddrinfo` "raw", however, so information such as error details can
be lost in translation. This will probably need to change in the
future.
Closes#7070
* Validate the input domain name.
* Use a crate-level helper for `spawn_blocking`
---------
Co-authored-by: Dave Bakker <github@davebakker.io>
* riscv64: Add codegen tests for fcmp and fcmp branches
* riscv64: Refactor and simplify some branches/fcmp
This commit is aimed at simplifying the layers necessary to generate a
branch for a `brif` statement. Previously this involved a
`lower_cond_br` helper which bottomed out in emitting a `CondBr`
instruction. The intention here was to cut all that out and emit a
`CondBr` directly.
Along the way I've additionally taken the liberty of simplifying `fcmp`
as well. This moves the "prefer ordered compares" logic into `emit_fcmp`
so it can benefit the `fcmp` instruction as well. This additionally
trimmed some abstractions around branches which shouldn't be necessary
any longer.
This switches the `extractor` to a `pure partial` constructor to be used
in `if-let` instead of the extraction position, which while not quite as
ergonomic does enable matching more constant values in more locations.
* Fix race condition in `AsyncWriteStream`
This commit fixes a synchronization issue with `AsyncWriteStream` where
the writer task would get wedged and not make any further progress. The
underlying reason is that `notify_waiters` was used which did not buffer
its notification, meaning that if a waiter wasn't actually waiting then
it would miss the notification and block forever on the next call to
`notified`. By using `notify_one` instead this will buffer up a single
notification for the other end for when it gets to waiting for work.
Additionally this removes creation of the `Notified` future
ahead-of-time as that's no longer necessary.
* Fix http bodies too
Found in CI for #7099 this commit updates the durations used in the
`resolves_immediately` and `never_resolves` tests. For immediately
resolving it should be ok to wait for a generous amount of time since
the timeout is only a protection against tests hanging. For
`never_resolves` it should be ok to wait a short amount of time and any
failure there will show up as a spurious failure.
* Allow backlog size to be set before initial listen
* Move set_listen_backlog_size into example_body
* Format code
* Let cap_net_ext handle the default value.
* retrigger checks
* Got lost while pulling in changes from main.
* Handle `lower_branch` consistently amongst backends
This commit is a refactoring to consistently implement `lower_branch`
among Cranelift's backends. Previously each backend had its own means of
extracting labels and shuffling along information, and now there's
prelude methods for all backends to access and use. This changes a few
display impls but the actual meat of what's emitted shouldn't change
amongst the backends.
* Fix compile
* c-api: Add a feature for async
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Add support for async config
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Add support for calling async functions
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Add ability to yield execution of Wasm in a store
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Introduce wasmtime_linker_instantiate_async
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Support defining async host functions
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* gitignore: ignore cmake cache for examples
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* examples: Add example of async API in C
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Consolidate async functionality into a single place
Put all the async stuff in it's own header and own rust source file
Also remove the wasmtime_async_continuation_new function, users can just
allocate it directly.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Make async function safe
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Remove wasmtime_call_future_get_results
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Simplify CHostCallFuture
Move the result translation and hostcall_val_storage usage into an async
function
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Simplify C continuation implementation
Remove the caller, which means that we don't need another struct for the
future implementation.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Improve async.h documentation
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Cleanup from previous changes
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* examples: Fix example
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Simplify continuation callback
This gives more duality with calling an async function and also means
that the implementation can pretty much mirror the sync version.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Fix async.h documentation
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Fix documentation for async.h
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: Review feedback
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* examples: Downgrade async.cpp example to C++11
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* c-api: initialize continuation with a panic callback
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* prtest:full
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
---------
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* riscv64: Refactor implementation of `{u,s}{div,rem}`
This commit's goal is to remove the usage of `gen_icmp` with
division-related instructions in the riscv64 backend. I've opted for a
slightly more verbose approach than what was present prior to make
sign/zero extensions more precise and additionally enable some
immediate-related optimizations.
Divison/remainder by an immediate will no longer emit checks to see if a
trap needs to be emitted. Instead only the raw `div`/`rem` instructions
are emitted. Additionally a few minor sign extensions are now avoided
such as the dividend in 32-bit remainders/division because only the
low 32-bits are inspected.
Finally, while I was here, I went ahead an added `has_m` guards to all
these lowering rules. The M extension is always required with riscv64
right now and won't work if it's turned off, but I figure it's not too
bad to add in terms of completeness for now.
As to the meat of the commit, the check for trapping value as part of
division now happens without `gen_icmp` but instead `gen_trapif` which
enables avoiding materializing the comparison's value into a register.
* Fix tests
This commit refactors how the `Pollable` resource is created in WASI.
Previously this was created manually via two variants of a `Pollable`
enum but this was somewhat error prone for a few reasons:
* The more common representation, `TableEntry`, had boilerplate
associated with it that had dynamic downcasts and such. This is now
all hidden behind a more typed API.
* Callers had to remember to use `push_child_resource` which is easy to
forget.
* The previous signature of the readiness check returned a `Result<()>`
which made it accidentally easy for errors to be propagated into traps
rather than being returned as a "last operation failed" error.
This commit replaces the previous API with a single `subscribe` function
which takes a `Resource<T>` and returns a `Resource<Pollable>`. The `T`
type must implement a new trait, `Subscribe`, which indicates the
asynchronous readiness check. This readiness check additionally returns
`()` so it's no longer possible to accidentally return errors (or trap).
This namely required refactoring the `HostOutputStream` trait and
implementations. The trait itself now has a `check_write` method
corresponding to to the same WASI function. The old `write_ready`
function is now a convenience helper combo between `ready` and
`check_write`. Concrete implementations are refactored to store errors
discovered during `ready` to get communicated through `check-write`
later on.
Currently any 32-bit constant can be materialized without a load from a
constant pool on RISCV-64 but once constants start getting larger than
this they're always loaded from the constant pool. This commit adds
another special case for loading constants which appears to match what
LLVM does which is to consider materializing a smaller constant and than
shifting it left.
This is done by chopping off all trailing zeros from an immediate and
then testing if the immediate can be materialized as a 32-bit constant.
This means that the current constant loading sequence can optionally be
followed by a trailing `slli` instruction to shift the zeros back into
the constant. This namely means that loading `i64::MIN` (1 << 63) no
longer falls back to the constant pool.
This commit removes the usage of `gen_icmp` in `uadd_overflow_trap`.
The comparison previously done with an explicit comparison is now
bundled directly into the conditional branch to go to the trap itself.