Skip to content

Sync with upstream#3

Merged
rylev merged 43 commits into
rylev:lookup-overridefrom
badeend:tcp-override
Jan 19, 2024
Merged

Sync with upstream#3
rylev merged 43 commits into
rylev:lookup-overridefrom
badeend:tcp-override

Conversation

@badeend
Copy link
Copy Markdown

@badeend badeend commented Jan 18, 2024

@rylev This includes some changes that were made to wasi-sockets recently
Also, I've removed the SocketProtocolMode type in 47bd556

scottmcm and others added 30 commits December 19, 2023 21:12
Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
…r 32-bit MOVN (bytecodealliance#7699)

When the top 32 bits of the value are zero and the upper_halfword of the lower
32 bits is u16::MAX, load_constant64_full will emit a single `movn` instruction.
In that case, add_range_fact only adds lower_halfword as the fact range, which
misses the upper halfword value. We should add the hole 32-bit value as the
fact range.

Co-authored-by: Feilong Jiang <jiangfeilong@huawei>
…#7710)

* Add a test demonstrating a missed optimization

* Add `[su]extend_maybe` to opt ISLE
Release builds previously accidentally used the latest stable rather
than the CI-fixed MSRV+2 due to a configuration bug.
…liance#7723)

* Fix test run isa target

* Fix rust-fmt

---------

Co-authored-by: wenyangwang <wenyangwang@tencent.com>
* wasi-nn: update openvino-rs to 0.6.0

Signed-off-by: Iceber Gu <caiwei95@hotmail.com>

* vet: audit the openvino version bump

Signed-off-by: Iceber Gu <caiwei95@hotmail.com>

---------

Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
* Bump MSRV to 1.73.0, use 1.75.0 in CI

Pulling in the Rust update released over the winter holidays.

* Fix more warnings
* Optimize more reduction-of-an-extend cases

* Rebase atop 7719
* Update several dependencies to windows-sys 0.52.

Update cap-std, rustix, io-extras, errno, fd-lock, fs-set-times, and
winx to versions which use windows-sys 0.52.

I started out hoping that everything could be updated to
windows-sys 0.52, however tokio and mio have not yet updated to
windows-sys 0.52 due to supporting an older MSRV.

* Link the C++ examples with CoreFoundation.

This is needed due to the iana-time-zone support.

prtest:full

* Fix compilation on non-Apple platfoms.

* Fix compilation on Apple platforms.
* winch: Add memory instructions

This commit adds support for the following memory instructions to winch:

* `data.drop`
* `memory.init`
* `memory.fill`
* `memory.copy`
* `memory.size`
* `memory.grow`

In general the implementation is similar to what other instructions via
builtins are hanlded (e.g. table instructions), which involve stack
manipulation prior to emitting a builtin function call, with the
exception of `memory.size`, which involves loading the current length
from the `VMContext`

* Emit right shift instead of division to obtain the memory size in pages
This commit updates the documentation for Store::get_fuel to match its
signature, which returns a `Result` instead of an `Option`.
The file copy added for shared libraries is not needed and unused, it's not done for static builds and everywhere refers to WASMTIME_BUILD_PRODUCT or the original file in cargo's output.
…liance#7688)

* feat: implement `Resource<T>` -> `ResourceAny` conversion

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* feat(component/linker): introduce `PathIndex`

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* test: add `into_resource_any` tests

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* refactor(linker): only track import index for resources

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* feat(PrimaryMap): add `From<Vec<V>>` implementation

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* refactor: store `ResourceImportIndex` mapping in `PrimaryMap`

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* doc: expand on `ResourceImportIndex` purpose

prtest:full

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* refactor: use `Linker::insert` in `Linker::resource`

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

---------

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
…liance#7712)

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
…nce#7750)

Previously, `first_non_empty_{c}io_vec` always returned `Ok(None)` for buffers
residing in shared memories since they cannot, in general, safely be represented
as slices.  That caused e.g. `wasi-libc` to spin forever when trying to write to
stdout using `fd_write` since it always got `Ok(0)` and never made progress.

This commit changes the return type of both functions to use `GuestPtr` instead
of `GuestSlice{Mut}`, allowing safe access to shared guest memory.

Big thanks to Alex Crichton for narrowing this down and suggesting the fix.

Fixes bytecodealliance#7745

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
…nce#7756)

It doesn't look like which needs to modify the front of the `VecDeque`
that it uses to model the value stack, and can instead use a `Vec`.
Try not passing `-y -u` to `pacman` to avoid full system updates.
Currently full system updates might update the `msys2-runtime` package
before actually updating the package we requested, meaning that this
might not actually update anything given an update. This is what's
currently happening on CI which is breaking due to an update of gcc not
actually updating gcc. I'm mostly reading the invocation in
rust-lang/rust CI and seeing that it doesn't pass `-y -u` and hopeing
that by copying that here things might work.

prtest:full
Redpanda embeds Wasmtime to power our inline data transforms, allowing developers to transform data directly within the broker.
* winch: Multi-Value Part 2: Blocks

This commit adds support for the Multi-Value proposal for blocks.

In general, this change, introduces multiple building blocks to enable
supporting arbitrary params and results in blocks:

* `BlockType`: Introduce a block type, to categorize the type of each
  block, this makes it easier to categorize blocks per type and also
  makes it possible to defer the calculation of the `ABIResults` until
  they are actually needed rather than calculating everyghing upfront
  even though they might not be needed (when in an unreachable state).
* Push/pop operations are now frame aware. Given that each
  `ControlStackFrame` contains all the information needed regarding
  params and results, this change moves the the implementation of the
  push and pop operations to the `ControlStackFrame` struct.
* `StackState`: this struct holds the entry and exit invariants of each
  block; these invariants are pre-computed when entering the block and
  used throughout the code generation, to handle params, results and
  assert the respective invariants.

In terms of the mechanics of the implementation: when entering each
block, if there are results on the stack, the expected stack pointer
offsets will be calculated via the `StackState`, and the `target_offset`
will be used to create the block's `RetArea`. Note that when entering
the block and calculating the `StackState` no space is actually reserved
for the results, any space increase in the stack is deffered until the
results are popped from the value stack via
`ControlStackFrame::pop_abi_results`.

The trickiest bit of the implementation is handling constant values that
need to be placed on the right location on the machine stack. Given that
constants are generally not spilled, this means that in order to keep
the machine and value stack in sync (spilled-values-wise), values must
be shuffled to ensure that constants are placed in the expected location results wise.
See the comment in `ControlStackFrame::adjust_stack_results` for more
details.

* Review fixes
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
* Update the wasm-tools family of crates

Brings in support for validating gc instructions, but they're all left
disabled for now.

* Update fuzz test case generation

* More test fixes, remove stray files

* More test fixes

* Rebase
elliottt and others added 13 commits January 10, 2024 21:38
…e#7763)

* Add a small test checking that pollables can be used many times

* Tests where two commands have their stdin/stdout piped together

* Pipe together wasmtime subprocesses instead of managing the buffer
Multiple pollables of the same stream should report the same ready
status when data is available.
LLVM passes the tag in rax and the u128 val in rdx/rcx. Before this
change Cranelift would pass the first half of the value in rdx and the
second half using an implicit return value pointer.
* Winch: Float conversion instructions

* Add conversions suite to ignore list for Windows
* Move `jit` crate to `environ`

Move the platform agnostic parts of the crate `wasmtime-jit` to
`wasmtime-environ`. This is the first part of the refactoring discussed
here: bytecodealliance#7652 and a
follow up will move the remaining parts of `wasmtime-jit` so that the
crate can be deleted.

* Move `jit` crate to `wasmtime`

Move the remaining parts of `wasmtime-jit` to the `wasmtime` crate and
remove `wasmtime-jit`. This is part of the refactoring discussed in
bytecodealliance#7652.

* undo toml formatting

* Trigger pipeline: prtest:full

* Remove `jit` directory

* move `ProfilingAgent` out of `profiling` feature

* add links to ELF_NAME_DATA
…odealliance#7781)

* wasi: pull in contents of wasi-sockets, wasi-http, and wasi-cli 0.2.0-rc-2024-01-16

* command-extended and test worlds: use rc-2024-01-16

* sockets implementation: v6only is now mandatory

* adapter: cli imports and exports are from rc-2024-01-16 now

* eliminate ipv6-only methods and tests

* a v6_client.blocking_connect(net, v4_listener) will always fail
  with INVAL right away.
* eliminate the paths where a v6 client is allowed to connect to v4.
* eliminate the udp_dual_stack_conversation from udp_sample_application

* component-basic: update wasi:cli version

* wasi-http: sync wit directory

* wasi-http: fix import version

* code review from dave

* test both ipv4 address on v6 socket, and ipv6-mapped-ipv4 on v6 socket, both fail
…7782)

