Commit Graph

7124 Commits

Author SHA1 Message Date
Benjamin Bouvier
efff43e769 machinst x64: fold address modes on loads/stores; 2020-08-24 17:00:30 +02:00
Benjamin Bouvier
b830ee79de machinst x64: commute operands of integer operations if one input is an immediate; 2020-08-24 17:00:30 +02:00
Benjamin Bouvier
cca10b87cb machinst x64: optimize select/brz/brnz when the input is a comparison; 2020-08-24 17:00:30 +02:00
Julian Seward
620e4b4e82 This patch fills in the missing pieces needed to support wasm atomics on newBE/x64.
It does this by providing an implementation of the CLIF instructions `AtomicRmw`, `AtomicCas`,
`AtomicLoad`, `AtomicStore` and `Fence`.

The translation is straightforward.  `AtomicCas` is translated into x64 `cmpxchg`, `AtomicLoad`
becomes a normal load because x64-TSO provides adequate sequencing, `AtomicStore` becomes a
normal store followed by `mfence`, and `Fence` becomes `mfence`.  `AtomicRmw` is the only
complex case: it becomes a normal load, followed by a loop which computes an updated value,
tries to `cmpxchg` it back to memory, and repeats if necessary.

This is a minimum-effort initial implementation.  `AtomicRmw` could be implemented more
efficiently using LOCK-prefixed integer read-modify-write instructions in the case where the old
value in memory is not required.  Subsequent work could add that, if required.

The x64 emitter has been updated to emit the new instructions, obviously.  The `LegacyPrefix`
mechanism has been revised to handle multiple prefix bytes, not just one, since it is now
sometimes necessary to emit both 0x66 (Operand Size Override) and F0 (Lock).

In the aarch64 implementation of atomics, there has been some minor renaming for the sake of
clarity, and for consistency with this x64 implementation.
2020-08-24 11:50:06 +02:00
Gabor Greif
ec87aee147 Revert #2137, the extra (seemingly leftover) DW_OP_deref is in fact essential (#2156)
* Revert "don't leave Deref bytecode for Code chunk (#2137)"

This reverts commit 30b9e69136.

