Commit Graph

7943 Commits

Author SHA1 Message Date
Pat Hickey
e498888732 hook run command up to both wasi snapshots
sharing the same context! at long last
2021-01-29 12:29:30 -08:00
Pat Hickey
70f8288ec9 wasmtime-wiggle: take an Rc<RefCell<ctx>> instead of construct one
so that if users wish to share a ctx between modules they may!
2021-01-29 12:18:21 -08:00
Pat Hickey
c8e76b11ba wasmtime-wasi: support both snapshots 2021-01-29 12:11:38 -08:00
Pat Hickey
d738a4a588 preview 0: copy bodies of read, write, and poll_oneoff from snapshot 1 2021-01-29 12:07:21 -08:00
Nick Fitzgerald
a4eaefc670 Merge pull request #2623 from alexcrichton/update-some-deps
Update some wasm-tools dependencies
2021-01-29 10:53:18 -08:00
Benjamin Bouvier
2275519cb1 cranelift x64: use the POPCNT instruction for Popcount when it's available; 2021-01-29 19:41:01 +01:00
Benjamin Bouvier
6bf6612d96 cranelift x64: use the TZCNT instruction for Ctz when it's available; 2021-01-29 19:41:01 +01:00
Benjamin Bouvier
d3acd9a283 cranelift x64: use the LZCNT instruction for Clz when it's available; 2021-01-29 19:41:01 +01:00
Alex Crichton
f1d922dc2d Update some wasm-tools dependencies
Mostly focused around some small bugfixes and improvements related to
module-linking fuzzing.
2021-01-29 10:04:36 -08:00
Chris Fallin
b1b078e2bc Merge pull request #2621 from kaseyc/nop
Replace MachInst::gen_zero_len_nop with gen_nop(0)
2021-01-29 09:01:36 -08:00
Alex Crichton
0e41861662 Implement limiting WebAssembly execution with fuel (#2611)
* Consume fuel during function execution

This commit adds codegen infrastructure necessary to instrument wasm
code to consume fuel as it executes. Currently nothing is really done
with the fuel, but that'll come in later commits.

The focus of this commit is to implement the codegen infrastructure
necessary to consume fuel and account for fuel consumed correctly.

* Periodically check remaining fuel in wasm JIT code

This commit enables wasm code to periodically check to see if fuel has
run out. When fuel runs out an intrinsic is called which can do what it
needs to do in the result of fuel running out. For now a trap is thrown
to have at least some semantics in synchronous stores, but another
planned use for this feature is for asynchronous stores to periodically
yield back to the host based on fuel running out.

Checks for remaining fuel happen in the same locations as interrupt
checks, which is to say the start of the function as well as loop
headers.

* Improve codegen by caching `*const VMInterrupts`

The location of the shared interrupt value and fuel value is through a
double-indirection on the vmctx (load through the vmctx and then load
through that pointer). The second pointer in this chain, however, never
changes, so we can alter codegen to account for this and remove some
extraneous load instructions and hopefully reduce some register
pressure even maybe.

* Add tests fuel can abort infinite loops

* More fuzzing with fuel

Use fuel to time out modules in addition to time, using fuzz input to
figure out which.

* Update docs on trapping instructions

* Fix doc links

* Fix a fuzz test

* Change setting fuel to adding fuel

* Fix a doc link

* Squelch some rustdoc warnings
2021-01-29 08:57:17 -06:00
Amanieu d'Antras
78f312799e Optimize EntityList::extend and add EntityList::from_iter 2021-01-29 14:09:52 +01:00
Kasey Carrothers
99be82c866 Replace MachInst::gen_zero_len_nop with gen_nop(0) 2021-01-29 01:15:08 -08:00
Chris Fallin
ac60ad6c9a Merge pull request #2614 from kaseyc/nop
Avoid creating 0-sized nops in x64's gen_nop().
2021-01-28 21:37:39 -08:00
Kasey Carrothers
f76a9d436e Clean up handling of NOPs in the x64 backend.
1. Restricts max nop size to 15 instead of 16.
2. Fixes an edge case where gen_nop() would return a zero sized intruction on multiples of 16.
3. Clarifies the documentation of the gen_nop interface to state that returning zero is allowed when preferred_size is zero.
2021-01-28 20:45:00 -08:00
Johnnie Birch
cbd7a6a80e Add sse41 lowering for rounding x64 2021-01-28 17:37:17 -08:00
Pat Hickey
ef2cb7b6b7 nearly have snapshot 0 implemented... 2021-01-28 17:00:31 -08:00
Pat Hickey
9bd89abc0c rename everything c2 related to the "real" names 2021-01-28 15:34:03 -08:00
Pat Hickey
47fec44c10 move wasi-c2 into wasi-common 2021-01-28 15:15:50 -08:00
Pat Hickey
dd005208b6 delete wasi-common, yanix, winx 2021-01-28 15:13:45 -08:00
Pat Hickey
d628677fae move test failures into ignores in build.rs 2021-01-28 15:07:48 -08:00
Pat Hickey
1d057af64d notes 2021-01-28 13:20:52 -08:00
Pat Hickey
201a888d92 dirty fuckin' dangles boys
fuck you shorsey
2021-01-28 13:02:48 -08:00
Pat Hickey
11b8222033 missed a dangling symlink 2021-01-28 12:59:44 -08:00
Pat Hickey
34ad8df169 dangling directories are a windows thing 2021-01-28 12:58:41 -08:00
Pat Hickey
4801ea04a1 cool 2021-01-28 12:36:50 -08:00
Pat Hickey
0cedc17246 another one bites the dust 2021-01-28 12:35:13 -08:00
Pat Hickey
79e8f17486 bum bum bum 2021-01-28 12:30:37 -08:00
Pat Hickey
dae022b17f woo 2021-01-28 12:29:30 -08:00
Pat Hickey
1196e216e9 fix macro by denying trailing slashes. also other stuff 2021-01-28 12:23:48 -08:00
Pat Hickey
20e9169cc7 fd_allocate: put meat of test behind a guard 2021-01-28 11:43:42 -08:00
Nick Fitzgerald
d1c1cb6a25 bench-api: receive working directory as an argument
Rather than implicitly use the current working directory.
2021-01-28 11:43:06 -08:00
Pat Hickey
f7403acb6f fd_advise test: set size via fd_filestat_set_size and fd_allocate 2021-01-28 11:42:30 -08:00
Pat Hickey
e758318fee wire env variables through test runner to TESTCONFIG 2021-01-28 11:34:18 -08:00
Pat Hickey
bbbe168ca1 ctx: i guess we need environment variables! 2021-01-28 11:34:00 -08:00
Pat Hickey
7ffe3c72c5 config is lazy_static to amoritze it 2021-01-28 11:20:02 -08:00
Nick Fitzgerald
be1ac15beb Merge pull request #2617 from alexcrichton/limit-tables-and-memeories
Add knobs to limit memories/tables in a `Store`
2021-01-28 10:20:33 -08:00
Nick Fitzgerald
6537e81a36 Merge pull request #2616 from alexcrichton/fix-module-linking-fuzzing
Disable module-linking in plain instantiate fuzzers
2021-01-28 10:17:04 -08:00
Pat Hickey
6f85abd949 itsp ublished 2021-01-28 09:44:17 -08:00
Chris Fallin
19d800f975 Merge pull request #2615 from alexcrichton/precise-pc-trap
Only handle signals at pcs with trap information
2021-01-28 09:19:30 -08:00
Alex Crichton
dccaa64962 Add knobs to limit memories/tables in a Store
Fuzzing has turned up that module linking can create large amounts of
tables and memories in addition to instances. For example if N instances
are allowed and M tables are allowed per-instance, then currently
wasmtime allows MxN tables (which is quite a lot). This is causing some
wasm-smith-generated modules to exceed resource limits while fuzzing!

This commits adds corresponding `max_tables` and `max_memories`
functions to sit alongside the `max_instances` configuration.
Additionally fuzzing now by default configures all of these to a
somewhat low value to avoid too much resource usage while fuzzing.
2021-01-28 08:47:00 -08:00
Alex Crichton
cb65c755c5 Disable module-linking in plain instantiate fuzzers
We already cover module linking with the `instantiate-swarm` target and
otherwise enabling module linking is preventing otherwise-valid modules
from being compiled because of the breaking change in the module linking
proposal with respect to imports.
2021-01-28 07:55:04 -08:00
Alex Crichton
39f677d2dd Only handle signals at pcs with trap information
Previously wasmtime would handle any signal originating from wasm JIT
code. This would, however, handle bugs in JIT code as-if they were wasm
traps. Instead this commit switches signal handling to specifically
check for whether the precise program counter is expected to be a trap.
This way if a program counter traps and it's not expected to trap the
signal isn't handled and the process is aborted (presumably leading to
further debugging of whomever happens to work on the JIT at that time).
2021-01-28 07:44:06 -08:00
Pat Hickey
03466d04ce temporarily use my branch of the wasi crate 2021-01-27 19:05:52 -08:00
Pat Hickey
be108c7a93 will this work for platform-specific errnos? WIP 2021-01-27 18:18:12 -08:00
Pat Hickey
2ae1dee642 convert all errno assertions to assert_errno! 2021-01-27 18:10:38 -08:00
Pat Hickey
4f655001c0 make a macro that automates errno assertions 2021-01-27 18:10:34 -08:00
Pat Hickey
4f2696fedf more docs 2021-01-27 16:16:10 -08:00
Pat Hickey
cb171712cc various windows test notes 2021-01-27 15:32:23 -08:00
Pat Hickey
d1160cb9b5 split path rename trailing slash test into files and dirs
files fail on both platform, dirs pass on both! so, same bug!
2021-01-27 14:55:39 -08:00