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

Weekly merge #1

Merged
merged 57 commits into from
Aug 31, 2023
Merged

Weekly merge #1

merged 57 commits into from
Aug 31, 2023

Conversation

dhil
Copy link
Member

@dhil dhil commented Aug 31, 2023

No description provided.

fitzgen and others added 30 commits August 18, 2023 21:23
…ance#6835)

* Wasmtime: Rename `IndexAllocator` to `ModuleAffinityIndexAllocator`

We will have multiple kinds of index allocators soon, so clarify which one this
is.

* Wasmtime: Introduce a simple index allocator

This will be used in future commits refactoring the pooling allocator.

* Wasmtime: refactor the pooling allocator for components

We used to have one index allocator, an index per instance, and give out N
tables and M memories to every instance regardless how many tables and memories
they need.

Now we have an index allocator for memories and another for tables. An instance
isn't associated with a single instance, each of its memories and tables have an
index. We allocate exactly as many tables and memories as the instance actually
needs.

Ultimately, this gives us better component support, where a component instance
might have varying numbers of internal tables and memories.

Additionally, you can now limit the number of tables, memories, and core
instances a single component can allocate from the pooling allocator, even if
there is the capacity for that many available. This is to give embedders tools
to limit individual component instances and prevent them from hogging too much
of the pooling allocator's resources.

* Remove unused file

Messed up from rebasing, this code is actually just inline in the index
allocator module.

* Address review feedback

* Fix benchmarks build

* Fix ignoring test under miri

The `async_functions` module is not even compiled-but-ignored with miri, it is
completely `cfg`ed off. Therefore we ahve to do the same with this test that
imports stuff from that module.

* Fix doc links

* Allow testing utilities to be unused

The exact `cfg`s that unlock the tests that use these are platform and feature
dependent and ends up being like 5 things and super long. Simpler to just allow
unused for when we are testing on other platforms or don't have the compile time
features enabled.

* Debug assert that the pool is empty on drop, per Alex's suggestion

Also fix a couple scenarios where we could leak indices if allocating an index
for a memory/table succeeded but then creating the memory/table itself failed.

* Fix windows compile errors
Pull in the latest versions just published
This commit refactors the `wasmtime` CLI executable to be able to
support not only compiling components but additionally executing
components. While I was doing this I've additionally added a new
`--preview2` argument to enable using the new experimental
implementation of preview1 based on preview2 type/structs. This is
off-by-default but is expected to become the default in the future.

Some notable features of this change are:

* The preview1-implemented-with-preview2 module now sports
  `add_to_linker_{async,sync}` to replace the previous `add_to_linker`
  which always did async.

* Some trait bounds in the preview1-implemented-with-preview2 module are
  simplified.

* Some minor changes were made to `wiggle`'s macros to support a "block
  on" that isn't the default wiggle dummy executor (as now we actually
  do need Tokio)

* Many options related to core wasm `Linker` configuration, such as
  `--default-values-unknown-imports`, are not implemented for components
  at this time. When used with components these options return an error.

* Construction of WASI contexts has been refactored to pass around fewer
  arguments to avoid threading through lots of values for both preview1
  and preview2.

* Reading the input to the Wasmtime CLI has been updated to read the
  input in the `run` subcommand before handing it off to the `wasmtime`
  crate's API to enable the CLI to use the contents of what's loaded to
  determine what to do next.

* Our generic `./ci/run-tests.sh` script has been updated to pass the
  `--features component-model` flag to ensure that this CLI support is
  tested during the normal test suite.

* The CLI support for `wasi-nn` supports components as well as core wasm
  modules.
* Update release date of Wasmtime 12.0.0

* Update date to today

---------

Co-authored-by: Wasmtime Publish <[email protected]>
Co-authored-by: Alex Crichton <[email protected]>
…#6869)

* Use generated bindings to run components in the CLI

This commit updates the component support in the `wasmtime` CLI
from bytecodealliance#6836 to use the generated bindings for the "command" style of
components rather than having that custom-written in the CLI.

* Fix tests
…odealliance#6859)

This transform is wrong for the inputs in the attached testcase.

It was introduced in bytecodealliance#5546 and has been sort of unnoticed until bytecodealliance#6843 caused
some wasmtime testcode to fire this optimization rule and produce this
counterexample.
Previously 1.66.0 was listed, but as pointed out in bytecodealliance#6870 we now rely on
1.71.0
…iance#6873)