* add explanation that DW_OP_deref is needed
2020-08-21 13:12:30 -05:00
Chris Fallin
70b3fd3c10 Merge pull request #2155 from akirilov-arm/simd_conversions
AArch64: Implement SIMD conversions
2020-08-21 11:01:31 -07:00
Anton Kirilov
b895ac0e40 AArch64: Implement SIMD conversions
Copyright (c) 2020, Arm Limited.
2020-08-21 18:03:50 +01:00
Gabor Greif
6513e90914 use the obvious DW_OP_const4u for 0xffff_ffff (#2154)
No point in resorting to LEB128 encoding for such constants,
using the native `u32` is faster and more compact.

Adds `write_u32` method to facilitate this.
2020-08-21 08:16:09 -05:00
Johnnie Birch
0b67b22eda Update renamed document lint for broken links
Renames intra_doc_link_resolution_failure to broken_intra_doc_links
2020-08-20 14:24:06 -07:00
Andrew Brown
2154b76fa8 machinst x64: enable simd_const.wast spec test 2020-08-20 12:37:22 -07:00
Andrew Brown
2767b2efc6 machinst x64: add Inst::[move|load|store] for choosing the correct x86 instruction
This change primarily adds the ability to lower packed `[move|load|store]` instructions (the vector types were previously unimplemented), but with the addition of the utility `Inst::[move|load|store]` functions it became possible to remove duplicated code (e.g. `stack_load` and `stack_store`) and use these utility functions elsewhere (though not exhaustively).
2020-08-20 12:37:22 -07:00
Andrew Brown
cf598dc35b machinst x64: add packed moves for different vector types 2020-08-20 12:37:22 -07:00
Chris Fallin
debacec1c5 Merge pull request #2150 from jgouly/mul64s
arm64: Implement SIMD i64x2 multiply
2020-08-20 11:57:56 -07:00
Chris Fallin
051feaad75 Merge pull request #2148 from bjorn3/aarch64_fix_put_input_in_rsa
Fix put_input_in_reg
2020-08-20 11:41:35 -07:00
Chris Fallin
775dfa9df2 Merge pull request #1520 from bjorn3/aarch64-lower-small-fcvt_from_int
Lower fcvt_from_{u,s}int for 8 and 16 bit ints
2020-08-20 11:35:06 -07:00
Joey Gouly
a518c10141 arm64: Implement SIMD i64x2 multiply
Copyright (c) 2020, Arm Limited.
2020-08-20 13:26:03 +01:00
Alex Crichton
693c6ea771 wasmtime: Extract cranelift/lightbeam compilers to separate crates (#2117)
This commit extracts the two implementations of `Compiler` into two
separate crates, `wasmtime-cranelfit` and `wasmtime-lightbeam`. The
`wasmtime-jit` crate then depends on these two and instantiates them
appropriately. The goal here is to start reducing the weight of the
`wasmtime-environ` crate, which currently serves as a common set of
types between all `wasmtime-*` crates. Long-term I'd like to remove the
dependency on Cranelift from `wasmtime-environ`, but that's going to
take a lot more work.

In the meantime I figure it's a good way to get started by separating
out the lightbeam/cranelift function compilers from the
`wasmtime-environ` crate. We can continue to iterate on moving things
out in the future, too.
2020-08-20 11:34:31 +02:00
bjorn3
957eb9eeba Less unnecessary zero and sign extensions 2020-08-20 10:17:04 +02:00
Pat Hickey
530ea50c82 wasi-common: dep on getrandom requires std 2020-08-19 15:10:04 -07:00
Pat Hickey
e8c01ddef1 put getrandom::Error into Error 2020-08-19 14:29:14 -07:00
bjorn3
b5e24c8c67 Update object to 0.21.1 (#2144) 2020-08-19 15:14:26 -05:00
Pat Hickey
c1aec81b84 add enough errno variants to cover all windows codes too 2020-08-19 12:03:38 -07:00
Pat Hickey
4535741d01 refactor when we translate io::Error to an Error
* a certain subset of io::Errors are expected - these we have
  a (platform-specific, because windows) method to translate into
  one of the wasi errno variants in the Error enum.
* some io::Errors are unexpected - wasi-common doesnt expect them from
  the underlying OS. rather than preserve any fidelity in reporting
  those to the user (only the unix impl attempts this), lets collect
  those as an `Error::UnexpectedIo(#[source] std::io::Error)`.
  Rather than trace at the conversion site, we rely on the wiggle error
  conversion hooks to trace the `Error`'s `Debug` impl, and then
  we convert all of these unexpected into `Errno::Io` for returning
  to the guest.

This is a different behavior from before, and I don't have any firm
guarantees that nobody was depending on the old behavior, but it
appears to me that none of those unexpected errnos were reasonable
to expect from any of the filesystem syscalls wasi-common is making.
2020-08-19 11:32:59 -07:00
bjorn3
ba48b9aef1 Fix put_input_in_reg 2020-08-19 19:38:47 +02:00
Gabor Greif
4cafb90186 use opcode directly, now that we support this (#2145)
fixing also two typos with `DW_OP_fbreg`
2020-08-19 12:30:01 -05:00
Johnnie Birch
a31336996c Add support for some packed multiplication for new x64 backend
Adds support for i32x4, and i16x8 and lowering for pmuludq in
preperation for i64x2.
2020-08-19 10:24:14 -07:00
bjorn3
3a16416132 Add tests 2020-08-19 19:17:27 +02:00
bjorn3
4a84f3f073 Lower fcvt_from_{u,s}int for 8 and 16 bit ints 2020-08-19 18:07:12 +02:00
Pat Hickey
9286bb8f08 hmm this code is challenging 2020-08-18 16:22:15 -07:00
Pat Hickey
e08173da9e fix windows: Error is not Copy like Errno is 2020-08-18 16:11:59 -07:00
Pat Hickey
94f904449b fix yanix 2020-08-18 16:02:53 -07:00
Pat Hickey
c4fbec6387 additional windows fix 2020-08-18 15:02:54 -07:00
Pat Hickey
73aef4c6ca guess i forgot a lot of these that dont build on linux 2020-08-18 15:01:04 -07:00
Pat Hickey
81b3450114 Merge pull request #2141 from bytecodealliance/pch/cranelift_faerie_deprecated
delete cranelift-faerie
2020-08-18 13:00:32 -07:00
Chris Fallin
924782191b Merge pull request #2138 from cfallin/regalloc-v0.0.30
Use regalloc 0.0.30.
2020-08-18 11:46:39 -07:00
Pat Hickey
3bc1f84c9d windows: success fixes 2020-08-18 11:31:08 -07:00
Pat Hickey
35c100fdca delete cranelift-faerie
see https://github.com/bytecodealliance/wasmtime/pull/1816

DEPRECATION NOTICE: the Cranelift developer team intends to stop maintaining
the `cranelift-faerie` crate and remove it from the `wasmtime` git repository
on or after August 3, 2020. We recommend users use its successor, the
`cranelift-object` crate.
2020-08-18 11:02:14 -07:00
Pat Hickey
80b884780b wasmtime-wasi: fix path to errno type 2020-08-18 10:57:43 -07:00
Pat Hickey
4be3b06b61 switch from log::debug to tracing::debug
this duplicates work done in #2139 on code that moves from
where the switch took place in that PR.
2020-08-18 10:55:42 -07:00
Pat Hickey
e8160c9a6b redefine crate to use Error everywhere except in wasi 2020-08-18 10:50:17 -07:00
Pat Hickey
b8409dd9aa wasi-common: define an Error type for the crate 2020-08-18 10:50:17 -07:00
Pat Hickey
19369142cb wasi-common: trace and convert error
this is a bug - the TODO was never resolved, even when the code to
implement it was added right below :)

tracing is already in the transitive deps via wiggle, so no extra
trouble there. tracing::debug is more appropriate than eprintln
2020-08-18 10:50:17 -07:00
Pat Hickey
0e1c534e07 wasi-common: fix some warnings 2020-08-18 10:46:14 -07:00
Pat Hickey
8d39d9b1b5 wasmtime-wasi: switch dep from log to tracing 2020-08-18 10:46:14 -07:00
Pat Hickey
94ee96712a wasi-common: switch all logs from log to tracing
tracing is already the dep that wiggle uses.

I used tracing structured arguments wherever I could, but I skipped over
it in all of the snapshot_0 code, because I'm going to delete that code
and replace it with wiggle-based stuff real soon.
2020-08-18 10:46:14 -07:00
Chris Fallin
22181d0819 Use regalloc 0.0.30.
This upgrade pulls in one memory-allocation reduction improvement
(bytecodealliance/regalloc.rs#95). There should be no change in behavior
as a result of this.
2020-08-18 09:51:35 -07:00
Gabor Greif
30b9e69136 don't leave Deref bytecode for Code chunk (#2137)
Re-enter loop after pushing `CompiledExpressionPart::Deref`, so that it
isn't recoded for `CompiledExpressionPart::Code` as well.
2020-08-18 10:54:34 -05:00
Chris Fallin
7c1cd774ef Merge pull request #2134 from cfallin/fix-abi-extension
AArch64 ABI: properly store full 64-bit width of extended args/retvals.
2020-08-18 08:39:30 -07:00
Nick Fitzgerald
4f7b10acac Merge pull request #2135 from bytecodealliance/pch/wasi_dep_version_gardening
Dependency version gardening
2020-08-17 16:39:31 -07:00
Pat Hickey
bacf470a3e bump all wat dependencies to 1.0.23
this gets us down to one version of `wast` in dependency tree!
2020-08-17 16:03:35 -07:00