Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-merge the upstream/main #61

Merged
merged 222 commits into from
Oct 31, 2023
Merged

Re-merge the upstream/main #61

merged 222 commits into from
Oct 31, 2023

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Oct 31, 2023

Lets see if I can manage to integrate this in a way that does not lose the merge commit and is maintainable in the long run?

rylev and others added 30 commits September 21, 2023 17:55
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>
* 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 fa0750e.

* 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 (bytecodealliance#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>
* 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
…ance#6935)

* 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>
* Remove manual impl of Error/Display

These conflict with auto-generated ones.

* Fix tests
* riscv64: Delete `int_load_op` helper

* riscv64: Delete `default_memflags`

* riscv64: Rename `gen_amode`

* riscv64: Better matching for amode

* riscv64: Delete `emit_load` helper

* riscv64: Rename some load variables

* riscv64: Merge `iadd` into amode computations
…nce#7080)

* riscv64: Add `c.li` and `c.lui`

* riscv64: Add CB type instructions

`c.srli` / `c.srai` / `c.andi`

* riscv64: Add `sp` relative load instructions

* riscv64: Return Option from try_emit_compressed

* riscv64: Implement stack based stores

* riscv64: Add compressed stores

* riscv64: Add compressed loads
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.
* Optimize wasm calls ever-so-slightly

* Fix riscv64

* Remove stray comment

* Shuffle around where `unsafe` lies
…7086)

* Wasmtime: Move `Global` and `Table` to `externals` submodules

Just mechanical code motion, not functional changes.

* Wasmtime: Add `hash_key` methods for `Func` and `Table`

* Rename `wasmtime::Func::caller_checked_func_ref` to `wasmtime::Func::vm_func_ref`

We removed the "caller checked" part of the `VMFuncRef` type's name a while ago,
so update this method to be in line with that.

No functional changes, just mechanical renaming.

* cargo fmt

* Fix doc link
…ance#7089)

These registers require an additional byte to reference when encoded in certain
AVX instruction formats (and maybe other situations as well?) so prefer
xmm{0..7} when they are available and only fall back to xmm{8..15} when register
pressure is higher.
…7087)

* Add docs for debugging with core dumps

* Fix reference to old style CLI flag

* Add `no_run` to example that is only there to trap
…ytecodealliance#7093)

For `XmmRmiRVex`-format instructions, when the opcode is commutative, the first
operand is one of xmm{0..7}, and the second operand is one of xmm{8..15}, then
we can swap the operands to save a byte on instruction encoding.
This update gets rid of a panic that occurs when using `--profile=vtune`
from the command line.
* Bump wasm-tools crates

Two major changes/reasons for this update:

* Primarily pulling in support for semicolons-in-WIT files. Semicolons are
  not currently required, though, so I'll follow-up later with actual
  semicolons.

* The syntax for parsing `(if ...)` was fixed in `wast`. Previously it
  did not require `(then ...)` but this is required by the spec. New
  spec tests require this as well. This breaks existing text format
  tests which don't use `(then ...)` inside of an `(if ...)`. Most tests
  were updated by hand but `embenchen_*` tests were updated by running
  through the old parser to produce non-s-expression using code.

* Fix an example `*.wat`
* delete preview2::pipe::pipe

this is not used anywhere, not documented, and trivial for the user to
build on their own if they need it. i suspect they probably only want
one end of their pipe wrapped with AsyncReadStream or AsyncWriteStream.

* fix cfg_attr to ignore forking tests on qemu

* delete "async fd stdin" test, which is just the worker thread one anyway
…7072)

* Add memory protection keys (MPK)

In order to use MPK on an x86_64 Linux system, we need access to the
underlying `pkey_*` system calls (`sys`), control of the x86 PKRU
register (`pkru`), and a way of determining if MPK is even supported
(`is_supported`). These various parts are wrapped in a `ProtectionKey`
abstraction along with a `ProtectionMask` that can be used `allow` the
CPU to access protected regions.

* Integrate MPK into the pooling allocator

