Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Weekly upstream merge #43

Conversation

frank-emrich
Copy link

see comment below regarding a change in compiler.rs

rylev and others added 26 commits June 30, 2023 22:25
…e#6669)

* Add WasiCtxBuilder setters for the two clock types

Signed-off-by: Ryan Levick <[email protected]>

* Move two clocks to dedicated fields in WasiCtx

* Rename clock traits to Host prefix convention

Signed-off-by: Ryan Levick <[email protected]>

* Fix tests

---------

Signed-off-by: Ryan Levick <[email protected]>
* Run `cargo vet` on automated version bumps

As shown in the original CI of bytecodealliance#6686 the recent changes for `cargo vet`
0.8.0 mean that the previous release process no longer works since it
requires changes to the lock file for `cargo vet`. This updates the
version bumping process to run `cargo vet` as part of the committed
changes which hopefully will get everything to succeed. To ensure that
the same version of `cargo vet` is used in both locations the
installation procedure was extracted into its own separate little action.

* Configure shell to run in
* Bump Wasmtime to 12.0.0

* Add updates to `cargo vet` configuration

---------

Co-authored-by: Wasmtime Publish <[email protected]>
Co-authored-by: Alex Crichton <[email protected]>
* Update v8 and proc-macro2 dependencies

Gets them both compiling on the latest nightly so we can unpin the Rust
compiler version in OSS-Fuzz.

* Update nightly in CI
* cranelift: Const Propagate `ireduce`

* cranelift: Use `fits_in_64` in ireduce rule
…e#6685)

* winch(x64): Fix a couple of issues with control flow

This change fixes two issues with the control flow implementation found
when working on bytecodealliance#6610

The two fixes included in this change are:

1. Correctly handle the stack pointer at jump sites: when emitting an
   unconditional jump, the stack pointer might be left unbalanced due to
   register spilling, this could cause invalid memory accesses.

2. Explicitly track the exit label of the if block: previously the
   continuation label of the if block was implicitly treated as the exit
   label, which would cause undefined behaviour in programs that use
   unconditional branches in the `if` and `else` branches. This slight
   disadvantage of the approach in this change is that it involves special casing the
   emission of the end of an if block (without else) to account for the
   continuation label, since the continuation label is only naturally
   bound when there's an else branch.

* Expand on how `pop_sp_for_branch` works
* Fix a typo in an `unsafe impl Send/Sync`

This commit fixes a mistake in the `PrePatchedFuncRef` type where it has
an `unsafe impl` to make it send/sync but the target of the impl was
mistakenly `InstancePre<T>`

Note that this doesn't actually have any impact on the send/sync-ness of
`InstancePre<T>` since it's not storing an instance of `T`, so it's
always `Send`/`Sync` anyway. Nevertheless this reduces the scope of
unsafety slightly as was originally intended.

* Remove the `PrePatchedFuncRef` entirely

No longer necessary for `Send`/`Sync`-ness any more
…bytecodealliance#6637)

* handle interface functions correctly in `component::Linker::func_new`

Many months ago, I implemented `func_new`, but only supporting top-level
function imports.  If you tried to link a host function under an imported
interface, it would mistakenly treat it as a top-level function and either error
out if it couldn't find a corresponding type definition in the passed
`&Component`; or, if it found a top-level function that happened to have the
same name, it would use that type (which would coincidentally work if the type
happens to match, but lead to a runtime error later on otherwise).

This fixes the issue by looking up the correct component instance when necessary
and getting the type from there.

Note I've made no effort to optimize for performance here.  Happy to revisit
that if there's a need.

Signed-off-by: Joel Dice <[email protected]>

* print names in `func_new`, not intern indexes

Signed-off-by: Joel Dice <[email protected]>

* use `Vec` instead of linked list in `LinkerInstance`

Signed-off-by: Joel Dice <[email protected]>

---------

Signed-off-by: Joel Dice <[email protected]>
Co-authored-by: Alex Crichton <[email protected]>
* Store all instantiation arguments in a component

This commit updates how instantiation arguments are rooted within a
component instance. Previously a list of import arguments was "unzipped"
into a list of modules and a list of functions. This is becoming a bit
more cumbersome in an upcoming change for resources where a third style
of import is being added, so instead of this unzipping operation this
commit instead replaces the list of imports with an `Arc`. This way
instantiation is actually a bit cheaper since only one `Arc` needs to be
retained instead of each individual argument imported into a module.

Additionally this refactors the way that exported modules are handled by
avoiding translating everything into one list and instead continuing to
store modules in two separate lists: those in the component and those
imported.

* Add some more words
…e#6694)

* Fix signatures registered with modules-in-components

This commit fixes a minor issue in
`FunctionIndices::link_and_append_code` which previously ended up only
filling out the `wasm_to_native_trampolines` field for the first module
rather than all the modules. Additionally the first module might have
too many entries that encompass all modules instead of just its own
entries. The fix in this commit is to refactor this logic to ensure that
the necessary maps are present for all translations.

While technically a bug that can be surfaced through the embedder API
it's pretty obscure. The given test here panics beforehand but succeeds
afterwards, but this is moreso prep for some future resource-related
work where this map will need persisting into the component metadata
side of things.

* Fix build warning
…nce#6676)

* Update calling conventions for wasm functions slightly

This resolves two issues from recent changes in bytecodealliance#6649:

* First the s390x calling convention for wasm functions is changed back
  to `WasmtimeSystemV` from `Fast`. This was an accidental omission from
  bytecodealliance#6649 where the conclusion was that s390x will continue using a
  calling convention with little-endian lane order for lane arguments.
  The only calling convention that supports this today is
  `WasmtimeSystemV`, although the `Tail` calling convention will likely
  use it in the future as well.