* wasmtime(fuzzing): Fix a warning

* wasmtime(fuzzing): Correctly configure pooling allocator in differential

* wasmtime(fuzzing): Allow instantiation failures due to hitting pooling limits
…6874)

This commit removes these two instructions and replaces them instead
with their equivalents using `fcmp` plus `select` or `bitselect`
depending on the type (`bitselect` for vectors, `select` for scalars).
The motivation for this commit is that incorrect optimizations for these
instructions were removed in bytecodealliance#6859 and likely stemmed from the
surprising definitions of these instructions. These originally were
intended to correspond to operations in the SIMD proposal for
WebAssembly but nowadays the functionality of these instructions is
replaced with:

* Lowering from wasm to clif uses the `fcmp` plus `select` combo instruction.
* Backends that support optimizing this pattern use ISLE patterns to
  match the instruction and emit the specialization for the pseudo
  semantics.

This means that while the instructions are removed here it should be the
case that no functionality is lost and the output of Wasmtime/Cranelift
should still be the same as it was before. Existing tests using the
pseudo instructions were preserved except the riscv64 ones (where the
lowering was deleted) and the dynamic AArch64 ones. Both s390x and x64
continue to have specialized patterns for this compare-plus-select.
…iance#6875)

This commit enables the `component-model` feature at compile time for
our CI-originating binaries in the same manner that `all-arch` is
enabled for CI as well.
* egraphs: Remove extends before selects when possible

* egraphs: Rewrite `select+{i,fcmp}` when select arms match cmp result

* egraphs: Simplify double `bmask`

* egraphs: Simplify double `bswap`

* egraphs: Modularize select optimizations

Co-Authored-By: Jamey Sharp <[email protected]>

* egraphs: Remove `bmask+{i,f}cmp` optimizations

These were unsound since we only represent the results of `{i,f}cmp` as
`-1` for vectors, and not for scalars, scalars get the output of `1`

* egraphs: Optimize `bitrev` in `select` and `bmask`

* egraphs: Optimize `popcnt` in `select` and `bmask`

* egraphs: Optimize double `bitrev`

* egraphs: Add `thruthy` expression matcher

Cleans up the previous logic a bit.

This also adds `rotl`/`rotr` as thruth preserving expressions. As well as
`select` when it's branches match certain constants.

Co-Authored-By: Jamey Sharp <[email protected]>

* egraphs: Make `icmp ne x, 0` a thruthy expression

* egraphs: Add `icmp ne x, 0` as an expression that can delete thruthy inputs

* egraphs: Add tests for comutative versions of the `icmp ne` thruthy rules

* egraphs: Restrict `icmp ne` optimization to arms with the

This also cleans up some merge conflicts that happened when rebasing.

* egraphs: Restore some accidentally deleted tests

* egraphs: Use `t` and `f` as names for select arms

Co-authored-by: Jamey Sharp <[email protected]>

* egraphs: Allow `icmp ne` opt to match arms of different types

Co-authored-by: Jamey Sharp <[email protected]>

---------

Co-authored-by: Jamey Sharp <[email protected]>
Co-authored-by: Jamey Sharp <[email protected]>
Adds methods of the shape `GeneratedStruct::offset_of_<field_name>() -> u32` to allow clients to get the
same offsets used in the generated `read` and `write` methods. I don't believe there is currently a
way to get these otherwise for applications that wish to selectively read and write to fields.

I considered a couple alternatives to this:

1. Add methods like `read_<field_name>` and `write_<field_name>`. The interface to these ends up
being awkward because the `GuestType` impls are currently for owned types, so these methods would be
forced to either take ownership of the entire struct to write one field, or else silently clone the
field.

2. Add `#[repr(C)]` to the generated struct definition so that clients could use tools like
`memoffset` to calculate the offset themselves. I didn't want to depend on the witx offsets
coinciding with `repr(C)`, though.

I extended the Wiggle `records` to exercise these new methods.
* Implement the `tcp` interface of wasi-sockets.

Implement the `tcp`, `tcp-create-socket`, and `network` interfaces of
wasi-sockets.

* Minor cleanups.

* Update to the latest upstream wasi-sockets.