This change adds "stripes" to the pooling allocator's `MemoryPool`. Now,
when requesting a slot in which to instantiate, the user (i.e.,
`InstanceAllocationRequest`) will be transparently assigned to one of
the stripes, each of which is associated with a protection key. The user
can also request a specific protection key to use, which will override
the original "find me a slot logic".

This has implications for how instances get allocated: once a store is
assigned a protection key, it will only allocate requests with that key,
limiting how many slots it has access to. E.g., if 15 keys are active,
the store can only ever access 1/15th of the slots.

This change also includes a tri-bool configuration field,
`memory_protection_keys`, which is disabled by default for the time
being.

* Address review comments

This is a rollup of 43 commits addressing review comments of various
kinds: bug fixes, refactorings, documentation improvements, etc. It also
ensures that CI runs all checks. A big thanks to @fitzgen and
@alexcrichton for the review!

prtest:full

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>

---------

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
…ance#7098)

* x64: Fix false dependencies in int-to-float conversions

This commit is a result of the investigation on bytecodealliance#7085. The int-to-float
conversion instructions used right now on the x64 backend will
implicitly source the upper bits of the result from a different
register. This implicitly creates a dependency on further consumers
using the conversion result on whatever previously defined the upper
bits, even though they aren't used. This false dependency is the primary
reason for the slowdown witnessed in bytecodealliance#7085.

The fix chosen in this commit is to model the int-to-float instructions
with a new shape of instruction instead of the previous `GprToXmm{,Vex}`. This
previous shape was modeled as single-input and single-output, but this
does not reflect the actual nature of the `cvtsi2s{s,d}` instructions.
Instead these now use `CvtIntToFloat{,Vex}` which have two source
operands and one destination operand, modeling how the upper bits of a
different register are used. In lowerings using this instruction the
upper bits to preserver are always sourced from a zero'd out register to
force breaking dependencies between instructions.

Closes bytecodealliance#7085

* Remove now dead code

* Remove outdated test

Golden test output covers this test case anyway nowadays

* Review comments

* Fix emit tests
* Mark some frequently used methods as `inline`

* Seed the preview2 context with the thread_rng, instead of using a syscall
This has no longer been used since bytecodealliance#7056 and I believe it's just an
accident that it wasn't removed as part of that PR.
* ci: Upgrade QEMU to `8.1.1`

This adds support for RISC-V's Zcb extension that includes some
extra compressed instructions.

It also removes the current cpuinfo patch, that has been released
in 8.1

* wasmtime: Don't assert the exact faulting address for wasm traps
)

* Move the incoming_handler impl into http_impl

* Remove the incoming handler -- we need to use it as a guest export

* Start adding a test-programs test for the server side of wasi-http

* Progress towards running a server test

* Implement incoming-request-method

* Validate outparam value

* Initial incoming handler test

* Implement more of the incoming api

* Finish the incoming api implementations

* Initial cut at `wasmtime serve`

* fix warning

* wasmtime-cli: invoke ServeCommand, and add enough stuff to the linker to run trivial test

* fix warnings

* fix warnings

* argument parsing: allow --addr to specify sockaddr

* rustfmt

* sync wit definitions between wasmtime-wasi and wasmtime-wasi-http

* cargo vet: add an import config and wildcard audit for wasmtime-wmemcheck

* cargo vet: audit signal-hook-registry

* Remove duplicate add_to_linker calls for preview2 interfaces

prtest:full

* Add a method to finish outgoing responses

Co-authored-by: Adam Foltzer <acfoltzer@fastly.com>
Co-authored-by: Pat Hickey <phickey@fastly.com>

* Mark the result of the incoming_{request,response}_consume methods as own

* Explicit versions for http-body and http-body-util

* Explicit `serve` feature for the `wasmtime serve` command

* Move the spawn outside of the future returned by `ProxyHandler::call`

* Review feedback

---------

Co-authored-by: Trevor Elliott <telliott@fastly.com>
Co-authored-by: Adam Foltzer <acfoltzer@fastly.com>
* Remove usage of `is-terminal` and `atty` crates

This functionality is now folded into the standard library itself.

* Fix syntax

* Fix a unix/windows cfg
* winch(x64): Call indirect

This change adds support for the `call_indirect` instruction to Winch.

