Commit Graph

5970 Commits

Author SHA1 Message Date
Peter Huene
9de0ab302c Remove the .NET implementation. (#1477)
This commit removes the .NET implementation from Wasmtime.

It now exists at https://github.com/bytecodealliance/wasmtime-dotnet.

Also updates the Wasmtime book to include information about using Wasmtime from
.NET.
2020-04-06 20:03:49 -05:00
Alex Crichton
bd374fd6fc Add Wasmtime-specific C API functions to return errors (#1467)
* Add Wasmtime-specific C API functions to return errors

This commit adds new `wasmtime_*` symbols to the C API, many of which
mirror the existing counterparts in the `wasm.h` header. These APIs are
enhanced in a number of respects:

* Detailed error information is now available through a
  `wasmtime_error_t`. Currently this only exposes one function which is
  to extract a string version of the error.

* There is a distinction now between traps and errors during
  instantiation and function calling. Traps only happen if wasm traps,
  and errors can happen for things like runtime type errors when
  interacting with the API.

* APIs have improved safety with respect to embedders where the lengths
  of arrays are now taken as explicit parameters rather than assumed
  from other parameters.

* Handle trap updates

* Update C examples

* Fix memory.c compile on MSVC

* Update test assertions

* Refactor C slightly

* Bare-bones .NET update

* Remove bogus nul handling
2020-04-06 15:13:06 -05:00
Maciej Kot
78c548dc8f Option for host managed memory (#1400)
* Option for host managed memory

* Rename Allocator to MemoryCreator

* Create LinearMemory and MemoryCreator traits in api

* Leave only one as_ptr function in LinearMemory trait

* Memory creator test

* Update comments/docs for LinearMemory and MemoryCreator traits

* Add guard page to the custom memory example

* Remove mut from LinearMemory trait as_ptr

* Host_memory_grow test
2020-04-06 09:52:43 -05:00
Pat Hickey
c2cb4ea3ff Wiggle: tweaks to internal interfaces (#1469)
* [wiggle]: wiggle-generate internal interface for Names simplified

im using it in other libraries where I don't want to construct a
wiggle_generate::Config just to use the ctx_type out of it.

* wiggle: define_func can get trait name as argument

this flexibility needed for some customization over in lucet
2020-04-06 09:51:17 -05:00
Radu M
45b3ed142c Re-enable ignored unreachable_wat cli test (#1472)
Signed-off-by: Radu M <root@radu.sh>
2020-04-06 09:08:58 -05:00
Dan Gohman
9ca3bf532e Increase the size of the sigaltstack. (#1315)
* Increase the size of the sigaltstack.

Rust's stack overflow handler installs a sigaltstack stack with size
SIGSTKSZ, which is too small for some of the things we do in signal
handlers, and as of this writing lacks a guard page. Install bigger
sigaltstack stacks so that we have enough space, and have a guard page.
2020-04-03 16:36:17 -05:00
Andrew Brown
5297466add Expose parsing of run commands and trivially use in testing framework
This is necessary to avoid build errors from dead code (and I didn't want to litter all of the structs with `#[allow(dead_code)]` just to remove in a subsequent PR).
2020-04-03 13:25:10 -07:00
Andrew Brown
f56f9fb01c Remove unparseable run commands in existing tests 2020-04-03 13:25:10 -07:00
Andrew Brown
3d5ff8dc3d Add parsing functionality for run commands 2020-04-03 13:25:10 -07:00
Andrew Brown
07fc9d33bd Add Parser::match_imm8 for parsing signed 8-bit integers
Also, make some stylistic tweaks to `match_imm16` and `match_imm32` based on the review comments.
2020-04-03 13:25:10 -07:00
Andrew Brown
508042101f Add structures to represent run commands like run: %fn0(42, 4.2) == false 2020-04-03 13:25:10 -07:00
Andrew Brown
5cdc767496 Fix typo in lexer.rs 2020-04-03 13:25:10 -07:00
Dan Gohman
fde5ddf159 Fixes for 0.15 (#1449)
* Wasmtime 0.15.0 and Cranelift 0.62.0. (#1398)

* Bump more ad-hoc versions.

* Add build.rs to wasi-common's Cargo.toml.

* Update the env var name in more places.

* Remove a redundant echo.
2020-04-03 13:13:37 -07:00
Marcin Mielniczuk
f6e3ab03a2 Implement path_link for Windows. (#1199)
Implement path_link for Windows.
2020-04-03 21:24:38 +02:00
Alex Crichton
7728703ec7 Remove stray file in C API (#1464)
Forgot to delete this from a previous PR!
2020-04-03 13:53:33 -05:00
Andrew Brown
a799f9f6b5 Skip extra work when calculating sizes for recipes with inferred REX prefixes
As explained in the added documentation and #1342, if we prevent `infer_rex()` and `w()` from being used together then we don't need to check whether the W bit is set when calculating the size of a recipe. This should improve compile time for x86 very slightly since all `infer_rex()` instructions will no longer need this check.
2020-04-02 16:50:07 -07:00
Andrew Brown
a4c1147045 Skip extra work when inferring REX prefixes
As explained in the added documentation and #1342, if we prevent `infer_rex()` and `w()` from being used together then we don't need to check whether the W bit is set when figuring out if a REX prefix is needed in `needs_rex()`. This should improve compile time for x86 very slightly since all `infer_rex()` instructions will no longer need this check.
2020-04-02 16:50:07 -07:00
Andrew Brown
d0daef6f60 Avoid infer_rex() and w() on the same x86 encoding template, resolves #1342
In cranelift x86 encodings, it seemed unintuitive to specialize Templates with both `infer_rex()`` and `w()`: if `w()` is specified, the REX.W bit must be set so a REX prefix is alway required--no need to infer it. This change forces us to write `rex().w()``--it's more explicit and shows more clearly what cranelift will emit. This change also modifies the tests that expected DynRex recipes.
2020-04-02 16:50:07 -07:00
Nick Fitzgerald
a325b62ade Merge pull request #1463 from fitzgen/fix-c-api-tests
Fix wasmtime-c-api tests and run them in CI
2020-04-02 14:45:10 -07:00
Andrew Brown
e425bfcebd Infer REX prefixes for SIMD load and store with displacement 2020-04-02 11:28:42 -07:00
Andrew Brown
dc874a5b3b Infer REX prefixes for SIMD load_extend 2020-04-02 11:28:42 -07:00
Andrew Brown
9336884db5 Avoid inferring REX prefixes in i64 mode; fixes #1421 2020-04-02 11:28:42 -07:00
Nick Fitzgerald
1d337efa38 Run the C API tests in CI 2020-04-02 10:40:16 -07:00
Artur Jamro
3481e59673 Install rustfmt component for the CI job (#1462) 2020-04-02 12:34:38 -05:00
Nick Fitzgerald
244ed4191b Fix the C API crate's tests 2020-04-02 10:02:07 -07:00
Johnnie Birch
dff789c7c6 Adds JIT profiling support for VTune (#819)
This patch adds initial support for ittapi which is an open
source profiling api for instrumentation and tracing and profiling
of jitted code. Result files can be read by VTune for analysis

Build:
    cargo build --features=vtune
Profile: // Using amplxe-cl from VTune
    amplxe-cl -v -collect hostpost target/debug/wasmtime --vtune test.wasm
2020-04-02 09:04:08 -05:00
Johnnie Birch
9e11e8d019 Remove unnecessary braces around assigned value in simple_preopt
Removes unnecessary braces that is causing compilation failure
in a test scenario.
2020-04-02 15:54:19 +02:00
Alex Crichton
1a0325014f Remove the wasmtime Python extension from this repo (#1457)
* Remove the wasmtime Python extension from this repo

This commit removes the `crates/misc/py` folder and all associated
doo-dads like CI. This module has been rewritten to use the C API
natively and now lives at
https://github.com/bytecodealliance/wasmtime-py as discussed on #1390
2020-04-01 13:52:59 -05:00
Nathan Froyd
83602e05b6 cranelift-object: mark output as using non-executable stacks
The `faerie` crate does this by default.  `object` itself does not, but
it seems reasonable to make this change for parity between
`cranelift-faerie` and `cranelift-object`.
2020-04-01 12:20:53 -04:00
Marcin Mielniczuk
20e71858a1 Sanitize file/directory symlinks in path_symlinks on Windows (#1359)
* Sanitize file/directory symlinks in path_symlinks on Windows

* Remove redundant error mappings
2020-04-01 08:55:51 +02:00
Yury Delendik
e64668776a Propertly simulate DWARF information when imports present (#1452)
* Ignore complex LLVM10 expressions.

* Propery function name when imports are present
2020-03-31 18:33:35 -05:00
Andrew Brown
d3df275003 Remove duplication of map_reg; fixes #1245
Both cranelift-codegen and wasmtime-debug need to map Cranelift registers to Gimli registers. Previously both crates had an almost-identical `map_reg` implementation. This change:
 - removes the wasmtime-debug implementation
 - improves the cranelift-codegen implementation with custom errors
 - exposes map_reg in `cranelift_codegen::isa::fde::map_reg` and subsequently `wasmtime_environ::isa::fde::map_reg`
2020-03-31 15:42:02 -07:00
Pat Hickey
48014e8d45 wiggle: remove versions and dont publish wiggle-test (#1446)
* wiggle: delete version deps between wiggle and wiggle-test

* scripts: dont publish wiggle-test
2020-03-31 14:13:16 -05:00
Andrew Brown
5423683474 Enable spec test for SIMD load_extend 2020-03-31 11:35:26 -07:00
Andrew Brown
3699e7d925 Translate Wasm SIMD load_extend operations to Cranelift IR 2020-03-31 11:35:26 -07:00
Andrew Brown
54398156ea Add x86 implementation of SIMD load_extend instructions 2020-03-31 11:35:26 -07:00
Andrew Brown
cf1cfdcace Add new instructions to support SIMD load_extend 2020-03-31 11:35:26 -07:00
EchoSysBen
00200504b1 correct typo in the docs profiling section (#1442) 2020-03-31 09:22:56 -05:00
teapotd
2180e9ce16 fuzzing: Enable NaN canonicalization (#1334)
* Method to enable NaN canonicalization in Config

* Use fuzz_default_config in DifferentialConfig

* Enable NaN canonicalization for fuzzing
2020-03-31 09:22:08 -05:00
Alex Crichton
ac7cd4c46a Implement more of the wasm_frame_t type (#1438)
This fills out a few functions related to frame information in the C
API. This additionally adds some extension functions to get the module
name and function name from the C API.
2020-03-30 17:13:51 -05:00
Alex Crichton
bc5568f4b3 Symbolize start trap traces (#1437)
Make sure we've registered the frame info early enough so traps during
instantiation give frames as well.
2020-03-30 17:02:01 -05:00
bjorn3
bc462404b3 [cranelift-frontend] Fix emit_zero for vectors (#1428)
* Fix emit_zero for vectors
* Add undef_vector_vars frontend test
* Remove unused import
2020-03-30 13:01:14 -07:00
Alex Crichton
968cd76163 Move back to only one WASI submodule (#1434)
* Move back to only one WASI submodule

This commit fixes the issue where we have two WASI submodules for build
reasons in this repository. The fix was to place the submodule in the
`wasi-common` crate, and then anyone using the `wig` crate has to be
sure to define a `WASI_ROOT` env var in a build script to be able to
parse witx files.

With all that in place `wasi-common` becomes the source of truth for the
witx files we're parsing, and crates like `wasmtime-wasi` use
build-scripts shenanigans to read the same witx files. This should
hopefully get us so we're compatible with publishing and still only have
one submodule!

* rustfmt
2020-03-30 14:45:23 -05:00
Jakub Konka
78772cf5e1 Generate trace logs in wiggle albeit behind a feature gate
This commit augments `wiggle` with trace log generation for the shims,
returned errno values, and returned values proper (if any, i.e.,
different than unit type `()`). What that means is that every syscall
will have auto-generated up to 3 traces, for instance,

```
 TRACE wasi_common::wasi::wasi_snapshot_preview1 > fd_prestat_get(fd=Fd(3))
 TRACE wasi_common::wasi::wasi_snapshot_preview1 >      | result=(buf=Dir(PrestatDir { pr_name_len: 1 }))
 TRACE wasi_common::wasi::wasi_snapshot_preview1 >      | errno=No error occurred. System call completed successfully. (Errno::Success(0))
```

Putting logging behind a feature gate in this case means that the log calls
are generated by the `wiggle` crate regardless if the client requested
the feature or not, however, then their usage in the client lib is
dictated by the presence of the feature flag. So, for instance, `wasi-common`
has this feature enabled by default, while any other client lib
using `wiggle` if they don't want tracing enabled, they will just
leave the feature off. I'm not sure if this is what we wanted
but seemed easiest to implement quickly. Lemme y'all know your thoughts
about this!
2020-03-30 19:58:15 +02:00
Andrew Brown
cd900d72db Add tests showing no interference between jump tables and constants 2020-03-30 09:48:05 -07:00
Andrew Brown
1c339f35e7 Make rodata test framework more robust
Previously `test rodata` would cause failures when compiling Cranelift IR that had assertions about the current sink offset (e.g. multiple blocks, see `emit_function` in `binemit/mod.rs`).
2020-03-30 09:48:05 -07:00
Håvar Nøvik
98ff36bfed Fix typo in Memory.Maximum doc string. (#1432)
Co-authored-by: Håvar Nøvik <havar.novik@esmartsystems.com>
2020-03-30 10:04:40 -05:00
Andrew Brown
08e5484cdb Enable Wasm spec tests for SIMD load_splat (#1426) 2020-03-27 20:00:16 -05:00
bjorn3
dfe22836e8 Fix the order of the rex2 registers for r_ib_unsigned_gpr (#1424)
Fixes #1423
2020-03-27 14:29:32 -07:00
Alex Crichton
9d40e1072a Include the Windows DLL import library in binaries
This commit fixes an issue where you couldn't actually link to
`wasmtime.dll` via a C compiler because it was missing its import
library, `wasmtime.dll.lib`
2020-03-27 12:53:03 -07:00