* Omit instruction offsets in winch disassembly when possible

Only emit instruction offsets at basic block boundaries, or for all
instructions after a return. The reason behind the latter, is that many
of the instructions after a return are traps, and will be common jump
targets.

* Update winch tests

* Configure full offset output in the `disasm` function
* Add stack overflow tests

* Add stack overflow tests for indirect calls

* Check for stack overflow on function entry

* Ignore the call tests on windows, as stack overflows trap

* Bless the winch filetests
* mpk: also force MPK during benchmarking

This change takes advantage of the `WASMTIME_TEST_FORCE_MPK` environment
variable to force its use in the `call.rs` benchmarks. I see differences
in several cases when running:

```console
$ taskset --cpu-list 0-15 cargo bench -- async
$ WASMTIME_TEST_FORCE_MPK=1 taskset --cpu-list 0-15 cargo bench -- async
```

To properly isolate the MPK effects, this adds a `sync-pool` option
(`IsAsync::NoPooling`).

* mpk: disable PKRU read unless logging is turned on

After noticing some minor effects with this PKRU read, I chose to avoid
it unless logging is enabled. A perfectly valid alternative would be to
remove the logging altogether, but I have found this very helpful when
trying to troubleshoot MPK issues.

* mpk: inline PKRU functions

To avoid any unnecessary call overhead, we hint to the compiler that
`pkru::read` and `pkru::write` should be inlined.
@rylev rylev merged commit d796ad4 into rylev:lookup-override Jan 19, 2024
rylev pushed a commit that referenced this pull request Apr 2, 2024
…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>
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.