Libcalls are a pre-requisite for supporting `call_indirect` in order to
lazily initialy funcrefs. This change adds support for libcalls to
Winch by introducing a `BuiltinFunctions` struct similar to Cranelift's
`BuiltinFunctionSignatures` struct.

In general, libcalls are handled like any other function call, with the
only difference that given that not all the information to fulfill the
function call might be known up-front, control is given to the caller
for finalizing the call.

The introduction of function references also involves dealing with
pointer-sized loads and stores, so this change also adds the required
functionality to `FuncEnv` and `MacroAssembler` to be pointer aware,
making it straight forward to derive an `OperandSize` or `WasmType` from
the target's pointer size.

Finally, given the complexity of the call_indirect instrunction, this
change bundles an improvement to the register allocator, allowing it to
track the allocatable vs non-allocatable registers, this is done to
avoid any mistakes when allocating/de-allocating registers that are not
alloctable.

--
prtest:full

* Address review comments

* Fix typos
* Better documentation for `new_unchecked`
* Introduce `max` for `BitSet`
* Make allocatable property `u64`

* winch(calls): Overhaul `FnCall`

This commit simplifies `FnCall`'s interface making its usage more
uniform throughout the compiler. In summary, this change:

* Avoids side effects in the `FnCall::new` constructor, and also makes
  it the only constructor.
* Exposes `FnCall::save_live_registers` and
  `FnCall::calculate_call_stack_space` to calculate the stack space
  consumed by the call and so that the caller can decide which one to
  use at callsites depending on their use-case.

* tests: Fix regset tests
…dealliance#7029)

* Rename `Host*` things to avoid name conflicts with bindings.

* Update to the latest resource-enabled wit files.

* Adapting the code to the new bindings.

* Update wasi-http to the resource-enabled wit deps.

* Start adapting the wasi-http code to the new bindings.

* Make `get_directories` always return new owned handles.

* Simplify the `poll_one` implementation.

* Update the wasi-preview1-component-adapter.

FIXME: temporarily disable wasi-http tests.

Add logging to the cli world, since stderr is now a reseource that
can only be claimed once.

* Work around a bug hit by poll-list, fix a bug in poll-one.

* Comment out `test_fd_readwrite_invalid_fd`, which panics now.

* Fix a few FIXMEs.

* Use `.as_ref().trapping_unwrap()` instead of `TrappingUnwrapRef`.

* Use `drop_in_place`.

* Remove `State::with_mut`.

* Remove the `RefCell` around the `State`.

* Update to wit-bindgen 0.12.

* Update wasi-http to use resources for poll and I/O.

This required making incoming-body and outgoing-body resourrces too, to
work with `push_input_stream_child` and `push_output_stream_child`.

* Re-enable disabled tests, remove logging from the worlds.

* Remove the `poll_list` workarounds that are no longer needed.

* Remove logging from the adapter.

That said, there is no replacement yet, so add a FIXME comment.

* Reenable a test that now passes.

* Remove `.descriptors_mut` and use `with_descriptors_mut` instead.

Replace `.descriptors()` and `.descriptors_mut()` with functions
that take closures, which limits their scope, to prevent them from
invalid aliasing.

* Implement dynamic borrow checking for descriptors.

* Add a cargo-vet audit for wasmtime-wmemcheck.

* Update cargo vet for wit-bindgen 0.12.

