Commit Graph

6481 Commits

Author SHA1 Message Date
Chris Fallin
48573b52b2 Merge vcode filetest mode into compile.
I hadn't realized before that the filetest backend for `test vcode` is
doing essentially what `compile` is doing, but for new (`MachInst`)
backends: it is just getting a disassembly and running it through
filecheck. There's no reason not to reuse `test compile` for the AArch64
tests as well.

This was motivated by the desire to have "this IR compiles successfully"
tests work on both x86 and AArch64. It seems this should work fine by
adding multiple `target` directives when a test case should be
compile-tested on multiple architectures.
2020-05-22 17:28:48 -07:00
Chris Fallin
73537e72c0 Merge pull request #1732 from jgouly/copysign-fpu
arm64: Use FPU instrctions for Fcopysign
2020-05-22 17:25:33 -07:00
Peter Huene
f36539130b Merge pull request #1734 from peterhuene/fix-saved-fprs
Cranelift: Fix FPR saving and shadow space allocation for Windows x64.
2020-05-22 12:06:37 -07:00
Pat Hickey
d57fea20ca Merge pull request #1717 from bytecodealliance/pch/wiggle_auto_borrow_checking
Automate borrow checking in wiggle
2020-05-22 09:35:12 -07:00
Nick Fitzgerald
193f9c9e15 Merge pull request #1746 from whitequark/i64-divrem-libcalls
cranelift: add i64.[us]{div,rem} libcalls
2020-05-22 08:50:12 -07:00
whitequark
b2e8ed4dc9 cranelift: add i64.[us]{div,rem} libcalls.
These libcalls are useful for 32-bit platforms.
2020-05-22 11:41:56 +00:00
Peter Huene
ce5f3e153b Only update XMM save unwind operation offsets when using a FP.
This commit prevents updating the XMM save unwind operation offsets when a
frame pointer is not used, even though currently Cranelift always uses a
frame pointer.