* Address review feedback.

* Handle zero-length reads and writes, and other cleanups.

* Fix compilation on macOS.

* Fix compilation on Windows.

* Update all the copies of wasi-socket wit files.

* Sync up more wit files.

* Fix the errno code for non-blocking `connect` on Windows.

prtest:full

* Tolerate `NOTCONN` errors when cleaning up with `shutdown`.

* Simplify the polling mechanism.

This requires an updated tokio for `Interest::ERROR`.

* Downgrade to tokio 1.29.1 for now.

* Move `tcp_state` out of the `Arc`.

* `accept` doesn't need a write lock.

* Remove `tcp_state`'s `RwLock`.
* wasi-nn: add [named models]

This change adds a way to retrieve preloaded ML models (i.e., "graphs"
in wasi-nn terms) from a registry. The wasi-nn specification includes a
new function, `load_by_name`, that can be used to access these models
more efficiently than before; previously, a user's only option was to
read/download/etc. all of the bytes of an ML model and pass them to the
`load` function.

[named models]: WebAssembly/wasi-nn#36

In Wasmtime's implementation of wasi-nn, we call the registry that holds
the models a `GraphRegistry`. We include a simplistic `InMemoryRegistry`
for use in the Wasmtime CLI (more on this later) but the idea is that
production use will involve some more complex caching and thus a new
implementation of a registry--a `Box<dyn GraphRegistry>`--passed into
the wasi-nn context. Note that, because we now must be able to `clone` a
graph out of the registry and into the "used graphs" table, the OpenVINO
`BackendGraph` is updated to be easier to copy around.

To allow experimentation with this "preload a named model"
functionality, this change also adds a new Wasmtime CLI flag: `--graph
<encoding>:<host dir>`. Wasmtime CLI users can now preload a model from
a directory; the directory `basename` is used as the model name. Loading
models from a directory is probably not desired in Wasmtime embeddings
so it is cordoned off into a separate `BackendFromDir` extension trait.

* wasi-nn: add "named model" test

Add a new example crate which loads a model by name and performs image
classification. It uses the same MobileNet model as the existing test
but a new version of the Rust bindings. The new crate is built and run
with the new CLI flag in the `ci/run-wasi-nn-example.sh` script.

prtest:full

* review: rename `--graph` to `--wasi-nn-graph`
* winch: Initial support for floats

This change introuduces the necessary building blocks to support floats in
Winch as well as support for both `f32.const` and `f64.const` instructions.

To achieve support for floats, this change adds several key enhancements to the
compiler:

* Constant pool: A constant pool is implemented, at the Assembler level, using the machinery
  exposed by Cranelift's `VCode` and `MachBuffer`. Float immediates are stored
  using their bit representation in the value stack, and whenever they are
  used at the MacroAssembler level they are added to the constant
  pool, from that point on, they are referenced through a `Constant` addressing
  mode, which gets translated to a RIP-relative addressing mode during emission.

* More precise value tagging: aside from immediates, from which the type can
  be easily inferred, all the other value stack entries (`Memory`, `Reg`, and `Local`) are
  modified to explicitly contain a WebAssembly type. This allows for better
  instruction selection.

--

prtest:full

* fix: Account for relative sp position when pushing float regs

This was an oversight of the initial implementation. When pushing float
registers, always return an address that is relative to the current position of
the stack pointer, essentially storing to (%rsp). The previous implementation
accounted for static addresses, which is not correct.

* fix: Introduce `stack_arg_slot_size_for_type`

To correctly calculate the stack argument slot sizes, instead of overallocating
for `word_bytes`, since for `f32` floating points we only need to worry about
loading/storing 4 bytes.

* fix: Correctly type the result register.

The previous version wrongly typed the register as a general purpose register.

* refactor: Re-write `add_constants` through `add_constant`

* docs: Replace old comment

* chore: Rust fmt

* refactor: Index regset per register class

This commit implements `std::ops::{Index, IndexMut}` for `RegSet` to index each
of the bitsets by class. This reduces boilerplate and repetition throuhg the
code generation context, register allocator and register set.

* refactor: Correctly size callee saved registers

To comply with the expectation of the underlying architecture: for example in
Aarch64, only the low 64 bits of VRegs are callee saved (the D-view) and in the
`fastcall` calling convention it's expected that the callee saves the entire 128
bits of the register xmm6-xmm15.