* Cut down on duplicate sync/async resource types (#1)

* Allow calling `get-directories` more than once (#2)

For now `Clone` the directories into new descriptor slots as needed.

* Start to lift restriction of stdio only once  (#3)

* Start to lift restriction of stdio only once

This commit adds new `{Stdin,Stdout}Stream` traits which take over the
job of the stdio streams in `WasiCtxBuilder` and `WasiCtx`. These traits
bake in the ability to create a stream at any time to satisfy the API
of `wasi:cli`. The TTY functionality is folded into them as while I was
at it.

The implementation for stdin is relatively trivial since the stdin
implementation already handles multiple streams reading it. Built-in
impls of the `StdinStream` trait are also provided for helper types in
`preview2::pipe` which resulted in the implementation of
`MemoryInputPipe` being updated to support `Clone` where all clones read
the same original data.

* Get tests building

* Un-ignore now-passing test

* Remove unneeded argument from `WasiCtxBuilder::build`

* Fix tests

* Remove some workarounds

Stdio functions can now be called multiple times.

* If `poll_oneoff` fails part-way through, clean up properly.

Fix the `Drop` implementation for pollables to only drop the pollables
that have been successfully added to the list.

This fixes the poll_oneoff_files failure and removes a FIXME.

---------

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
…es run out. (bytecodealliance#7114)

* Cranelift: return programmatic error rather than panic when temporaries run out.

Cranelift currently has a limit of `2^21` vregs per function body in
VCode. This is a consequence of (performance-motivated) bitpacking of
`Operand`s into `u32`s in regalloc2.

As a result of this, it is possible to produce a function body that will
fail to compile by running out of vreg temporaries during lowering.
Currently, this results in a panic. Ideally, we would propagate the
error upward and return it programmatically.

This PR does that, with a "deferred error" mechanism. A cleaner solution
would be to properly thread the `Result` types through all layers of
lowering. However, that would require supporting `Result`s in ISLE, and
that is a deeper language-design and `islec`-hacking question that I
think we can tackle later if we continue to see motivating cases.

The deferral works by returning a valid but bogus `ValueReg`s to the
lowering rule, but storing the error and checking for it in the toplevel
lowering loop. (Note that we have to return a bogus `v0` rather than
`VReg::invalid()`, because the latter causes the `ValueRegs` to think
there is no register provided.)

This PR also includes a test at the Wasmtime level. Note that it takes
~22s to run on my (relatively fast) laptop, because it has to run until
it runs out of VRegs in a debug build of the compiler. We could remove
the test if we feel we're otherwise confident.

Thanks to Venkkatesh Sekar for reporting this issue! The integration
test uses one of the example inputs from the report.

* Review feedback.

* Handle alloc after a deferred error occurs.

* Add uncommitted fix for previous.
* Fix compile warnings in preview1 adapter

This isn't part of the "main build" so it's not inheriting the "deny
warnings" flag passed in CI, so fixup some warnings which have leaked
through over time.

* Remove some usage of `UnsafeCell` in the adapter

Move to abstractions such as `OnceCell` from the standard library as
well as `RefCell` to avoid some unsafety. This shouldn't have any
practical ramifications on the adapter, mostly just trying to help
over-time maintenance.

* Deny test-programs warnings in CI
alexcrichton and others added 24 commits October 26, 2023 21:55
Change an `a - b` expression to `a.saturating_sub(b)` to handle the case
when a clock is subscribed to an instance/duration in the past.
This vet was originally added in bytecodealliance#7380 but I accidentally deleted it
in bytecodealliance#7387 with a call to `cargo vet prune`.
…nce#7389)

* PCC: add memory type and fact annotations needed for dynamic-memory validation.

* PCC: update dynamic fact kinds, add sketch of dynamic-mem case, and add parser.

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* Working dynamic-range verification on x64 and aarch64.

* Fix x64 shll: output range according to bitwidth, not always-64-bit.

* Review feedback.

* Missing backtick in doc comment.

---------

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
)

Currently Wasmtime has two implementations of the `wasi_snapshot_preview1` set
of APIs. The now-historical implementation lives in the `wasi-common`
crate and the more recent implementation lives in the `wasmtime-wasi`
crate. The main difference is that the `wasmtime-wasi` implementation is
based on the implementation of preview2, meaning that the preview1
implementation is a shim in that direction. Additionally currently the
preview2 implementation of preview1 is accessible via the `-Spreview2`
flag on the CLI.

This commit updates the interpretation of the `-Spreview2` flag and the
defaults around which implementation to choose. By default the
preview1-built-on-preview2 implementation (the new `wasmtime-wasi`
implementation) is selected now. This means that the `wasi-common`
implementation is disabled by default. There are still two use cases to
keep running the `wasi-common` implementation, however:

* When running modules that import from `wasi_unstable`, the "snapshot"
  before `wasi_snapshot_preview1`, currently `wasi-common` is required.
  The shims to implement `wasi_unstable` have not yet been implemented
  in the `wasmtime-wasi` crate.

* When running with WASI threads (`-Sthreads`) the preview2
  implementation does not work. This is because the preview2
  implementation expects mutable access to the table which is not
  granted when threads are enabled.

Tests using `wasi_unstable` now pass `-Spreview2=n` to explicitly
request the old `wasi-common` implementation. Additionally the
`wasi-common` implementation is still selected by default when
`-Sthreads` is passed (enabling the WASI threads proposal).
…e#7393)

This also twists the `max_memory_protection_keys` knob.
* 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 bytecodealliance#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 bytecodealliance#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
* Add release notes for 14.0.3

* Review comments
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 bytecodealliance#7396
…ance#7402)

This commit fixes a panic in the `wasmtime serve` CLI command when the
`response-outparam::set` method was never invoked by the guest. In this
situation return a more first-class error than a panic explaining what
the guest should be doing.
Print a message on `wasmtime serve` startup showing the address that
`wasmtime` is listening for requests on, so that users know what it's
doing, and can copy+past the URL into curl or a browser to start
using it.

For example:

```
$ wasmtime serve target/wasm32-wasi/debug/hello_wasi_http.wasm
Serving HTTP on http://0.0.0.0:8080/
```
* Attempt to automatically configure release notes

This commit is an attempt to tackle bytecodealliance#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>

---------

Co-authored-by: Andrew Brown <andrew.brown@intel.com>
* Update wasm-tools crates

This commit updates the wasm-tools family of crate for a number of
notable updates:

* bytecodealliance/wasm-tools#1257 - wasmparser's ID-based
  infrastructure has been refactored to have more precise types for each
  ID rather than one all-purpose `TypeId`.
* bytecodealliance/wasm-tools#1262 - the implementation of
  "implementation imports" for the component model which both updates
  the binary format in addition to adding more syntactic forms of
  imports.
* bytecodealliance/wasm-tools#1260 - a new encoding scheme for component
  information for `wit-component` in objects (not used by Wasmtime but
  used by bindings generators).

Translation for components needed to be updated to account for the first
change, but otherwise this was a straightforward update.

* Remove a TODO
Updating a few locations that I missed from the previous updates.
* Validate headers

* Incorporate review feedback

* Update crates/wasi-http/wit/deps/http/types.wit

Co-authored-by: Luke Wagner <mail@lukewagner.name>

* Sync wit files

* Make the fields constructor infallible, and add fields.from-list

---------

Co-authored-by: Luke Wagner <mail@lukewagner.name>
This returns `Option<Box<wasmtime_error_t>>` on the Rust side.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Largely just additions of new targets and such, as well as support for
serde.
…dealliance#7358)

* monotonic clock: introduce `duration` type, split `subscribe`

We are introducing a `duration` type because it has a distinct meaning
from `instant`: an `instant` can only be compared to other `instant`s
from the exact same `monotonic-clock`, whereas a `duration` represents
a duration of time which can be compared to any other duration of time.

The `duration` type is motivated, in part, by a desire to reuse it to
specify durations such as timeouts in other WASI proposals.

Instead of taking a boolean specifying whether the u64 is an absolute or
relative time, `subscribe-instant` takes an `instant` type and
`subscribe-duration` takes a `duration` type.

* wasmtime-wasi: implement changes to monotonic clock interface

* adapter: fixes for subscribe duration and instant

* factor subscribe_to_duration out into a helper function.

* sync wits into wasi-http

* component adapter: fix for interpreting flag for monotonic instant vs duration

* subscribe_instant impl: fix logic for when time is in the past

caught by subtract overflow panic, thankfully

* test-programs: compile against new subscribe instant, duration methods
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 bytecodealliance#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.
* Turn `request-options` into a resource

* Fallible setters

* Store timeouts as std::time::Duration

* Trap when conversion from millis to u32 would fail

* Switch to clocks/monotonic-clock/duration for timeouts
@nagisa nagisa requested a review from MCJOHN974 October 31, 2023 14:03
@nagisa nagisa added this pull request to the merge queue Oct 31, 2023
Merged via the queue into main with commit 20945d9 Oct 31, 2023
@nagisa nagisa deleted the nagisa/remerges-upstream-main branch October 31, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.