Commit Graph

863 Commits

Author SHA1 Message Date
Alex Crichton
63d5b91930 Wasmtime 0.19.0 and Cranelift 0.66.0 (#2027)
This commit updates Wasmtime's version to 0.19.0, Cranelift's version to
0.66.0, and updates the release notes as well.
2020-07-16 12:46:21 -05:00
Alex Crichton
41e1300247 Allow improper_ctypes_definitions in C API
This was enabled in rust-lang/rust#72700 but it looks like it's still
too noisy for it to be useful to us.
2020-07-16 17:28:54 +02:00
Nick Fitzgerald
a9455a8e51 C API tweaks for wasmtime-py (#2029)
* wasmtime-c-api: Only drop non-null `*mut wasm_ref_t`s

* wasmtime-c-api: Handle null refs in `wasm_val_t` to `Val` conversion

* wasmtime-c-api: Don't unwrap and rewrap `Option`s

The `unwrap` can panic, and there isn't any point to this unwrap+rewrap.

* wasmtime-c-api: Add conversions between `funcref` and `wasm_func_t`

* wasmtime-c-api: More ownership documentation for `wasmtime.h`
2020-07-15 19:55:31 -05:00
Yury Delendik
a817470fab Fix signature of wasmtime_module_new 2020-07-15 14:07:36 -05:00
Benjamin Bouvier
abf157bd69 machinst x64: Only use the feature flag to enable the x64 new backend;
Before this patch, running the x64 new backend would require both
compiling with --features experimental_x64 and running with
`use_new_backend`.

This patches changes this behavior so that the runtime flag is not
needed anymore: using the feature flag will enforce usage of the new
backend everywhere, making using and testing it much simpler:

    cargo run --features experimental_x64 ;; other CLI options/flags

This also gives a hint at what the meta language generation would look
like after switching to the new backend.

Compiling only with the x64 codegen flag gives a nice compile time speedup.
2020-07-15 13:11:28 +02:00
Alex Crichton
1000f21338 Update wasmparser to 0.59.0 (#2013)
This commit is intended to update wasmparser to 0.59.0. This primarily
includes bytecodealliance/wasm-tools#40 which is a large update to how
parsing and validation works. The impact on Wasmtime is pretty small at
this time, but over time I'd like to refactor the internals here to lean
more heavily on that upstream wasmparser refactoring.

For now, though, the intention is to get on the train of wasmparser's
latest `main` branch to ensure we get bug fixes and such.

As part of this update a few other crates and such were updated. This is
primarily to handle the new encoding of `ref.is_null` where the type is
not part of the instruction encoding any more.
2020-07-13 16:22:41 -05:00
Nick Fitzgerald
9bafb173a0 Merge pull request #1996 from fitzgen/ref-types-in-c-api
Support reference types in the C API
2020-07-13 10:58:42 -07:00
Nick Fitzgerald
3638dba855 examples: Run the correct example executable on Windows
We were accidentally always running the `fib-debug/main` example because of
shenanigans with alphabetical ordering and hard coding "main.exe" as the command
we run. Now we properly detect which example we built and run the appropriate
executable.
2020-07-13 09:34:20 -07:00
Nick Fitzgerald
9f0ec620f0 wasmtime-c-api: Remove duplicate tests of examples
The canonical examples tests will be the examples run via `cargo run -p
run-examples` from now on. Those tests have two advantages over the ones being
deleted:

1. They will automatically pick up new examples and run/test them.
2. They support all of Linux, MacOS, and Windows, while the tests being deleted
   are Linux only.
2020-07-13 08:42:55 -07:00
Peter Huene
f48f9eb4b3 Merge pull request #2010 from whitequark/fix-windows-creat_trunc
WASI: make O_CREAT|O_TRUNC actually truncate files on Windows
2020-07-11 17:11:22 -07:00
Peter Huene
41b4721512 Add a test case for WASI file truncation. 2020-07-10 14:28:08 -07:00
Yury Delendik
b2551bb4d0 Make wasmtime_environ::Module serializable (#2005)
* Define WasmType/WasmFuncType in the Cranelift
* Make `Module` serializable
2020-07-10 15:56:43 -05:00
Nick Fitzgerald
ec331a088c run-examples: Provide more error context for debugging
Use `anyhow` for nice errors and provide error context on commands that we run.
2020-07-10 13:51:58 -07:00
Nick Fitzgerald
89603bc6b3 wasmtime-c-api: Make wasm_table_set *not* take ownership of its reference
Same for `wasm_table_grow` and `wasm_table_new` and their `init` values.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
d07fdca73a wasmtime-c-api: Use a safe helper for initializing MaybeUninit out pointers 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
377b213fd5 wasmtime-c-api: Remove unused HostInfoState struct 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
b73b2e0d5a wasmtime-c-api: Make wasmtime_externref_new write to an out pointer
The C API prefers not to return structs by value.

Same for `wasmtime_externref_new_with_finalizer`.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
b9bb095e0f wasmtime-c-api: Remove nested options from wasm_ref_t representation 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
742f8ee1fc wasmtime-c-api: Make wasmtime_externref_new proxy to wasmtime_externref_new_with_finalizer 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
5ed8a9ba0e wasmtime-c-api: Add an externrefs example for the C API 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
267bf16683 wasmtime-c-api: Add Wasmtime-specific APIs for externrefs
This commit adds APIs to create new `externref` values (with and without
finalizers) and to get an `externref`'s wrapped data.
2020-07-10 13:09:08 -07:00
Nick Fitzgerald
4c01ffd087 wasmtime-c-api: Document new reference types support 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
aaf4c941b8 wasmtime-c-api: Add support for funcref values 2020-07-10 13:09:08 -07:00
Nick Fitzgerald
4cdf8b7cfd wasmtime-c-api: Add support for externref values
This required that `wasm_val_t` have a `Drop` implementation, an explicit
`Clone` implementation, and no longer be `Copy`, which rippled out through the
crate a bit.

Additionally, `wasm_func_call` and friends were creating references to
uninitialized data for its out pointers and assigning to them. As soon as
`wasm_val_t` gained a `Drop` impl and tried to drop the old value of the
assignment (which is uninitialized data), then things blew up. The fix is to
properly represent the out pointers with `MaybeUninit`, and use `ptr::write` to
initialize them without dropping the old data.

Part of #929
2020-07-10 13:09:08 -07:00
whitequark
92f33284b6 WASI: make O_CREAT|O_TRUNC actually truncate files on Windows
Fixes #2009.
2020-07-10 19:23:37 +00:00
Rochet2
0387169934 Allow android compilation (#2002) 2020-07-09 11:03:55 -05:00
Yury Delendik
c53b253261 Fix debug information relocation (when imports present) (#1997) 2020-07-09 08:52:35 -05:00
Yury Delendik
091373f9b8 Removes duplicate code in src/obj.rs, crates/obj and crates/jit/object.rs (#1993)
Changes:

 -  Moves object creation code from crates/jit/object.rs to the creates/obj (as ObjectBuilder)
 -   Removes legacy crates/obj/function.rs
 -  Removes write_debugsections
2020-07-08 12:14:19 -05:00
Nick Fitzgerald
62655cdbe7 wasmtime: Document support for {extern,func}ref in Func::wrap 2020-07-07 14:27:07 -07:00
Nick Fitzgerald
392bbadac7 wasmtime: Ensure that Func::wrap'd return values are compatible with the current store 2020-07-07 14:27:07 -07:00
Nick Fitzgerald
3e63774e99 wasmtime: Add support for Option<Func> args and returns in Func::wrap 2020-07-07 11:09:20 -07:00
Nick Fitzgerald
46ef80bf2f wasmtime: Support ExternRefs in Func::wrap'd functions
Fixes #1868
2020-07-07 11:09:20 -07:00
Nick Fitzgerald
44e6fae29c wasmtime: Modify WasmTy and WasmRet for future {extern,func}ref support 2020-07-07 11:09:20 -07:00
Yury Delendik
bef1b87be0 Write ELF image and instantiate code_memory from it (#1931)
- Create the ELF image from Compilation
- Create CodeMemory from the ELF image
- Link using ELF image
- Remove creation of GDB JIT images from crates/debug
- Move make_trampoline from compiler.rs
2020-07-07 12:51:24 -05:00
Gabor Greif
79f054f77f Correct the files' directory index when downgrading DWARF5 -> 4 (#1989)
* correct the files' directory index when downgrading DWARF5 -> 4
2020-07-07 11:20:32 -05:00
Yury Delendik
9900641674 Support reference types in the DWARF transform (#1986) 2020-07-07 09:43:03 -05:00
Nick Fitzgerald
a7c6433773 wasmtime: Support reference types in the Rust API
This is a mix of exposing new things (e.g. a `Table::fill` method) and extending
existing support to `externref`s (e.g. `Table::new`).

Part of #929
2020-07-06 14:21:32 -07:00
Dan Gohman
cf5289c553 Begin porting yanix to WASI.
This isn't complete yet, but subsequent steps will depend on Rust libstd
and libc bindings changes that are in flight.
2020-07-06 20:20:28 +02:00
Nick Fitzgerald
25397d0c15 Merge pull request #1982 from fitzgen/fuzz-reference-types
fuzzing: Enable reference types by default
2020-07-06 10:27:09 -07:00
Daiki Ueno
2ce2dd0203 wasmtime: add build-time option for parallel compilation (#1903)
When running in embedded environments, threads creation is sometimes
undesirable. This adds a feature to toggle wasmtime's internal thread
creation for parallel compilation.
2020-07-06 11:22:05 -05:00
Nick Fitzgerald
9b56203732 fuzzing: Enable reference types by default
Part of #929
2020-07-06 09:18:52 -07:00
Nick Fitzgerald
80ff22fd18 Merge pull request #1973 from fitzgen/table-fill
wasmtime: Implement `table.fill`
2020-07-06 09:03:25 -07:00
Graham Scheaffer
ef8fe18262 Updated region versions (#1978) 2020-07-06 09:26:28 -05:00
Nick Fitzgerald
3555f97906 wasmtime: Implement table.fill
Part of #929
2020-07-02 16:59:07 -07:00
Johnnie Birch
60681d7019 Add __dso_handle to exception list of deprecated export symbols
When compiling C to WASM with clang-8, __dso_handle is a global
that maybe exported but that currently is not whitelisted along
with __heap_base and _data_end to be handled as allowable depricated
exports. This PR adds the case for __dso_handle.
2020-07-02 14:58:53 -07:00
Nick Fitzgerald
bffd54c016 wasmtime: Implement global.{get,set} for externref globals (#1969)
* wasmtime: Implement `global.{get,set}` for externref globals

We use libcalls to implement these -- unlike `table.{get,set}`, for which we
create inline JIT fast paths -- because no known toolchain actually uses
externref globals.

Part of #929

* wasmtime: Enable `{extern,func}ref` globals in the API
2020-07-02 16:04:01 -05:00
Nick Fitzgerald
3fa3ff2ece Merge pull request #1968 from alexcrichton/link-c-docs
Link to C API docs and make a landing page
2020-07-02 13:28:20 -07:00
Sergei Shulepov
ce51995828 Use smallvec for avoid allocations in the trampoline (#1965) 2020-07-02 11:24:03 -05:00
Alex Crichton
920e0984d3 Link to C API docs and make a landing page
Spice up the landing page a bit for the C API documentation and then
link to it from a few places to ensure it's discoverable.
2020-07-02 08:49:27 -07:00
Alex Crichton
47a218f908 Document the rest of the C API (#1959)
This commit fills out documentation for all remaining functions in the C
API, and additionally enables "warn if undocumented" which will fail CI
since warnings are also treated as errors.
2020-07-02 09:26:10 -05:00