This will prevent incorrect unwind information in the future when we start
omitting frame pointers.
2020-05-21 16:46:30 -07:00
Peter Huene
54f9cd255f Re-enable tests that were excluded due to the previous limitation. 2020-05-21 15:57:15 -07:00
Peter Huene
2cd5ed1880 Address code review feedback. 2020-05-21 15:57:11 -07:00
Pat Hickey
bc1f538385 wiggle: fix tests 2020-05-21 15:47:48 -07:00
Pat Hickey
561f9e084a wig: bugfixes (sorry, thought i had tested before committimg) 2020-05-21 14:21:47 -07:00
whitequark
26ee986c2f runtime: handle traps on Windows x32. (#1740) 2020-05-21 15:07:05 -05:00
Alex Crichton
036c8ec8c5 Fix assertion about length/capacity in C API (#1736)
I recently saw some [errors] crop up in wasmtime-go's CI, so let's be
sure to convert to `Box<[T]>` which guarantees the length/capacity of
the vector are equal.

[errors]: https://github.com/bytecodealliance/wasmtime-go/runs/694744570
2020-05-21 15:06:30 -05:00
Pat Hickey
d19a09a4be wig: wiggle now puts BorrowChecker inside GuestMemory 2020-05-21 12:40:39 -07:00
Pat Hickey
9f763375de error name change fixup 2020-05-21 12:38:06 -07:00
Pat Hickey
96d6884d33 wiggle: get BorrowChecker from GuestMemory method 2020-05-21 12:37:14 -07:00
Pat Hickey
3920d8c1f3 code review fix 2020-05-21 12:22:47 -07:00
Pat Hickey
ba82ddcf37 borrow out of handles: change error name and describe behavior in comment 2020-05-21 12:22:19 -07:00
whitequark
e5635f4bc9 winx: do not link directly to ntdll.dll. (#1739)
The documentation for RtlNtStatusToDosError explicitly tells to call
it via GetProcAddress. The documentation for NtQueryInformationFile
does not, but similar considerations apply because there is normally
no import library for ntdll.

The main reason to use GetProcAddress though is because MinGW does
include an import library for ntdll, this import library contains
a definition of setjmp, and because of the way rustc orders linker
arguments, this definition of setjmp conflicts with and gets picked
over the one in msvcrt. Using setjmp from ntdll is undesirable as it
is an undocumented API and it is missing from wine, making it harder
to develop wasmtime using a cross-compiler.

Fixes #1738.
2020-05-21 13:56:20 -05:00
Joey Gouly
02c3f238f8 arm64: Use FPU instrctions for Fcopysign
Copyright (c) 2020, Arm Limited.
2020-05-21 18:14:12 +01:00
Alex Crichton
68f0d2f6d0 Enable env_logger in the C API (#1737)
This commit ensures that `env_logger` and `RUST_LOG` are configured to
work with the C API.
2020-05-21 11:02:49 -05:00
Peter Huene
78c3091e84 Fix FPR saving and shadow space allocation for Windows x64.
This commit fixes both how FPR callee-saved registers are saved and how the
shadow space allocation occurs when laying out the stack for Windows x64
calling convention.

Importantly, this commit removes the compiler limitation of stack size for
Windows x64 that was imposed because FPR saves previously couldn't always be
represented in the unwind information.

The FPR saves are now performed without using stack slots, much like how the
callee-saved GPRs are saved. The total CSR space is given to `layout_stack` so
that it is included in the frame size and to offset the layout of spills and
explicit slots.

The FPR saves are now done via an RSP offset (post adjustment) and they always
follow the GPR saves on the stack. A simpler calculation can now be made to
determine the proper offsets of the FPR saves for representing the unwind
information.

Additionally, the shadow space is no longer treated as an incoming argument,
but an explicit stack slot that gets laid out at the lowest address possible in
the local frame. This prevents `layout_stack` from putting a spill or explicit
slot in this reserved space. In the future, `layout_stack` should take
advantage of the *caller-provided* shadow space for spills, but this commit does
not attempt to address that.

The shadow space is now omitted from the local frame for leaf functions.

Fixes #1728.
Fixes #1587.
Fixes #1475.
2020-05-20 15:37:30 -07:00
Chris Fallin
c9e3b71c39 Merge pull request #1729 from cfallin/machinst-branch-opt
Fix MachBuffer branch optimization.
2020-05-20 14:43:57 -07:00
Chris Fallin
13e12908a6 MachBuffer branch opts: comments approximating a semi-formal correctness proof. 2020-05-20 14:12:19 -07:00
Pat Hickey
37514b730f wig: alex has convinced me that this BorrowChecker creation is correct 2020-05-20 12:51:28 -07:00
Pat Hickey
b130a64d19 wasi-common fixes 2020-05-20 12:51:28 -07:00
Pat Hickey
04fb4acc6a wasi-common: WIP translating to use automated borrow checking 2020-05-20 12:51:28 -07:00
Pat Hickey
3643f2d164 wig: create a BorrowChecker just to get things compiling. Needs fixing. 2020-05-20 12:51:28 -07:00
Pat Hickey
056a7d0729 wiggle: redo docs for auto borrow checking 2020-05-20 12:51:28 -07:00
Pat Hickey
c30194dfa1 document BorrowChecker, make creation unsafe 2020-05-20 12:51:28 -07:00
Pat Hickey
a4c1079b50 borrow checker: add method to check that its empty 2020-05-20 12:51:28 -07:00
Pat Hickey
d221a3a346 faster path for borrow-checking GuestPtr::{read, write} 2020-05-20 12:51:28 -07:00
Pat Hickey
be1df80c1b wasi test: update explanation of safety 2020-05-20 12:51:28 -07:00
Pat Hickey
478cc68082 wiggle: GuestType read and write must borrow 2020-05-20 12:51:28 -07:00
Pat Hickey
73602c6bfe borrow checker: reset index when empty, handle oom 2020-05-20 12:51:28 -07:00
Pat Hickey
52e8300f01 wiggle: automate borrow checking, explicitly passing borrow checker throughout 2020-05-20 12:51:28 -07:00
Nick Fitzgerald
e229fbc79c Merge pull request #1733 from fitzgen/rename-anyref-to-externref
Rename `anyref` to `externref` across the board
2020-05-20 12:44:49 -07:00
Chris Fallin
80ab154d04 Update from review comments. 2020-05-20 12:35:36 -07:00
Jakub Konka
348be6f3ed Revert fstatat on *nix and test symlinks in path_filestat calls (#1725)
* Revert fstatat on *nix and test symlinks in path_filestat calls

This commit effectively reverts too eager refactoring on my part which
resulted in incorrect `path_filestat_{get, set_times}` behaviour on
*nix hosts. In the presence of symlinks, neither of the calls would
work properly.

In order to shield ourselves from similar errors in the future, I've
augmented the `path_filestat` test cases with symlink checks as well.

* Pass appropriate flags to fstatat and utimensat

* Fix formatting

* Fix Windows build

* Expand final symlinks if follow is set on Windows

* Fix formatting

* Do not follow symlinks unless specified on Windows

* Update comments and restart CI

* Skip testing volatile atim field
2020-05-20 12:02:24 -07:00
Nick Fitzgerald
f28b3738ee Rename anyref to externref across the board 2020-05-20 11:58:55 -07:00
Benjamin Bouvier
1f620e1b46 cranelift: bump regalloc.rs to 0.0.24 and adapt to latest API changes; 2020-05-20 15:37:15 +02:00
Chris Fallin
e11094b28b Fix MachBuffer branch optimization.
This patch fixes a subtle bug that occurred in the MachBuffer branch
optimization: in tracking labels at the current buffer tail using a
sorted-by-offset array, the code did not update this array properly when
redirecting labels. As a result, the dead-branch removal was unsafe,
because not every label pointing to a branch is guaranteed to be
redirected properly first.

Discovered while doing performance testing: bz2 silently took a wrong
branch and exited compression early. (Eek!)

To address this problem, this patch adopts a slightly simpler data
structure: we only track the labels *at the current buffer tail*, and
*at the start of each branch*, and we're careful to update these
appropriately to maintain the invariants. I'm pretty confident that this
is correct now, but we should (still) fuzz it a bunch, because wrong
control flow scares me a nonzero amount. I should probably also actually
write out a formal proof that these data-structure updates are correct.
The optimizations are important for performance (removing useless empty
blocks, and taking advantage of any fallthrough opportunities at all),
so I don't think we would want to drop them entirely.
2020-05-19 18:09:18 -07:00
Nick Fitzgerald
5c39b74eb8 Make the fuzzing CI job faster (#1727)
* CI: Only build fuzz targets, don't run them over the corpora

We've only ever caught a single potential regression by running the fuzz targets
over a sample of their corpora. However, this is also our slowest CI
job. Running the fuzz targets over their corpora simply isn't paying for itself.

Instead, just ensure that we can build the fuzz targets with `cargo fuzz` and
all of the libFuzzer and sanitizer instrumentation that it enables. This will
ensure that we don't break the fuzz targets, and we leave finding regressions in
the fuzz corpora to oss-fuzz.

* fuzz: feature gate peepmatic's fuzz targets

This makes it so that the CI's fuzz target-building job doesn't build peepmatic,
and transitively Z3.
2020-05-19 15:27:52 -05:00
Nick Fitzgerald
26e0629795 Merge pull request #1726 from fitzgen/fix-simple-automata-timeout
Limit the size of automaton keys in the `peepmatic_simple_automata` fuzz target
2020-05-19 10:05:25 -07:00
Nick Fitzgerald
9d2100e54a Limit the size of automaton keys in the peepmatic_simple_automata fuzz target
Fixes https://oss-fuzz.com/testcase-detail/5742905129172992
2020-05-19 09:12:50 -07:00
Chris Fallin
d8d6fbe58c Merge pull request #1718 from cfallin/machinst-codebuffer
Rework of MachInst isel, branch fixups and lowering, and block ordering.
2020-05-19 07:17:22 -07:00
Nick Fitzgerald
28d6df0db6 Limit the size of automaton keys in the peepmatic_fst_diff fuzz target (#1724)
This should avoid timeouts caused by large keys.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22251
2020-05-18 21:27:00 -05:00
Chris Fallin
bdd2873c8c Address review comments. 2020-05-18 16:25:26 -07:00
Chris Fallin
687aca00fe Update x64 backend to use new lowering APIs. 2020-05-18 16:25:15 -07:00
Chris Fallin
a75377565f Merge pull request #1722 from cfallin/docs-qemu-run
Docs: add section on running under qemu.
2020-05-18 13:06:24 -07:00