This change also fixes the the stores/loads of callee saved float registers in the
fastcall calling convention, as in the previous implementation only the low 64
bits were saved/restored.

* docs: Add comment regarding typed-based spills
* doc: add ADOPTERS.md

Signed-off-by: Bailey Hayes <[email protected]>

* Update ADOPTERS.md

Co-authored-by: Till Schneidereit <[email protected]>

* Capitalize "Wasmtime"

---------

Signed-off-by: Bailey Hayes <[email protected]>
Co-authored-by: Till Schneidereit <[email protected]>
Co-authored-by: Nick Fitzgerald <[email protected]>
…6885)

* Handle more failures with `--trap-on-grow-failure`

This debugging tool was missing a few cases about `memory.grow` or
`table.grow` returning -1, namely when the OS reported failure in the
`memory.grow` case or in the case for tables when the computation
overflowed for the new table size. This commit updates the
`*_grow_failed` methods, which were already hooking these errors, to
return a `Result<()>` which enables returning a trap from them as well.

* Fix test
* upgrade webpki-roots to 0.25.2

Co-authored-by: Timmy Silesmo <[email protected]>

* upgrade rustls to 0.21.6

and replace deprecated add_server_trust_anchors with add_trust_anchors

Co-authored-by: Timmy Silesmo <[email protected]>

* audit dependency upgrades

---------

Co-authored-by: Timmy Silesmo <[email protected]>
…#6891)

* winch: Derive `OperandSize` from the value type

This change is a small refactor to how we've been handling the operand size
parameter passed to some of the `CodeGenContext` operations, namely,
`pop_to_reg` and `move_val_to_reg`.

Given the more precise value tagging introduced in:
bytecodealliance#6860,
it's now possible to derive the operand size from the type associated to a value
stack entry, which:

* Makes the usage of the functions mentioned above less error prone.
* Allows a simplification of the two function definitions mentioned above.
* Results in better instruction selection in some cases.

* chore: Update filetests
* Rename "reverse" to "flip"

* Rename "inverse" to "negate"

* Correct grammar in comment: change "an" to "a"

* Rename "flip" to "swap_args"

* Rename "negate" to "complement"
Specifically dynamic_memory_reserved_for_growth and native_unwind_info

Signed-off-by: Tyler Rockwood <[email protected]>
…nce#6905)

This commit optimizes the use of CI resources by avoiding unnecessary
duplication of WebAssembly spec tests when using the Cranelift compiler
strategy. Previously, Cranelift was tested against both the official spec test
suite and Winch's test suite, the latter being a subset of the former. This
commit eliminates this redundancy.
…codealliance#6547)

* Set compiler flag 'unwind_info' to false if specified in config

* fmt
* Avoid spawn_blocking and poll and asyncfd.

Replace the Unix-specific AsyncFd and Windows poll code using
tokio::net::TcpStream.

prtest:full

* Delete dead code.
alexcrichton and others added 27 commits August 24, 2023 23:49
* Don't force veneers on island emission

This commit is a follow-up to bytecodealliance#6804 with the discussion on bytecodealliance#6818. This
undoes some of the changes from bytecodealliance#6804, such as bringing a size parameter
back to `emit_island`, and implements the changes discussed in bytecodealliance#6818.
Namely fixups are now tracked in a `pending_fixups` list for editing and
modification and then during island emission they're flushed into a
`BinaryHeap` tracked as `fixup_records`. Additionally calculation of the
size of the pending island is now done as a single calculation rather
than updating metadata as we go along. This is required because fixups
are no longer entirely cleared during island emission so the previous
logic of "reset the island size to zero" and have it get recalculated as
the island is emitted is no longer applicable. I opted to go with a
simplistic version of this for now which assumes that all veneers are
the worst case size, but if necessary I think this could be more optimal
by tracking each veneer in a counter.

Closes bytecodealliance#6818

* Keep a running count for pending fixup deadline

Update this as pending fixups are added and then clear this out when
islands are emitted.

* Don't force all fixups to go through a binary heap

Instead process them immediately if they're ready.
…e#6893)

* wasi-nn: accept a list of backends instead of a hash map

* wasi-nn: refactor with new `Backend` and `Registry` wrappers