* Second the apple-aarch64 platform now uses the `Fast` calling
  convention instead of `AppleAarch64` calling convention. That
  convention was specified in bytecodealliance#4195 but local testing shows that is not
  necessary in the sense that tests all pass with the `Fast` calling
  convention. This means that the prior comment why the `AppleAarch64`
  calling convention is required is no longer accurate and in the
  absence of a reason not to I went ahead and switched it to `Fast`.

In the near future all wasm functions will unconditionally use the
`Tail` calling convention and at that time the lane order can be
specified on s390x to be little-endian to satisfy all the constraints
here. Additionally any unwinding directives, if necessary for aarch64,
can be specified as needed.

* Fix compile
This commit adds support for the `local.tee` instruction. This change
also introduces a refactoring to the original implementation of
`local.set` to be able to share most of the code for the implementation
of `local.tee`.
…liance#6673)

* Attempt versioned exports to facilitate having multiple versions in the same crate

* Modify approach to use `export_name` and `link_name`

* Only apply version to names in assembly and foreign item fns

* Attempt to handle the s390x case

* Fix alignment of backslashes in assembly file

* Pretend I understand the preprocessor

* Version symbols in `crates/runtime/src/helpers.c`

* Stop versioning `__jit_debug_register_code` because gdb relies on it and it is uses `weak` linkage

* Version symbol in `crates/fiber/src/windows.c`

* Consolidate `LitStr` creation in macro

* Add new crate to publish script and supply-chain config

* Fix order in supply chain config

* Set `audit-as-crates-io` to false

* Missing `versioned_link` for Windows

* Version strings used in debug

* Formatting

* Get rid of `versioned_str` and bring back `versioned_suffix`

---------

Co-authored-by: Alex Crichton <[email protected]>
…lliance#6697)

We discussed this in today's Wasmtime meeting and the consensus was that
we trust each of these people to have a sufficient standard of care for
anything they release.

This reduces our estimated audit backlog by about 184 kLOC.

For the most part, the trust records I'm adding here are identical to
trust records that Mozilla is using. The fact that they've also decided
these publishers are trustworthy is reassuring additional evidence for
our decision. The exceptions and notable cases are as follows:

I've chosen to not trust three crates by these authors that Mozilla did
not trust. I suspect Mozilla simply doesn't use these crates or has
manually audited them, rather than there being any problem with the
crates themselves. But I've chosen to be conservative about what we
trust.

- autocfg: we only have an exception for an old version, and that
  version is only used transitively by wasi-crypto.
- env_logger: Mozilla has audited some versions; we should update, or
  add delta audits.
- thread_local: only used by tracing-subscriber which is only used in
  dev-dependencies.

I've trusted one crate that Mozilla did not: libm, when published by
Amanieu. We're trusting libc when published by the same author, and libm
is a small extension of the same trust.

Recent versions of the toml crate have been published by epage so I
looked at in this process, but Mozilla only trusts the older versions
which were published by alexcrichton. They've been delta-auditing the
newer versions. I've chosen to follow their lead on this; Alex is a
trusted contributor to Wasmtime anyway.
* allow perfmaps on any unix platform

* change it in cranelift as well
This change adds support for the `global.set` and `global.get`
instructions.
* Fix some warnings on nightly Rust

* One is to avoid using `drop(&mut T)`
* Another is to avoid using `()` in FFI functions since apparently
  that's not recommended. Working around this in the macro was pretty
  tricky, however.

* Fix a typo

* Review feedback
…#6709)

This commit fixes a mistake from the SSE2-simd work where an SSSE3 guard
was missing from a usage of `pshufb`. I assumed that the SSE4.1 guard
was enough but a fuzz-generated test case shows that it's possible to
enable SSE4.1 without SSSE3 so a second condition is added here (SSE4.1
remains for `pinsrb` and SSSE3 is for `pshufb`).
* Adding all missing branches to is_zero and adding cornercase to vall_true tests

* Starting to work on iterator

* Move Iterator implementation to DataValueExt

* Backup commit

* quick and dirty iterator

* adding test

* Simplifying code. Adding tests

* New implementation for Opcode::VallTrue

* Adding i64x2 testcase

* Using try_fold makes the code way more readable

* Correct results

* Simplify code even more

* Fix typo and propagate error up the chain

* Simply clone() DataValue without going through integers

* Return InvalidType for is_zero on any vector

* Handle V64 and V128 together

Co-authored-by: Afonso Bordado <[email protected]>

* Reformat code

* Reduce visibility of extractlanes

---------

Co-authored-by: Afonso Bordado <[email protected]>
.iter()
.map(|(_, ty)| match ty {
ModuleType::Function(ty) => *ty,
ModuleType::Continuation(ty) => *ty,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is correct.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correct.

Copy link

@dhil dhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

.iter()
.map(|(_, ty)| match ty {
ModuleType::Function(ty) => *ty,
ModuleType::Continuation(ty) => *ty,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correct.

Comment on lines +633 to +634
ModuleType::Function(ty) => *ty,
ModuleType::Continuation(ty) => *ty,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ModuleType::Function(ty) => *ty,
ModuleType::Continuation(ty) => *ty,
ModuleType::Function(ty) | ModuleType::Continuation(ty) => *ty,

@dhil
Copy link

dhil commented Jul 15, 2023

Subsumed by #50.

@dhil dhil closed this Jul 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.