Commit Graph

6554 Commits

Author SHA1 Message Date
Nick Fitzgerald
8c5f59c0cf wasmtime: Implement table.get and table.set
These instructions have fast, inline JIT paths for the common cases, and only
call out to host VM functions for the slow paths. This required some changes to
`cranelift-wasm`'s `FuncEnvironment`: instead of taking a `FuncCursor` to insert
an instruction sequence within the current basic block,
`FuncEnvironment::translate_table_{get,set}` now take a `&mut FunctionBuilder`
so that they can create whole new basic blocks. This is necessary for
implementing GC read/write barriers that involve branching (e.g. checking for
null, or whether a store buffer is at capacity).

Furthermore, it required that the `load`, `load_complex`, and `store`
instructions handle loading and storing through an `r{32,64}` rather than just
`i{32,64}` addresses. This involved making `r{32,64}` types acceptable
instantiations of the `iAddr` type variable, plus a few new instruction
encodings.

Part of #929
2020-06-30 12:00:57 -07:00
Dan Gohman
959e424c81 Add O_PATH and O_CLOEXEC to yanix. (#1946)
* Add O_PATH and O_CLOEXEC to yanix.

While here, update the Wasmtime git branch name in a comment.

* Add AT_EMPTY_PATH too.
2020-06-30 11:26:59 -07:00
Alex Crichton
0acd2072c2 Fix doc warnings and link failures (#1948)
Also add configuration to CI to fail doc generation if any links are
broken. Unfortunately we can't blanket deny all warnings in rustdoc
since some are unconditional warnings, but for now this is hopefully
good enough.

Closes #1947
2020-06-30 13:01:49 -05:00
Nick Fitzgerald
dee2bf14a9 Merge pull request #1944 from declanvk/issue-1705
Implement customer [de]serialization for `IntegerInterner`
2020-06-30 09:58:05 -07:00
Andrew Brown
4d57ae99e3 Upgrade wasmparser to 0.58.0 (#1942)
* Upgrade wasmparser to 0.58.0

* Enable more spec tests
2020-06-30 11:08:21 -05:00
Declan Kelly
a3feb8a412 Implement customer [de]serialization for IntegerInterner
Added some basic tests that the representation of the interner
is only the `values` sequence, and that it round-trips successfully.
2020-06-30 01:21:27 -07:00
Nick Fitzgerald
43f8453b34 Merge pull request #1937 from fitzgen/upgrade-z3-for-peepmatic
deps: Bump `z3` to 0.6.0
2020-06-29 11:19:31 -07:00
Nick Fitzgerald
0bc0fd54eb deps: Bump z3 to 0.6.0
Z3 is used by `peepmatic`.
2020-06-29 10:41:22 -07:00
Valentin
c10c79b7ae Correct version of region dependency (#1933) 2020-06-29 08:55:37 -05:00
Alex Crichton
cca558cd20 Remove HostRef<T> from the C API (#1926)
This commit removes `HostRef<T>` from the C API which only served the
purpose now of converting each type to a `wasm_ref_t*`. Our
implementation, however, does not guarantee that you'll get the same
`wasm_ref_t*` for each actual underlying item (e.g. if you put a func in
a table and then get the func as an export and from the table then
`same` will report `false`). Additionally the fate of `wasm_ref_t*`
seems somewhat unclear at this point.

The change here is to make the `same` and cast functions all abort
saying they're unimplemented. (similar to the host info functions). If
and when we get around to reimplementing these functions we can ensure
they're implemented uniformly and work well for all intended use cases.
2020-06-26 14:34:34 -05:00
Pat Hickey
c3799c8ab4 Merge pull request #1929 from bytecodealliance/pch/stray_log_in_wasmtime_wiggle
wasmtime-wiggle: change stray `log` ecosystem macro to `tracing`
2020-06-26 10:54:02 -07:00
Pat Hickey
1659b849ba wasmtime-wiggle: change stray log ecosystem macro to tracing 2020-06-26 10:14:14 -07:00
Andrew Brown
ae634417a0 Enable more spec tests 2020-06-25 14:48:16 -07:00
Andrew Brown
c9d573d841 Provide spec-compliant legalization for SIMD floating point min/max 2020-06-25 14:48:16 -07:00
Nick Fitzgerald
c6b01935ec Merge pull request #1922 from fitzgen/stub-out-host-info-api
wasmtime: Rip out incomplete/incorrect externref "host info" support
2020-06-25 14:35:13 -07:00
Nick Fitzgerald
e40c039e65 wasmtime: Rip out incomplete/incorrect externref "host info" support
Better to be loud that we don't support attaching arbitrary host info to
`externref`s than to limp along and pretend we do support it. Supporting it
properly won't reuse any of this code anyways.
2020-06-25 14:00:40 -07:00
Peter Huene
9ce67d8cad Merge pull request #1914 from peterhuene/fix-musl-unwind
Register individual FDEs for musl libc.
2020-06-25 13:02:29 -07:00
Alex Crichton
a92a31d850 Rename the master branch to main (#1924)
* This PR is against a branch called `main`
* Internally all docs/CI/etc is updated
* The default branch of the repo is now `main`
* All active PRs have been updated to retarget `main`

Closes #1914
2020-06-25 14:03:21 -05:00
Peter Huene
4087fcee65 Register individual FDEs for musl libc.
When targeting musl, libunwind is used for the `__register_frame`
implementation.

Unlike when targeting libgcc which expects an entire frame table, the libunwind
implementation expects a single FDE.

This change ensures Wasmtime registers each individual FDE when targeting musl.

Fixes #1904.
2020-06-25 11:42:50 -07:00
Nick Fitzgerald
c91a9313b5 Merge pull request #1921 from fitzgen/cargo-fuzz-0.8
CI: use `cargo fuzz` 0.8.X
2020-06-25 10:49:25 -07:00
Nick Fitzgerald
ab80107dfb CI: use cargo fuzz 0.8.X
It has switched to release+debug assertion builds by default, so pass `--dev` to
avoid compiling with optimizations.
2020-06-25 10:01:23 -07:00
Pat Hickey
cd7fcf480b Merge pull request #1910 from bytecodealliance/pch/separate_wasmtime_wiggle_crate
Factor Wiggle's wasmtime integration into a standalone crate
2020-06-25 09:34:34 -07:00
Benjamin Bouvier
c9a3f05afd machinst x64: implement calls and int cmp/store/loads;
This makes it possible to run a simple recursive fibonacci function in
wasmtime.
2020-06-25 16:20:33 +02:00
Johnnie Birch
2d364f75bd Remove xmm_r_r inst data structure and cases after related refactoring
Removes unneeded data structure that was holding instructions for
xmm based move instructions. These instructions can should be categorized
as rm not just r. This change is intended to simplify organization and
cases when lowering.
2020-06-25 14:31:51 +02:00
Pat Hickey
82c4132700 simpler name, add rustdocs 2020-06-24 14:34:35 -07:00
Pat Hickey
6b62b16c7d rewrite shim func generator with witx CoreType 2020-06-24 12:47:28 -07:00
Johnnie Birch
f2f7706265 Implements vcode lowering for f32.copysign.
This patch implements the required but not already available
x64 instructions for copysign as well as the actual lowering sequence
and tests for the newly implemented x64 instructions.
Those instructions include:

andps,
andnps,
movaps,
movd,
orps,

The lowering sequence is based on the lowering for f32.copysign
in the current cranelift backend. movd does not have a test yet
due to some logic needed express a 32-bit register as a source
for xmm_rm_r instructions. This code also begins some
rethinking/refactoring of how the sse move instuctions
are written and so also includes new emit cases that will replace
current ones that match a different enum used to describe sse moves.
2020-06-24 11:47:26 -07:00
Nick Fitzgerald
1ea2f47d9c Merge pull request #1901 from fitzgen/ref-func
Support for `funcref`s, `ref.func`, and `table.grow` with `funcref`s
2020-06-24 10:53:19 -07:00
Nick Fitzgerald
58bb5dd953 wasmtime: Add support for func.ref and table.grow with funcrefs
`funcref`s are implemented as `NonNull<VMCallerCheckedAnyfunc>`.

This should be more efficient than using a `VMExternRef` that points at a
`VMCallerCheckedAnyfunc` because it gets rid of an indirection, dynamic
allocation, and some reference counting.

Note that the null function reference is *NOT* a null pointer; it is a
`VMCallerCheckedAnyfunc` that has a null `func_ptr` member.

Part of #929
2020-06-24 10:08:13 -07:00
Pat Hickey
91980b29f7 Merge pull request #1909 from siyopao/guestptr-conversion
wiggle: GuestPtr<[u8]> => GuestPtr<str> conversions
2020-06-23 21:08:44 -07:00
Pat Hickey
c6e599219a Update crates/wiggle/src/lib.rs 2020-06-23 21:08:05 -07:00
Pat Hickey
67f6aad415 Update crates/wiggle/src/lib.rs 2020-06-23 21:08:00 -07:00
Pat Hickey
564b0709dd wip 2020-06-23 18:11:38 -07:00
Pat Hickey
f66c1fbde9 reorganize configuration into modules 2020-06-23 17:42:12 -07:00
Craig Pastro
ea3c2325a5 wiggle: add as_byte_ptr: str -> [u8] method 2020-06-24 09:12:30 +09:00
Craig Pastro
7699c4d6e3 wiggle: fix lifetime in as_str_ptr 2020-06-24 09:10:59 +09:00
Nick Fitzgerald
ddc2ce8080 cranelift-wasm: Make FuncEnvironment::translate_ref_func take a FuncIndex
It was previously taking a raw `u32`. This change makes it more clear what index
space that index points into.
2020-06-23 16:36:10 -07:00
Nick Fitzgerald
c6f32f666d cranelift-wasm: Retain both the Wasm and Cranelift types of tables 2020-06-23 16:36:10 -07:00
Nick Fitzgerald
03165e0cb5 cranelift-wasm: Allow more customization of ref type representations
* Allow different Cranelift IR types to be used for different Wasm reference
  types.

* Do not assume that all Wasm reference types are always a Cranelift IR
  reference type. For example, `funcref`s might not need GC in some
  implementations, and can therefore be represented with a pointer rather than a
  reference type.
2020-06-23 16:36:10 -07:00
Nick Fitzgerald
28fccaedc4 cranelift-wasm: Pass ir::Tables into all the translate_table_* methods
This serves two purposes:

1. It ensures that we call `get_or_create_table` to ensure that the embedder
already had a chance to create the given table (although this is mostly
redundant due to validation).

2. It allows the embedder to easily get the `ir::TableData` associated with this
table, and more easily emit whatever inline JIT code to translate the table
instruction (rather than falling back to VM calls).
2020-06-23 16:36:10 -07:00
Pat Hickey
69f81397a8 add func overrides, to get rid of proc exit special case 2020-06-23 16:29:11 -07:00
Pat Hickey
49c62ee828 make the missing memory error value configurable 2020-06-23 15:28:01 -07:00
Pat Hickey
62237de7ce remove logging: wiggle now provides this functionality 2020-06-23 14:49:17 -07:00
Pat Hickey
bb339aaba0 rename macro. add comments to invocation. 2020-06-23 14:16:53 -07:00
Pat Hickey
abc3982234 add target to config 2020-06-23 14:13:27 -07:00
Thibault Charbonnier
8082aeaa5f C API: expose wasmtime_linker_get_one_by_name() (#1897)
* C API: expose wasmtime_linker_get_one_by_name()

* C API: remove unnecessary 'unsafe' qualifiers

* C API: avoid unnecessary mutable borrows of the Linker
2020-06-23 14:23:49 -05:00
Chris Fallin
9751b96c5e Merge pull request #1900 from cfallin/clarify-lowering-docs
MachInst isel and aarch64 backend: docs / clarity improvements.
2020-06-23 09:59:07 -07:00
Alex Crichton
6f6296816b Bind Trap::i32_exit_status in C API (#1912)
This allows embedders to take a different action when a WASI program
exits depending on whether it exited with an exit status or exited with
a trap.

cc bytecodealliance/wasmtime-py#30
2020-06-23 11:40:51 -05:00
Pat Hickey
cde32070fc factor the docs out as well 2020-06-22 19:27:31 -07:00
Pat Hickey
6adbae3007 paramaterize the instance type name as well 2020-06-22 19:01:29 -07:00