Commit Graph

2292 Commits

Author SHA1 Message Date
Nick Fitzgerald
70cef0a433 fuzzing: Enforce a maximum input length for peepmatic_compile target (#1985)
This avoids timeouts from large inputs, like
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23906
2020-07-07 09:03:14 -05:00
Peter Huene
d6ae72abe6 Merge pull request #1983 from peterhuene/fix-unwind-info
Remove 'set frame pointer' unwind code from Windows x64 unwind.
2020-07-06 22:26:41 -07:00
Peter Huene
92864baa1f Fix module doc comment. 2020-07-06 19:02:52 -07:00
Peter Huene
b1c7c1401e Fix incorrect scaling for SaveXmm128Far.
The `SaveXmm128Far` unwind op should have a 32-bit unscaled value.

The value was accidentally scaled down by 16 while calculating whether or not
the `SaveXmm128` or `SaveXmm128Far` unwind op should be used.
2020-07-06 18:52:16 -07:00
Nick Fitzgerald
62530e4d23 Merge pull request #1975 from MaxGraey/more-peephole-opts
peepmatic: add reminder by a power of two rule
2020-07-06 16:32:16 -07:00
MaxGraey
305659427d changes according review 2020-07-07 01:55:18 +03:00
Peter Huene
3a33749404 Remove 'set frame pointer' unwind code from Windows x64 unwind.
This commit removes the "set frame pointer" unwind code and frame
pointer information from Windows x64 unwind information.

In Windows x64 unwind information, a "frame pointer" is actually the
*base address* of the static part of the local frame and would be at some
negative offset to RSP upon establishing the frame pointer.

Currently Cranelift uses a "traditional" notion of a frame pointer, one
that is the highest address in the local frame (i.e. pointing at the
previous frame pointer on the stack).

Windows x64 unwind doesn't describe such frame pointers and only needs
one described if the frame contains a dynamic stack allocation.

Fixes #1967.
2020-07-06 14:22:57 -07:00
Graham Scheaffer
ef8fe18262 Updated region versions (#1978) 2020-07-06 09:26:28 -05:00
MaxGraey
2048278d2a typo 2020-07-03 21:45:40 +03:00
Benjamin Bouvier
9d5be00de4 Address review comments
- put the division in the synthetic instruction as well,
- put the branch table check in the inst's emission code,
- replace OneWayCondJmp by TrapIf vcode instruction,
- add comments describing code generated by the synthetic instructions
2020-07-03 14:33:52 +02:00
Benjamin Bouvier
2115e70acb machinst x64: implement enough to support branch tables; 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
f86ecdcb86 machinst x64: lower and implement div/idiv; ADD TESTS 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
da30527368 machinst x64: implement one way conditional jmp 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
9d1bcfb2e8 machinst x64: implement cmov 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
bd88065571 machinst x64: lower binary ALU operators; 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
faeed3c7a4 machinst x64: implement spills and reloads 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
08efcbd9d5 machinst x64: use movss for f32 loads; 2020-07-03 11:19:32 +02:00
MaxGraey
d21ca7f2a3 fixed added fits-in-native-word contrain 2020-07-03 11:46:37 +03:00
MaxGraey
03b6c97e15 typo 2020-07-03 11:05:55 +03:00
MaxGraey
1fcb215895 trailing new line 2020-07-03 11:03:03 +03:00
MaxGraey
1033cf5748 use (isub 1 $C) instead (iadd -1 $C) 2020-07-03 11:01:35 +03:00
MaxGraey
d839d83f7e add reminder by a power of two peephole rule 2020-07-03 09:44:59 +03:00
Chris Fallin
b700646c93 Merge pull request #1962 from cfallin/aarch64-lowering-condbr
AArch64: avoid branches with explicit offsets at lowering stage.
2020-07-02 14:05:40 -07:00
Chris Fallin
9bc0f3eceb Merge pull request #1966 from jgouly/simd-arith
arm64: Implement basic SIMD arithmetic
2020-07-02 11:07:14 -07:00
Chris Fallin
b7ecad1d74 AArch64: avoid branches with explicit offsets at lowering stage.
In discussions with @bnjbvr, it came up that generating `OneWayCondBr`s
with explicit, hardcoded PC-offsets as part of lowered instruction
sequences is actually unsafe, because the register allocator *might*
insert a spill or reload into the middle of our sequence. We were
careful about this in some cases but somehow missed that it was a
general restriction. Conceptually, all inter-instruction references
should be via labels at the VCode level; explicit offsets are only ever
known at emission time, and resolved by the `MachBuffer`.

To allow for conditional trap checks without modifying the CFG (as seen
by regalloc) during lowering, this PR instead adds a `TrapIf`
pseudo-instruction that conditionally skips a single embedded trap
instruction. It lowers to the same `condbr label ; trap ; label: ...`
sequence, but without the hardcoded branch-target offset in the lowering
code.
2020-07-02 11:02:27 -07:00
Andrew Brown
5ed74abeee Translate Wasm narrow instructions to CLIF's snarrow and unarrow
In order to make it more clear what the incoming types are for this translation (e.g. two `I32X4`s narrow to an `I16X8`), this change explicitly sets the type to which to bitcast (if necessary) the incoming values.
2020-07-02 09:35:45 -07:00
Andrew Brown
057c93b64e Add unarrow instruction with x86 implementation
Adds a shared `unarrow` instruction in order to lower the Wasm SIMD specification's unsigned narrowing (see https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing). Additionally, this commit implements the instruction for x86 using PACKUSWB and PACKUSDW for the applicable encodings.
2020-07-02 09:35:45 -07:00
Andrew Brown
65e6de2344 Replace x86_packss with snarrow
Since the Wasm specification contains narrowing instructions (see https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing) that lower to PACKSS*, the x86-specific instruction is not necessary in the CLIF IR.
2020-07-02 09:35:45 -07:00
Andrew Brown
152d7fcee7 Fix typo and wording of CDSL error messages 2020-07-02 09:35:45 -07:00
Joey Gouly
62e7b7f838 arm64: Implement basic SIMD arithmetic
Copyright (c) 2020, Arm Limited.
2020-07-02 13:17:33 +01:00
Benjamin Bouvier
8e257e731e cranelift-wasm: expose cranelift-frontend's FunctionBuilder in the public API; 2020-07-02 12:36:43 +02:00
Johnnie Birch
0aa56c500c Add x64 lowering of Clif flt load instruction for new backend
Adds support for the clif flt load instruction.
2020-07-01 17:48:33 -07:00
Johnnie Birch
f2dd1535d5 Add x64 lowering of Clif flt store instruction for new backend
Adds support for the clif flt store instruction.
2020-07-01 14:54:59 -07:00
Chris Fallin
0a59a321bd Merge pull request #1954 from cfallin/b1649432
AArch64: fix shift ops: mask shift amount.
2020-07-01 09:33:29 -07:00
Chris Fallin
a351fa52b5 Merge pull request #1930 from cfallin/spectre-heap
Spectre mitigation on heap access overflow checks.
2020-07-01 09:23:04 -07:00
Chris Fallin
533f1c8d8b Aarch64: fix shift ops: mask shift amount.
The failure to mask the amount triggered a panic due to a subtraction
overflow check; see
https://bugzilla.mozilla.org/show_bug.cgi?id=1649432. Attempting to
shift by an out-of-range amount should be defined to shift by an amount
mod the operand size (i.e., masked to 5 bits for 32-bit shifts, or 6
bits for 64-bit shifts).
2020-07-01 08:57:56 -07:00
Chris Fallin
e694fb1312 Spectre mitigation on heap access overflow checks.
This PR adds a conditional move following a heap bounds check through
which the address to be accessed flows. This conditional move ensures
that even if the branch is mispredicted (access is actually out of
bounds, but speculation goes down in-bounds path), the acually accessed
address is zero (a NULL pointer) rather than the out-of-bounds address.

The mitigation is controlled by a flag that is off by default, but can
be set by the embedding. Note that in order to turn it on by default,
we would need to add conditional-move support to the current x86
backend; this does not appear to be present. Once the deprecated
backend is removed in favor of the new backend, IMHO we should turn
this flag on by default.

Note that the mitigation is unneccessary when we use the "huge heap"
technique on 64-bit systems, in which we allocate a range of virtual
address space such that no 32-bit offset can reach other data. Hence,
this only affects small-heap configurations.
2020-07-01 08:36:09 -07:00
Till Schneidereit
f80c2abffb Update various crates' object and wast dependencies (#1908)
This somewhat cuts down on duplicate dependencies. `wast` is used in a much older version (`11.0.0`) by `witx`, and can be updated without issues there as well, but this at least gets us from 3 copies to 2.
2020-07-01 09:11:38 -05:00
Benjamin Bouvier
de9fbfa095 machinst x64: correctly assign FP registers for incoming args;
Fixes #1943.

Thanks to @jlb6740 for noticing the issue and @bjorn3 for catching the
error!
2020-07-01 15:00:43 +02:00
Andrew Brown
c3993a5f8e Translate Wasm SIMD abs to Cranelift's iabs instruction 2020-06-30 14:00:17 -07:00
Andrew Brown
737cf1d605 Implement iabs for x86 SIMD
This only covers the types necessary for implementing the Wasm SIMD spec--`i8x16`, `i16x8`, `i32x4`.
2020-06-30 14:00:17 -07:00
Andrew Brown
26bdf9c333 Add iabs instructions.rs
This is necessary for implementing SIMD [abs](https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#lane-wise-integer-absolute-value).
2020-06-30 14:00:17 -07:00
Nick Fitzgerald
a2f4202800 cranelift-frontend: Add the FunctionBuilder::insert_block_after method 2020-06-30 12:00:57 -07:00
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
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