Commit Graph

6452 Commits

Author SHA1 Message Date
Benjamin Bouvier
079ccf1f6e Remove unused results warnings; 2019-06-24 11:42:26 +02:00
Benjamin Bouvier
d7d48d5cc6 Add the dyn keyword before trait objects; 2019-06-24 11:42:26 +02:00
Lars T Hansen
eee824b6bd Merge pull request #797 from lars-t-hansen/memsink_rodata_fix
Fix a calculation error for rodata_size in memsink
2019-06-21 08:29:13 -07:00
Sean Stangl
b9836d4d9c Correctly capitalize Firefox in the README 2019-06-20 16:23:15 -07:00
Jef
2e4d676093 Fix several miscompilations 2019-06-20 15:21:22 +02:00
Van der Auwermeulen Grégoire
d900a5f6ef Update WASI-tutorial.md
consistent
2019-06-19 07:13:51 -07:00
Van der Auwermeulen Grégoire
3425553dc6 Update WASI-tutorial.md
Update README based on feedback
2019-06-19 07:13:51 -07:00
Van der Auwermeulen Grégoire
15b85dc285 Update WASI-tutorial.md 2019-06-19 07:13:51 -07:00
Jakub Konka
ce8912abf3 Use preopen_dir handlers exposed in wasi-common 2019-06-19 07:12:00 -07:00
Sendil Kumar
ab8f8ef5d8 Adds an explicit way to use the args inside the WebAssembly Module 2019-06-19 07:10:56 -07:00
Jakub Konka
7ac6666fcb Fixes incorrect guest fd encoding
Surfaced when running sunfishcode/misc-tests. When trying to
truncate the file without the __WASI_RIGHT_PATH_FILESTAT_SET_SIZE
right, error __WASI_ENOTCAPABLE was correctly returned, however,
the guest fd pointer was not encoded to -1 in that case. This
commit fixes it by taking out the guest fd encoding out of the
conditional branch which turns out obsolete.
2019-06-19 07:09:46 -07:00
Lars T Hansen
36870c41c8 Fix a calculation error for rodata_size in memsink 2019-06-18 07:14:32 -07:00
Jakub Konka
54a897cf91 Move common functionality into hostcalls mod 2019-06-18 06:00:22 -07:00
Jakub Konka
c113ff32e6 Move preopen_dir handlers from wasmtime to wasi-common 2019-06-17 02:40:42 -07:00
Jef
e2285b543a Fix div (makes the euler example pass!) 2019-06-13 13:24:40 +02:00
Jef
353e6e737b Make not a no-op for condition codes, only emit constants once 2019-06-09 14:55:09 +02:00
Ari Lotter
8dc1d90352 Use try_from replacing cast in wasmtime-runtime. 2019-06-09 12:27:28 +02:00
Ari Lotter
f3f6ab0583 Use try_from replacing cast in wasmtime-wasi-c. 2019-06-09 12:27:28 +02:00
Ari Lotter
1158b5bd6c Use try_from replacing cast in wasmtime-environ.
`try_from` is stable now, so cast is unnecessary.
2019-06-09 12:27:28 +02:00
Lars T Hansen
3b8ab2b5e2 Merge pull request #790 from lars-t-hansen/reloc_jt_fixes
Handle Reloc::X86PCRelRodata4 in sundry reloc_jt
2019-06-09 08:32:51 +02:00
Lars T Hansen
ec5dc3384e Handle Reloc::X86PCRelRodata4 in sundry reloc_jt 2019-06-07 14:37:58 +02:00
julian-seward1
5fb347b7bc Merge pull request #784 from julian-seward1/issue779
Only create copy_nop instructions for types for which an encoding exi…
2019-06-05 15:05:56 +02:00
Julian Seward
b1488decc4 Only create copy_nop instructions for types for which an encoding exists. Issue #779.
PR #773 detects, at reload time, `copy` instructions that copy a value from stack
slot back to the same stack slot.  It replaces them with `copy_nop` instructions
that have a null encoding (hence producing no code).

For x86_64, `copy_nop` encodings for the types I64, I32, F64 and F32 are
provided.  Unfortunately the code that detects the redundant copy doesn't
check the type of the copied value, hence leaving itself open to the danger of
creating a `copy_nop` instruction cannot be encoded (which is different from
saying it has a null encoding).

This patch:

* Expands the x86_64 set of `copy_nop` encodings to: I64 I32 I16 I8 F64 and F32

* Adds encodings for the same for x86_32, rv64 and rv32.

* In `visit_inst()` in `reload.rs`, checks the type of the copied value accordingly.

* Adds comments explaining the above.
2019-06-05 13:06:22 +02:00
Jakub Konka
e530a582af Fix preopening dirs on Windows 2019-06-03 13:23:07 -07:00
Dan Gohman
635be8a032 Make the wasmtime-wasi-c dependency conditional on Unix. 2019-06-03 13:23:07 -07:00
Dan Gohman
06b6ec42b9 Provide the C WASI implementation as an option.
This adds the C WASI implementation as a new crate, wasmtime-wasi-c,
and adds a command-line flag to the wasmtime command-line driver to
select which WASI implementation to use.
2019-06-03 13:23:07 -07:00
Jakub Konka
d57fbc7d0c Sync with wasi-common 2019-06-03 13:23:07 -07:00
Jakub Konka
e44d8e8fe3 Update min rustc to 1.34 as required by wasi-common 2019-06-03 13:23:07 -07:00
Jakub Konka
e8142f076d Migrate to wasi-common crate 2019-06-03 13:23:07 -07:00
Dan Gohman
23055196fc Bump the minimum required Rust version to 1.34.
1.34 was [released] on April 11, so it satisfies the stable Rust
[policy].