The wasi-nn crate uses virtual dispatch to handle different kinds of
backends and registries. For easier use, these items are now wrapped in
their own `Box<dyn ...>` structs.

* wasi-nn: completely remove `BackendKind`

This change completely removes the `BackendKind` enum, which uniquely
listed the kinds of backends that the wasi-nn crate contained. Since we
allow many kinds of backends in `WasiNnCtx` which can be implemented
even outside the crate, this `BackendKind` enum no longer makes sense.
This change uses `GraphEncoding` instead.

* nit: move `pub mod backend` with other exports

prtest:full

* fix: remove broken doc links
* Update dependencies

* `verify-component-adapter`: use workspace dependencies
* winch: Add support for parametric instructions

This commit introduces support for the drop and select instructions.

Additionally, it refactors the CodeGenContext::drop_last implementation,
enhancing flexibility for callers to determine the handling of elements to be
dropped. This refactoring simplifies scenarios where a Memory entry is at the
top of the stack.

* refactor: Use `cmov` instead of local control flow
- Bump wasm-tools deps
- Use new TypeSectionReader::into_iter_err_on_gc_types method
* fuzzgen: Enable `select` with float arms

* fuzzgen: Disable `select_spectre_guard` with float arms on RISC-V
…ce#6916)

* egraphs: Move `{s,u}widen+splat` rules to vector.isle

* egraphs: Disable some `splat` rules for floats
)

Unconditionally use `pblendvb` which will provide the semantics desired
for `bitselect` since the `all_ones_or_all_zeros` predicate guarantees
that byte-size-chunks are all-zeros-or-all-ones and `pblendvb` works at
the byte level. As suggested by Jamey in bytecodealliance#6890.

Closes bytecodealliance#6890
* x64: Implement `bitselect` for scalar integers

* x64: Implement `bitselect` for scalar floats

* fuzzgen: Enable bitwise float ops for x64
* update serde and serde_derive to 1.0.188

Co-authored-by: Christopher Serr <[email protected]>

* cargo vet: import audits for updates to serde, serde_derive, and syn

---------

Co-authored-by: Christopher Serr <[email protected]>
By not activating the `derive` feature on `serde`, the compilation speed
can be improved by a lot. This is because `serde` can then compile in
parallel to `serde_derive`, allowing it to finish compilation possibly
even before `serde_derive`, unblocking all the crates waiting for
`serde` to start compiling much sooner.

As it turns out the main deciding factor for how long the compile time of a
project is, is primarly determined by the depth of dependencies rather
than the width. In other words, a crate's compile times aren't affected
by how many crates it depends on, but rather by the longest chain of
dependencies that it needs to wait on. In many cases `serde` is part of
that long chain, as it is part of a long chain if the `derive` feature
is active:

`proc-macro2` compile build script > `proc-macro2` run build script >
`proc-macro2` > `quote` > `syn` > `serde_derive` > `serde` >
`serde_json` (or any crate that depends on serde)

By decoupling it from `serde_derive`, the chain is shortened and compile
times get much better.

Check this issue for a deeper elaboration:
serde-rs/serde#2584

For `wasmtime` I'm seeing a reduction from 24.75s to 22.45s when
compiling in `release` mode. This is because wasmtime through `gimli`
has a dependency on `indexmap` which can only start compiling when
`serde` is finished, which you want to happen as early as possible so
some of wasmtime's dependencies can start compiling.

To measure the full effect, the dependencies can't by themselves
activate the `derive` feature. I've upstreamed a patch for
`fxprof-processed-profile` which was the only dependency that activated
it for `wasmtime` (not yet published to crates.io). `wasmtime-cli` and
co. may need patches for their dependencies to see a similar
improvement.
* riscv64: Sign extend imm12 values

* riscv64: Rename `imm5_to_i8` constructor

This better fits the existing naming convention of constructors being `x_to_y` and extractors being `y_from_x`

See `u64_to_uimm5` or `uimm5_from_u8` as examples.

* riscv64: Sign extend `replicated_imm5` immediates

* riscv64: Delete `neg_imm12` helper

* riscv64: Delete `construct_imm_sub_rs`

It is no longer used.

* riscv64: Refactor `Inst::generate_imm`

Instead of taking a closure, return an Option with the split values

* riscv64: Rework constant emission

