Commit Graph

6963 Commits

Author SHA1 Message Date
Pat Hickey
fe5d6d59e6 wasi example: theres lots of useful tracing messages for debugging 2020-09-01 14:34:12 -07:00
Pat Hickey
a2eae90701 test-all.sh: wasimtime-wasi-c does not exist anymore 2020-09-01 13:50:31 -07:00
Pat Hickey
51d88f7899 wasi-common: move implementation of args, env methods into StringArrayWriter 2020-09-01 13:50:31 -07:00
Pat Hickey
6213a05c85 wiggle: add array indexing methods to GuestPtr<[T]> 2020-09-01 13:50:31 -07:00
Pat Hickey
87222d6db0 wasi-common: move GuestPtr deref out of path::get 2020-09-01 13:50:30 -07:00
Pat Hickey
20ccc11564 Merge pull request #2140 from bytecodealliance/pch/wasi_error_handling
wasi-common: refactor error types
2020-09-01 13:01:26 -07:00
Pat Hickey
c9ec60dcce Merge pull request #2169 from bytecodealliance/pch/fix_wasmtime_wiggle
wiggle-wasmtime: witx paths should be relative to CARGO_MANIFEST_DIR,…
2020-08-31 10:05:04 -07:00
MaxGraey
a8f7041296 new implementations for nearest lib calls
use approach with copysign for handling negative zero


format


refactor for better branch prediction


move copysign back to internal branch


format


fix


use abs instead branches


better comments


switch arms for better branch prediction
2020-08-31 09:39:20 -07:00
Benjamin Bouvier
a7f7c23bf9 machinst aarch64: in baldrdash, allow returning only one value across register classes;
Baldrdash's API requires that there is at most one result in a register,
across all the possible register classes: in particular, it's not
possible to return an i64 value in a register while returning an v128
value in another register.

