Commit Graph

2988 Commits

Author SHA1 Message Date
Dan Gohman
b4528beaf5 Bump version to 0.51.0 (#1250) 2019-11-20 22:40:55 -08:00
Andrew Brown
838f2f4646 Merge pull request #1226 from abrown/log-verifier-errors
Log verifier errors
2019-11-20 13:29:53 -08:00
bjorn3
c5e74986e1 Legalize uextend and sextend to 128bit ints 2019-11-19 14:42:21 -08:00
Benjamin Bouvier
0b7e7916bd Fixes #1228: add a link to the contributing.md file from the readme. (#1245) 2019-11-19 13:49:50 +01:00
iximeow
d804ab8b92 Track frame layout changes. (#1204)
* Track frame layout changes.
2019-11-18 10:18:38 -08:00
Andrew Brown
f72a5d9caa Translate WASM floating-point abs and neg to CLIF 2019-11-15 13:45:25 -08:00
Andrew Brown
91d29c09d0 Add x86 SIMD floating-point absolute value 2019-11-15 13:45:25 -08:00
Andrew Brown
1f17e35e95 Add x86 SIMD immediate shifts 2019-11-15 13:45:25 -08:00
Andrew Brown
6519a43b08 Add x86 SIMD floating-point negation 2019-11-15 13:45:25 -08:00
Projjal Chanda
cd4d7ca0a1 Merged scalar and simd logical operator 2019-11-15 08:56:51 -08:00
XAMPPRocky
4ccacde3d4 Fix rendered links in CONTRIBUTING.md 2019-11-15 14:46:20 +01:00
krk
f7c7245b06 Add legalization for popcnt.i128 via narrowing, fixes #1116 2019-11-15 14:03:49 +01:00
Benjamin Bouvier
569a57fa7d Hoist the stack alignment and Windows64 fastcall shadow stack space constants. 2019-11-15 13:58:47 +01:00
Sean Stangl
f8ae622003 Use a struct interface for creating and reading encoding bits on x86. #1156 (#1212) 2019-11-13 18:01:13 -07:00
Peter Huene
b578fd5396 Fix the cranelift-filetests build. (#1227)
This commit removes the dependency on `byteorder::ReadBytesExt`, which can't be
used from `no_std`, which is how we're building the `byteorder` crate.

The fix is to simply offset into the slice as needed rather than using a
`std::io::Cursor`.

Fixes #1225.
2019-11-13 16:22:26 -08:00
Andrew Brown
37c70995a4 Temporarily disable fuzzing until #1216 is resolved (#1224) 2019-11-13 16:42:45 -06:00
Andrew Brown
215884e907 Simplify variable name: change inst_ to inst 2019-11-12 17:05:39 -08:00
Andrew Brown
a2b28f9472 Ensure vectors are bitcast to the correct type
Due to SIMD's v128 operations, vectors that may have had an explicit type (e.g. f32x4) before a v128 operation will subsequently have CLIF's v128 stand-in type: i8x16. In order for follow-on operations (that may be more stricly typed, e.g. f32x4.add) to avoid CLIF errors, we must bitcast them back to the operation type. The raw_bitcast operation used to do this emits no machine code but does incur some small compile-time cost; it would be nice to avoid this in the future.
2019-11-12 17:05:39 -08:00
Andrew Brown
b425ddc52d Translate WASM floating-point arithmetic to CLIF 2019-11-12 17:05:39 -08:00
Andrew Brown
c8eb4e9612 Add x86 SIMD floating-point arithmetic 2019-11-12 17:05:39 -08:00
Andrew Brown
04db2a9f39 Bind constant vectors to vconst; fixes #1052 (#1217) 2019-11-12 15:57:59 -08:00
Benjamin Bouvier
9080a02e10 Replace CraneStation by bytecodealliance everywhere; (#1221) 2019-11-12 10:09:31 -08:00
Till Schneidereit
f4b021c072 Make it a Bytecode Alliance project (#1220) 2019-11-12 07:52:48 -08:00
Andrew Brown
81df93e6a0 Translate WASM float comparisons to CLIF 2019-11-08 14:06:53 -08:00
Andrew Brown
d32301854d Add x86 SIMD implementation of float comparison 2019-11-08 14:06:53 -08:00
Andrew Brown
e5a36e2c61 Allow CLIF lexer to properly identify NaN and Inf keywords 2019-11-08 14:06:53 -08:00
Nick Fitzgerald
7e32fa2731 Try and assign directly to return registers; backtrack to use struct-return param (#1213)
* Try and assign directly to return registers; backtrack to use struct-return param

Rather than trying to count number of return registers that would be used by a
given set of return values, optimistically assign the return values to
registers. If we later find that we can't fit them all in registers, then
backtrack and introduce the use of a struct-return pointer parameter.

* Rename `rets2` and wrap it in an option so we avoid the clone for non-multi-value
2019-11-08 09:51:57 -08:00
Sean Stangl
a06f2c87c2 Pass Encoding to compute_size() for runtime Encoding inspection. #1156
In some cases, compute_size() is used to choose between various different Encodings
before one has been assigned to an instruction. For x86, the REX.W bit is stored
in the Encoding. To share recipes between REX/non-REX, that bit must be inspected
by compute_size().
2019-11-08 09:08:07 -08:00
Benjamin Bouvier
143cb01489 Do not align the stack frame for leaf functions not using the stack. 2019-11-08 17:20:20 +01:00
Benjamin Bouvier
1074c7675e Clear the old_signatures between functions' compilations. 2019-11-08 17:20:20 +01:00
Peter Huene
4ccf0fdfa3 Fix build errors in x86 unwind info when building no_std. (#1214)
This commit fixes the build errors in the unwind info implementation for
the x86 ABI by changing `byteorder` to build `no_std`.

This copies two simple functions from the `WriteBytesExt` trait so that
we can easily write to a `Vec<u8>` with a particular endianness.

Fixes #1203.
2019-11-07 16:41:32 -08:00
Dan Gohman
cf82863ea9 Bump version to 0.49.0 (#1208) 2019-11-06 14:38:46 -08:00
m4b
d5fb482524 build: update everything to target-lexicon 0.9; 2019-11-06 12:50:14 +01:00
Daniel
16441ed70a SimpleJIT - Add a Drop impl to PtrLen (#1001)
* Implement SimpleJIT deallocation for non-windows targets.

* Remove custom Drop from feature(selinux-fix).

* Fix typo in unprotect error message.

* Drop SimpleJIT memory by default and add free_memory method instead.

* Move free_memory to a handle returned by Module::finish.

* Reduce memory handle content to necessary fields only.

* Use lower overhead method for leaking.
2019-11-05 20:12:34 -08:00
Andrew Brown
1417215532 Translate WASM integer less-than to CLIF 2019-11-05 16:42:34 -08:00
Andrew Brown
af4637aff6 Add x86 SIMD legalizations for icmp less-than 2019-11-05 16:42:34 -08:00
Andrew Brown
ce67ea5d58 Factor out common translations for SIMD comparisons 2019-11-05 16:42:34 -08:00
Andrew Brown
7715c5e07a Translate WASM integer greater-than to CLIF 2019-11-05 16:42:34 -08:00
Andrew Brown
feffed85d2 Add x86 SIMD legalizations for integer greater-than
This includes `icmp ugt`, `icmp sge`, and `icmp uge` for vectors with lanes of I8, I16, and I32.
2019-11-05 16:42:34 -08:00
Andrew Brown
0ab5760fd7 Add x86 SIMD instructions for min and max
Only the I8, I16, and I32 versions are included since Cranelift lacks support for AVX.
2019-11-05 16:42:34 -08:00
Andrew Brown
f053595748 Translate WASM iTxN.gt_s to CLIF 2019-11-05 16:42:34 -08:00
Andrew Brown
c454c3c771 Add x86 SIMD encoding for icmp sgt 2019-11-05 16:42:34 -08:00
Andrew Brown
6f35273055 Add hexadecimal parsing for uimm8
This is to make it more clear in signed contexts that the uimm8 (e.g. 255) is in fact being used for its bits (e.g. 0xff).
2019-11-05 16:42:34 -08:00
Andrew Brown
3a94e8d46a Translate WASM iTxN.ne to CLIF 2019-11-05 16:42:34 -08:00
Andrew Brown
e3a20d67b2 Add x86 SIMD legalization of icmp ne 2019-11-05 16:42:34 -08:00
Andrew Brown
f8c3dfeb17 Translate WASM iTxN.eq to CLIF 2019-11-05 16:42:34 -08:00
Alex Crichton
f0e90df9ac Migrate CI to GitHub Actions
This commit migrates from Azure Pipelines to Github Actions for CI for
cranelift. The CI configuration was relatively straightforward, and the
intention here is not to change what's actually being done on CI, just
change where it's being done. The previous CI configuration had build
targets for producing releases, but these weren't actually applicable
for cranelift itself (mostly just copied from wasmtime), so they've been
folded into the main "test everything" matrix which now includes
`--release` mode items.

See cranestation/wasmtime#474 for some more context as well in terms of
benefits of Github Actions vs Azure Pipelines.
2019-11-05 16:07:50 -08:00
Nick Fitzgerald
a49483408c Many multi-value returns (#1147)
* Add x86 encodings for `bint` converting to `i8` and `i16`

* Introduce tests for many multi-value returns

* Support arbitrary numbers of return values

This commit implements support for returning an arbitrary number of return
values from a function. During legalization we transform multi-value signatures
to take a struct return ("sret") return pointer, instead of returning its values
in registers. Callers allocate the sret space in their stack frame and pass a
pointer to it into the caller, and once the caller returns to them, they load
the return values back out of the sret stack slot. The callee's return
operations are legalized to store the return values through the given sret
pointer.

* Keep track of old, pre-legalized signatures

When legalizing a call or return for its new legalized signature, we may need to
look at the old signature in order to figure out how to legalize the call or
return.

* Add test for multi-value returns and `call_indirect`

* Encode bool -> int x86 instructions in a loop

* Rename `Signature::uses_sret` to `Signature::uses_struct_return_param`

* Rename `p` to `param`

* Add a clarifiying comment in `num_registers_required`

* Rename `num_registers_required` to `num_return_registers_required`

* Re-add newline

* Handle already-assigned parameters in `num_return_registers_required`

* Document what some debug assertions are checking for

* Make "illegalizing" closure's control flow simpler

* Add unit tests and comments for our rounding-up-to-the-next-multiple-of-a-power-of-2 function

* Use `append_isnt_arg` instead of doing the same thing  manually

* Fix grammar in comment

* Add `Signature::uses_special_{param,return}` helper functions

* Inline the definition of `legalize_type_for_sret_load` for readability

* Move sret legalization debug assertions out into their own function

* Add `round_up_to_multiple_of_type_align` helper for readability

* Add a debug assertion that we aren't removing the wrong return value

* Rename `RetPtr` stack slots to `StructReturnSlot`

* Make `legalize_type_for_sret_store` more symmetrical to `legalized_type_for_sret`

* rustfmt

* Remove unnecessary loop labels

* Do not pre-assign offsets to struct return stack slots

Instead, let the existing frame layout algorithm decide where they should go.

* Expand "sret" into explicit "struct return" in doc comment

* typo: "than" -> "then" in comment

* Fold test's debug message into the assertion itself
2019-11-05 14:36:03 -08:00
Dan Gohman
45fb377457 Bump version to 0.48.0 (#1202)
* Bump version to 0.48.0

* Re-enable `byteorder`'s default features.

The code uses `WriteBytesExt` which depends on the `std` feature being
enabled. So for now, just enable `std`.
2019-11-05 13:59:19 -08:00
Peter Huene
8923bac7e8 Implement emitting Windows unwind information for fastcall functions. (#1155)
* Implement emitting Windows unwind information for fastcall functions.

This commit implements emitting Windows unwind information for x64 fastcall
calling convention functions.

The unwind information can be used to construct a Windows function table at
runtime for JIT'd code, enabling stack walking and unwinding by the operating
system.

* Address code review feedback.

This commit addresses code review feedback:

* Remove unnecessary unsafe code.
* Emit the unwind information always as little endian.
* Fix comments.

A dependency from cranelift-codegen to the byteorder crate was added.
The byteorder crate is a no-dependencies crate with a reasonable
abstraction for writing binary data for a specific endianness.

* Address code review feedback.

* Disable default features for the `byteorder` crate.
* Add a comment regarding the Windows ABI unwind code numerical values.
* Panic if we encounter a Windows function with a prologue greater than 256
  bytes in size.
2019-11-05 13:14:30 -08:00