Notably, this version includes the new `try_from` features.

[released]: https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html
[policy]: https://github.com/CraneStation/cranelift/blob/master/CONTRIBUTING.md#rustc-version-support
2019-06-03 12:40:58 +02:00
Dan Gohman
da1baf7481 Use try_from instead of the cast crate.
Now that `try_from` is in stable Rust, we can use it here.
2019-06-03 12:40:58 +02:00
Dan Gohman
3dfeab50ad Don't add the NULL terminator to argv and environ arrays.
The wasm userspace has been updated to do that instead, in
https://github.com/CraneStation/wasi-sysroot/pull/72.
2019-06-02 08:54:51 +02:00
Lars T Hansen
fbaffa2c04 Merge pull request #774 from lars-t-hansen/jump_tables
Generalize information about compiled code
2019-06-01 12:24:41 +02:00
Dan Gohman
9a66400cd8 Use try_from instead of the cast crate.
`try_from` is newly stable in the standard library starting in Rust 1.34.
2019-05-31 21:09:43 +02:00
Jakub Konka
51fc39e0e6 Backport path_get fix discovered in Win branch 2019-05-31 20:32:42 +02:00
Dan Gohman
61eb4738fe wasi-sysroot is now named wasi-libc. (#167) 2019-05-31 10:15:52 +02:00
Lars T Hansen
420850adf0 Record information about sections of emitted code+data.
The result of the emitter is a vector of bytes holding machine code,
jump tables, and (in the future) other read-only data.  Some clients,
notably Firefox's Wasm compiler, needs to separate the machine code
from the data in order to insert more code directly after the code
generated by Cranelift.

To make such separation possible, we record more information about the
emitted bytes: the sizes of each of the sections of code, jump tables,
and read-only data, as well as the locations within the code that
reference (PC-relatively) the jump tables and read-only data.
2019-05-31 08:39:57 +02:00
Dan Gohman
825f1d764a Fix a compiler warning.
Fix the following warning from Rust 1.35:

warning: cannot borrow `*self` as mutable because it is also borrowed as immutable
   --> wasmtime-runtime/src/instance.rs:473:25
    |
465 |         } else if let Some(start_export) = self.module.exports.get("_start") {
    |                                            ----------- immutable borrow occurs here
...
473 |                         self.invoke_function(*func_index)
    |                         ^^^^                 ----------- immutable borrow later used here
    |                         |
    |                         mutable borrow occurs here
    |
    = note: #[warn(mutable_borrow_reservation_conflict)] on by default
    = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
    = note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
2019-05-30 18:44:38 -07:00
Benjamin Bouvier
70f79d23bf [meta] Make Builders build() instead of finish(); 2019-05-29 14:05:01 +02:00
Benjamin Bouvier
d9277f249b [meta] Introduce the InstructionGroupBuilder;
This follows the rest of the code base data structures, where we have a
mutable data structure builder; once the data structure is constructed,
it's immutable.

This also makes the definition of instructions easier, and it paves the
way for defining immediate variants.
2019-05-29 14:05:01 +02:00
Benjamin Bouvier
feb90e376a [meta] Make Instruction name/doc Strings so they can be automatically generated; 2019-05-29 14:05:01 +02:00
Benjamin Bouvier
22a6823496 [meta] Rename cdsl/inst to cdsl/instructions; 2019-05-29 14:05:01 +02:00
iximeow
6059936113 remove rex-prefixed recipes for e9 and eb jumps
while not incorrect, the prefix has no additional semantics on these
  instructions other than taking an extra byte for the jump
2019-05-29 11:32:44 +02:00
Takanori Ishibashi
f427a2b923 Fix url in comments 2019-05-28 13:29:45 +02:00
Dan Gohman
b5f4949597 Avoid using C features which depends on _Generic. 2019-05-27 10:13:33 -07:00
Dan Gohman
1882fc41bb Build sandboxed-system-primitives with -std=gnu99. 2019-05-27 09:14:29 -07:00
Dan Gohman
f486d61629 Make use of static_assert conditional on whether it's available. 2019-05-27 09:07:04 -07:00
Julian Seward
03368895fe Cranelift: Redundant stack-slot-to-stack-slot copy removal. PR#773.
This is also https://bugzilla.mozilla.org/show_bug.cgi?id=1552737.

Cranelift currently has a tendency to create redundant copies (self-copies) of
values from a stack slot back to the same stack slot.  This generates a
pointless load and store and an unnecessary register use.  The copies are
created by `visit_inst` in regalloc/reload.rs.  They appear to occur mostly,
but not exclusively, at loop heads.  It's unclear why this happens.

This patch adds a special case to `visit_inst` to find such copies.  They are
converted into a new instruction, `copy_nop`, which takes and produces the
same SSA names, so as not to break any of the SSA invariants, but which has a
zero-length encoding, hence removing the copy at emission time.

`copy_nop`s source and destination operands must be stack slots and of course
the *same* stack slot.  The verifier has been enhanced to check this, since
misuse of `copy_nop` will likely lead to hard-to-find incorrect-code bugs.

Attempts were made to write a standalone .clif test case.  But these failed
because it appears the .clif parser accepts but ignores location hints that
are stack slots.  So it's impossible to write, in clif, the exact form of
`copy` instruction that triggers the transformation.
2019-05-27 13:55:48 +02:00
Dan Gohman
176538b860 Support GCC and clang versions that lack <stdatomic.h>.
Add a code path to use the GCC builtins for atomics, which are supported
in older compiler versions, rather than the new <stdatomic.h>.
2019-05-27 07:48:18 +02:00
Jakub Konka
0143ed548d Update README 2019-05-24 11:02:03 -07:00