Commit Graph

6452 Commits

Author SHA1 Message Date
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
Chris Fallin
6e8666826d Docs: add section on running under qemu. 2020-05-18 11:43:53 -07:00
Alex Crichton
f22f415b14 Document cross-compiling Wasmtime (#1721)
Closes #1720
2020-05-18 10:52:00 -05:00
Austin Abell
e40fd9d6ab Fix Wasm from rust docs (#1719)
* Update Wasm from Rust docs

* oops

* oops x2
2020-05-18 06:58:21 -05:00
Chris Fallin
72e6be9342 Rework of MachInst isel, branch fixups and lowering, and block ordering.
This patch includes:

- A complete rework of the way that CLIF blocks and edge blocks are
  lowered into VCode blocks. The new mechanism in `BlockLoweringOrder`
  computes RPO over the CFG, but with a twist: it merges edge blocks intto
  heads or tails of original CLIF blocks wherever possible, and it does
  this without ever actually materializing the full nodes-plus-edges
  graph first. The backend driver lowers blocks in final order so
  there's no need to reshuffle later.

- A new `MachBuffer` that replaces the `MachSection`. This is a special
  version of a code-sink that is far more than a humble `Vec<u8>`. In
  particular, it keeps a record of label definitions and label uses,
  with a machine-pluggable `LabelUse` trait that defines various types
  of fixups (basically internal relocations).

  Importantly, it implements some simple peephole-style branch rewrites
  *inline in the emission pass*, without any separate traversals over
  the code to use fallthroughs, swap taken/not-taken arms, etc. It
  tracks branches at the tail of the buffer and can (i) remove blocks
  that are just unconditional branches (by redirecting the label), (ii)
  understand a conditional/unconditional pair and swap the conditional
  polarity when it's helpful; and (iii) remove branches that branch to
  the fallthrough PC.

  The `MachBuffer` also implements branch-island support. On
  architectures like AArch64, this is needed to allow conditional
  branches within plausibly-attainable ranges (+/- 1MB on AArch64
  specifically). It also does this inline while streaming through the
  emission, without any sort of fixpoint algorithm or later moving of
  code, by simply tracking outstanding references and "deadlines" and
  emitting an island just-in-time when we're in danger of going out of
  range.

- A rework of the instruction selector driver. This is largely following
  the same algorithm as before, but is cleaned up significantly, in
  particular in the API: the machine backend can ask for an input arg
  and get any of three forms (constant, register, producing
  instruction), indicating it needs the register or can merge the
  constant or producing instruction as appropriate. This new driver
  takes special care to emit constants right at use-sites (and at phi
  inputs), minimizing their live-ranges, and also special-cases the
  "pinned register" to avoid superfluous moves.

Overall, on `bz2.wasm`, the results are:

    wasmtime full run (compile + runtime) of bz2:

    baseline:   9774M insns, 9742M cycles, 3.918s
    w/ changes: 7012M insns, 6888M cycles, 2.958s  (24.5% faster, 28.3% fewer insns)

    clif-util wasm compile bz2:

    baseline:   2633M insns, 3278M cycles, 1.034s
    w/ changes: 2366M insns, 2920M cycles, 0.923s  (10.7% faster, 10.1% fewer insns)

    All numbers are averages of two runs on an Ampere eMAG.
2020-05-16 23:08:22 -07:00
Nick Fitzgerald
463734b002 CI: only test peepmatic in one job (#1714)
* CI: only test `peepmatic` in one job

This avoids building Z3 in most jobs, which saves CI time.

* Fix curl syntax on Windows

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2020-05-15 21:16:16 -05:00
Alex Crichton
bd0b818900 Default to using bash on Github Actions (#1591)
This updates our github actions configuration with a new feature
released which allows configuring the default shell for the entire
worflow. Here we set that to `bash` since we frequently do that anyway
and it helps keep syntax consistent throughout the configuration file.
2020-05-15 15:08:29 -05:00
Alex Crichton
8f2d442ffd Remove dependabot from wasmtime (#1713)
Right now we're just getting a lot of noisy "can't parse manifest" error
messages, and with `cargo audit` running on CI we should be alerted to
security vulnerabilities anyway.
2020-05-15 09:07:31 -07:00
Y-Nak
0393d101b1 Fix typo in peepmatic (#1712) 2020-05-15 09:47:16 -05:00
Pat Hickey
c36a214ce7 Merge pull request #1711 from jlb6740/label_for_x64
Automatically label PRs related to the new x64 backend
2020-05-14 17:08:20 -07:00
Johnnie Birch
2c00aef88a Automatically label PRs related to the new x64 backend 2020-05-14 16:12:46 -07:00
Nick Fitzgerald
01f46d0238 Merge pull request #1692 from fitzgen/update-to-wasmparser-0.55.0
Update to using `wasmparser` 0.55.0
2020-05-14 14:00:24 -07:00
Chris Fallin
df4028749e Merge pull request #1699 from jgouly/inst-size
Reduce arm64 Inst enum size
2020-05-14 13:44:46 -07:00
Nick Fitzgerald
1a4f3fb2df Update deps and tests for anyref --> externref
* Update to using `wasmparser` 0.55.0
* Update wasmprinter to 0.2.5
* Update `wat` to 1.0.18, and `wast` to 17.0.0
2020-05-14 12:47:37 -07:00
Nick Fitzgerald
3c0b64fef7 Merge pull request #1710 from fitzgen/remove-unused-lhs-member
peepmatic: remove unused member from `PeepholeOptimizer`
2020-05-14 12:03:31 -07:00
Nick Fitzgerald
e9ef8ea3d5 peepmatic: remove unused member from PeepholeOptimizer
This is dead code, left over from an earlier design.
2020-05-14 11:08:59 -07:00
Nick Fitzgerald
27d3bf9aee Merge pull request #1701 from fitzgen/peepmatic-github-actions
Add github labels actions integration for peepmatic
2020-05-14 10:25:14 -07:00
Nick Fitzgerald
fb7a690efc Merge pull request #1687 from fitzgen/sign-extend-immediates
cranelift: Sign extend `Imm64` immediates
2020-05-14 10:09:53 -07:00
Nick Fitzgerald
98137ea09f Add github labels actions integration for peepmatic 2020-05-14 09:20:44 -07:00
Nick Fitzgerald
0c8c3f588a Merge pull request #1647 from fitzgen/integrate-peepmatic
Introduce peepmatic: a peephole optimizations DSL and peephole optimizer compiler
2020-05-14 09:02:21 -07:00
Alex Crichton
1e3a1fa372 Remove stray debugging printlns (#1698)
Forgot to do this earlier!
2020-05-14 10:26:09 -05:00
Nick Fitzgerald
c093dee79e cranelift: Let lifetime elision elide lifetimes 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
923a73be7b deps: Bump z3 to 0.5.1
This fixes Windows builds.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
8d7ed0fd13 deps: Update wast to 15.0.0
This also updates `wat` in the lockfile so that the SIMD spec tests are passing
again.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
22a070ed4f peepmatic: Apply some review suggestions from @bjorn3 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
a9b280ca3a CI: Ensure that the built peepmatic peephole optimizers are up to date
Beyond just ensuring that they can still be built, ensure that rebuilding them
doesn't result in a different built artifact.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
fd4f08e75f peepmatic: rustfmt 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
52c6ece5f3 peepmatic: Make peepmatic optional to enable
Rather than outright replacing parts of our existing peephole optimizations
passes, this makes peepmatic an optional cargo feature that can be enabled. This
allows us to take a conservative approach with enabling peepmatic everywhere,
while also allowing us to get it in-tree and make it easier to collaborate on
improving it quickly.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
6e135b3aea peepmatic: Fix a failed assertion due to extra iterations after fixed point
After replacing an instruction with an alias to an earlier value, trying to
further optimize that value is unnecessary, since we've already processed it,
and also was triggering an assertion.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
eb2dab0aa4 peepmatic: Save RHS actions as a boxed slice, not vec
A boxed slice is only two words, while a vec is three words. This should cut
down on the memory size of our automata and improve cache usage.
2020-05-14 07:52:23 -07:00