This moves the constant emission rules into isle and cleans
up some of the existing constant emission code.

Further work is still required

* riscv64: Fix imm matching for `insertlane`

* riscv64: Misc cleanups

* riscv64: Refactor uses of `Imm12::maybe_from_u64`

Use `Imm12::maybe_from_i64` where it is more ergonomic

* riscv64: Delete `Imm20::maybe_from_u64`
…nce#6879)

* egraphs: Transform bitops into a `bitselect`

* cranelift: Add bitwise bitselect tests
Wasmtime's CI does not run clippy so there's no enforcement of this
configuration. Additionally the configuration per-crate is not uniformly
applied across all of the Wasmtime workspace and is only on some
historical crates. Because we don't run clippy in CI this commit removes
all of the clippy annotations for allow/warn/deny from the source.
* Add some initial release notes for 13.0.0

May need more updates over the coming days, but this should document
everything up-to-now.

* Review comments
There are currently two `I32Exit` types, one in `wasi-common` and one in
`wasmtime-wasi`. The `maybe_exit_on_error` helper only searched for the
former though, so update it to search for the latter as well to handle
exits in the component CLI.
* added trap to resource dtor

* basic resources

* fixed signature and trait bounds

* fixed static function

* fixed trait signature

* basic resources

* added result to resource drop

* reverted formatting

* added doc comment to resource `dtor`

* fixed merge issue

* fixed another merge issue

* added resource import codegen test

* Revert changes to `Cargo.lock`

* Update `Cargo.lock` with the wit-bindgen update

* Add `cargo vet` entries for new crates

* Restore old-style of printing types in bindgen

Avoid collecting resources-as-we-go in favor of doing that more
declaratively elsewhere. Additionally handle imported-vs-exported
resource via the order that interfaces are visited.

* Update the shape of resource traits:

* Use `&mut self` instead of `StoreContextMut`
* Make resource traits as supertraits of the `Host` trait generated for
  each resource.
* More uniformly handle types/returns with resource methods.
* Fix derivations of `Clone` and `Copy` for where handles are contained.

* Fix generation of handle typedefs

* Support resources-in-worlds

* Remove now-duplicate function

This is now the same as the preexisting `generate_function_trait_sig`

* Fix classifying handles as imported or exported

This determination happens by looking up the origin definition of a
resource, not the leaf possibly-aliased type.

* Fix chains-of-use of resources

Resources don't have their representation asserted since the bare type
itself doesn't implement `ComponentType`, but otherwise generate type
aliases the same way as other type aliases.

* Revert `Cargo.lock` changes

No need to update `wit-bindgen` to 0.10.0 just yet, that'll happen in a
future update if necessary.

* Add basic runtime tests for resources

* fixed merge issue

---------

Co-authored-by: Alex Crichton <[email protected]>
This commit comes from discussion on bytecodealliance#6932 and adds target settings to
the C API to configure compilation artifacts.
* riscv64: Use `Inst::load_u64_constant` when loading load offsets

* riscv64: Load ISLE constants from pool

* riscv64: Delete `offset32_imm`

* riscv64: Delete `pack_float_rounding_mode`

* riscv64: Delete `LoadConst32` instruction

* riscv64: Delete LoadConstant code

Move that logic into `LoadInlineConst`

* riscv64: Fix `LoadAddr` instructions for RegOffset

We were accidentally overriding the offset with the base.

* riscv64: Update inst_worst_case_size
…odealliance#6920)

* riscv64: Add CSR Instructions

* riscv64: Add float to int vector instructions

* cranelift: Split vector rounding mode tests

* riscv64: Implement float rounding ops for vectors

* riscv64: Update tests
…odealliance#6924)

* riscv64: Implement SIMD `fvpromote_low`/`fvdemote`

* riscv64: Implement SIMD `fcvt_from_{u,s}int`

* riscv64: Implement SIMD `fcvt_to_{u,s}int_sat`

* riscv64: Use `i8_to_imm5` constructor
This is handy for users of `deserialize_file()` to determine which version to call.
@dhil dhil merged commit caa3adf into wasmfx:main Aug 31, 2023
4 checks passed
@dhil dhil deleted the weekly-merge branch August 31, 2023 16:47
dhil pushed a commit that referenced this pull request Oct 6, 2023
…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 <[email protected]>
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.