This patch adds a notion of "remaining register values", so this is
properly taking into account when choosing whether a return value may be
put into a register or not.
2020-08-31 12:36:26 +02:00
penguin-wwy
e535005c74 Remove unused argument for clif-util compile commandline 2020-08-31 10:43:30 +02:00
CohenArthur
6849dc40bd Fix typo in generated documentation for entity! (#2176)
* entity: Fix typo in generated documentation

The same function documentation was used for `from_u32()` and `as_u32()`
while their behaviour is different
2020-08-31 10:40:24 +02:00
Nick Fitzgerald
a30966e907 Merge pull request #2175 from alexcrichton/update-wasm-smith
Bump wasm-smith dependency
2020-08-29 11:53:32 -07:00
Alex Crichton
e12499c9ae Bump wasm-smith dependency
Brings in a fix for limiting the length of import strings generated.
2020-08-29 10:51:51 -07:00
Pat Hickey
335886134c fix test 2020-08-28 17:11:11 -07:00
Pat Hickey
edefbf7c73 fix tests 2020-08-28 15:58:16 -07:00
Pat Hickey
22b427baa0 use WASI_ROOT env var to specify witx paths to wiggle macros 2020-08-28 15:42:51 -07:00
Pat Hickey
91dac9c7e8 wiggle: witx paths use shell expansion
instead of always being relative to CARGO_MANIFEST_DIR, each use site is
responsible for either putting that variable or another one (set by a
build.rs) at the start of witx paths.
2020-08-28 15:42:48 -07:00
Max de Danschutter
f1a5e55b98 Increase into-func to accept 16 arguments (#2170) 2020-08-28 10:39:48 -05:00
Pat Hickey
5c6ed0c736 wip - didnt have time to finish this before quittin time 2020-08-27 18:19:53 -07:00
Pat Hickey
4dabe3fad6 wasmtime-wasi: fix invocation of wasmtime_integration!
should use path relative to this crates's root
2020-08-27 16:12:20 -07:00
Pat Hickey
82d2a48896 wiggle-wasmtime: witx paths should be relative to CARGO_MANIFEST_DIR, not WASI_ROOT
the WASI_ROOT was leftover from when this code was part of `wig`.
2020-08-27 16:03:05 -07:00
Julian Seward
8ac4bd1d0d CL/newBE/x64: Lowering of scalar shifts: fix shift-by-imm generation
The logic for generation of shifts-by-immediate was not quite right.  The result was that even
shifts by an amount known at compile time were being done by moving the shift immediate into %cl
and then doing a variable shift by %cl.  The effect is worse than it sounds, because all of
those shift constants are small and often used in multiple places, so they were GVN'd up and
often ended up at the entry block of the function.  Hence these were connected to the use points
by long live ranges which got spilled.  So all in all, most of the win here comes from avoiding
spilling.

The problem was caused by this line, in the `Opcode::Ishl | Opcode::Ushr ..` case:
```
   let (count, rhs) = if let Some(cst) = ctx.get_constant(inputs[1].insn) {
```
`inputs[]` appears to refer to this CLIF instruction's inputs, and bizarrely `inputs[].insn` all
refer to the instruction (the shift) itself.  Hence `ctx.get_constant(inputs[1].insn)` asks
"does this shift instruction produce a constant" to which the answer is always "no", so the
shift-by-unknown amount code is always generated.  The fix here is to change that expression to
```
   let (count, rhs) = if let Some(cst) = ctx.get_input(insn, 1).constant {
```
`get_input`'s result conveniently includes a `constant` field of type `Option<u64>`, so we just
use that instead.
2020-08-27 11:48:35 +02:00
Pat Hickey
393581b2ae Merge branch 'main' into pch/wasi_error_handling 2020-08-26 17:26:03 -07:00
Nick Fitzgerald
1bbcbcb647 Update wasm-smith to 0.1.2 (#2167) 2020-08-26 17:35:25 -05:00
Gabor Greif
2632848491 Relocation of DW_OP_{bra, skip} instructions (#2143)
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening DW_OP_deref will expand to about 10 bytes, for example.

So the jumps must be relocated. We approach this task by inserting artificial LandingPad markers (new CompiledExpressionParts constructors) into the parsed vector at actual Jump targets.

LandingPads are identified by JumpTargetMarker tokens which are generated on the fly.

Additionally we now parse the Jump instructions. These also get their corresponding JumpTargetMarker token.

We bail in two situations:

    frame_base is too complicated (i.e. itself contains Jump)
    some jump distance in the original expression is fishy.
2020-08-26 17:19:03 -05:00
bjorn3
0c4e15a52e [reader] Replace == None with .is_none() in Parser::token
This replaces a full function call with matching on both lhs and rhs
with a single cmpb instruction.
2020-08-26 13:01:16 -07:00
bjorn3
0d3f9ad8ef [reader] Avoid handling of unicode when not necessary
Clif files are not meant to be written by end-users anyway. The main
effects are that non-ascii identifiers fail to lex instead of parse and
whitespace must now be in the ascii range. Comments still have full
unicode support.

This also inlines all char::is_* methods to avoid nested matches.

Overall this results in a slight reduction of instruction count.
2020-08-26 13:01:16 -07:00
Pat Hickey
19393be396 Merge pull request #2164 from bytecodealliance/pch/remove_truncate_check
wasi-common: remove unnecessary check - fixed in std since Rust 1.38
2020-08-26 10:09:01 -07:00
Pat Hickey
7e750845cd Remove unnecessary check - fixed in std since Rust 1.38
issue now closed: https://github.com/rust-lang/rust/issues/63326
fix landed in a rollup: https://github.com/rust-lang/rust/pull/63380 merged aug 8, 2019
rust 1.38 beta cut on aug 15, 2019: https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html
minimum supported rust version for this repo is currently 1.41.
2020-08-25 17:27:47 -07:00
Pat Hickey
02aba548e1 Merge remote-tracking branch 'origin/main' into pch/wasi_error_handling 2020-08-25 15:22:51 -07:00
Pat Hickey
f54685d0bc Merge pull request #2139 from bytecodealliance/pch/wasi_common_tracing
wasi-common: switch all logs from `log` to `tracing`
2020-08-25 15:09:53 -07:00
Nick Fitzgerald
237a3ac7d9 Merge pull request #2162 from fitzgen/wasm-smith-fuzzing
Add a fuzz target for instantiating `wasm-smith` modules
2020-08-25 13:55:06 -07:00
Pat Hickey
5e0ca3c13b tracing: some windows fixes 2020-08-25 11:32:24 -07:00
Pat Hickey
930912f783 tracing fixes in unix poll; add some missing debug impls 2020-08-25 11:29:34 -07:00
Pat Hickey
963fe37eea Update crates/wasi-common/src/sys/windows/path.rs
Co-authored-by: iximeow <git@iximeow.net>
2020-08-25 11:17:08 -07:00
Pat Hickey
fceea4e7d2 Update crates/wasi-common/src/sys/unix/mod.rs
Co-authored-by: iximeow <git@iximeow.net>
2020-08-25 11:16:48 -07:00
Nick Fitzgerald
d688458619 Add a fuzz target for instantiating wasm-smith modules 2020-08-25 10:19:49 -07:00
Benjamin Bouvier
7c85654285 Address review comments. 2020-08-24 17:00:30 +02:00
Benjamin Bouvier
ee76e01efc machinst: fix the pinned reg hack;
The pinned register hack didn't work because the GetPinnedReg is marked
as having side-effects, so that GVN wouldn't try to common it out.

This commit tweaks the function used during lowering to vcode, so that
the GetPinnedReg opcode is specially handled. It's a bit lame, but it
makes the hack work again.

Also, use_input needs to be a no-op for real registers.
2020-08-24 17:00:30 +02:00
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