Commit Graph

65 Commits

Author SHA1 Message Date
Dan Gohman
d9b4bd1de8 Support imports. 2018-12-06 23:02:19 -05:00
Dan Gohman
8170a9db79 Update to the rustfmt in rust 1.31, which is now stable. 2018-12-06 22:59:46 -05:00
Dan Gohman
96941a59af Implement call_indirect signature checking.
The call_indirect.wast spec test now passes.
2018-12-05 11:32:35 -05:00
Dan Gohman
57635eb62b Implement minimal call_indirect signature checking. 2018-12-05 11:32:28 -05:00
Dan Gohman
0a2ecf5a1e On Darwin, guard page accesses are raised as SIGBUS. 2018-12-05 02:25:34 -05:00
Dan Gohman
cfd28a7bc5 Temporarily disable use of Mach ports for trap handling on Darwin. 2018-12-05 02:25:34 -05:00
Dan Gohman
7faa15d7ac More infrastructure.
Improve handling of memory.grow/size, add a standalone wast runner,
test harness improvements.
2018-12-05 02:25:34 -05:00
Dan Gohman
83f8a31010 Convert the wast test harness into a crate.
This uses a build.rs file to collect all the wast tests and create
individual `#[test]` lines for them, so that `cargo test` can run them
in parallel.
2018-12-05 02:25:34 -05:00
Dan Gohman
4c47ce9b53 Add support for math libcalls. 2018-12-05 02:25:34 -05:00
Dan Gohman
bd69768e0d Improve infrastructure.
Do more encapsulation of raw pointers, use more PrimaryMaps instead of
Vecs, add a table.rs for managing table storage.
2018-12-05 02:25:34 -05:00
Dan Gohman
fe1643733b Remove use of offset_of! from wasmtime-environ.
wasmtime-environ is meant to support cross compilation, so it shouldn't
have dependencies on target layout of structs. This moves the layout
back into wasmtime-execute, and adds a system of asserts for checking
that wasmtime-environ's offsets stay in sync.
2018-12-05 02:25:34 -05:00
Dan Gohman
8dbd4b8d7c Start a wast testing harness and add some tests.
This implements a minimal wast testing harness in tests/wast.rs, which
runs the wast tests under tests/wast.

It also adds tests for trapping in a variety of ways, and fixes several
bugs exposed by those tests.
2018-12-05 02:25:34 -05:00
Dan Gohman
a6b54330c0 Switch Darwin to use PC-redirection for calling the Unwind function. 2018-12-05 02:25:34 -05:00
Dan Gohman
872f7a10f4 Use MAP_ANON instead of MAP_ANONYMOUS. 2018-12-05 02:25:34 -05:00
Dan Gohman
f44fe25f9c Rewrite linear memory handling in terms of simple mmap/VirtualAlloc.
The memmap crate doesn't make it straightforward to have part of the
region be writeable and part readonly. Since this is a fairly boutique
use case, and we don't need all that much code, just use the low-level
APIs directly.

Also, introduce a concept of "tunables" for adjusting the parameters of
the runtime.
2018-12-05 02:25:34 -05:00
Dan Gohman
02a3684a3f Update to bindgen 0.44. 2018-11-30 09:24:33 -08:00
Dan Gohman
b7d43edfd3 Be more careful about integer overflow when computing relocs. 2018-11-29 10:28:18 -08:00
Dan Gohman
f7dc961d2c Fix some clippy warnings. 2018-11-29 10:27:49 -08:00
Dan Gohman
5ae48b06e1 Fix the pthread_detach assert on Darwin. 2018-11-29 06:22:39 -08:00
Dan Gohman
38acc069fa Fix compilation errors on Darwin. 2018-11-29 06:01:25 -08:00
Dan Gohman
adb76ba9f1 Avoid casting to/from greg_t, which doesn't work consistently across platforms. 2018-11-29 05:59:17 -08:00
Dan Gohman
216c0ce14e Fix the scope of the ScopeGuard in call_wasm. 2018-11-29 05:59:17 -08:00
Dan Gohman
862d859587 Add a LICENSE file to each crate. 2018-11-29 05:57:32 -08:00
Dan Gohman
2a760ae5e8 Add tests that trap, and fix handling of SIGFPE on x86. 2018-11-27 06:38:28 -08:00
Dan Gohman
35627cf37f Implement wasm trap handlers. (#27)
* Implement wasm trap handlers.

This adds signal handlers based on SpiderMonkey's signal-handler code.
The functionality for looking up the trap code and wasm bytecode offset
isn't yet implemented, but this is a start.

I considered rewriting this code in Rust, but decided against it for now
as C++ allows us to talk to the relevant OS APIs more directly.

Fixes #15.

* Compile with -std=c++11.

* Refactor InstallState initialization.

* Compile with -fPIC.

* Factor out the code for calling a wasm function with a given index.

* Fix unclear wording in a comment.
2018-11-27 06:05:58 -08:00
Geoffroy Couprie
bf5a06bc95 separate the context intialization from the function execution (#21)
the start function is called from the initialization phase
2018-11-27 05:33:56 -08:00
Dan Gohman
95fba6a9de Update to Cranelift 0.25. 2018-11-26 22:50:07 -08:00
Dan Gohman
e8201d0f93 Begin work on no_std support.
This adds no_std support to a bunch of things, but more work is needed.
2018-11-26 04:52:39 -08:00
Dan Gohman
74ccddcd64 Update to Cranelift 0.24. 2018-11-25 05:08:29 -08:00
Dan Gohman
0a0108f959 Update to Cranelift 0.22. 2018-11-25 05:08:29 -08:00
Geoffroy Couprie
7fca0792dd add a way to provide imported functions during relocation
They are provided as a closure taking the module (&str) and function name (&str) as arguments,
returning an address (Option<isize>)
2018-11-16 09:56:36 -08:00
Dan Gohman
5a96e022db Update to the rustfmt in rust 1.29, which is now stable. 2018-10-09 14:36:48 -07:00
Dan Gohman
ecae909b9e Add the "wasm" category in Cargo.toml files. 2018-08-28 21:03:07 -07:00
Dan Gohman
fb7153ccf4 Update to cranelift 0.20.0.
The biggest change is the split from FunctionIndex to
DefinedFuncIndex to FuncIndex. Take better advantage of this by
converting several Vecs to PrimaryMaps.

Also, table_addr can now handle indices of the table index type,
so we don't need to explicitly uextend them anymore.
2018-08-28 20:56:58 -07:00
Dan Gohman
c5f0cd7d5e Enforce the wasm memory size limit on heaps with no maximum. 2018-08-28 16:54:28 -07:00
Dan Gohman
f2ad79963c Add a comment about "dynamic" heaps. 2018-08-28 16:54:28 -07:00
Dan Gohman
d3fcb596b3 Support multiple memory spaces. 2018-08-28 16:54:28 -07:00
Dan Gohman
c12ae182c3 Enforce the linear-memory maximum size.
Also, support linear memories with no maximum, and dynamic remapping.
2018-08-28 16:54:28 -07:00
Sergey Pepyakin
7b222190f5 Implement tables and call_indirect (#12)
* Implement tables and call_indirect

* Restore comment about sig checking.

* Widen callee index on 64bit platforms.
2018-08-15 16:25:49 -07:00
Sergey Pepyakin
e7c8d23a42 Implement memory.grow and memory.current (#9)
* Implement.

* Clean and doc

* Collect base addresses instead of leaking them

* Fix code for 1.25.

* Simplify $assert

* Use AbiParam::special.

* Use &mut self in base_addr
2018-08-11 06:52:43 -07:00
Dan Gohman
40791787c7 Update repository URLs. 2018-08-03 15:37:30 -07:00
Dan Gohman
548c45c604 Rename wasmtime-runtime to wasmtime-environ.
This mirrors changes in cranelift.
2018-08-03 15:20:19 -07:00
Dan Gohman
ef5254c0da More code reorganization and cleanups. 2018-08-03 15:06:59 -07:00
Dan Gohman
831b481f13 More code reorganization. 2018-08-03 14:18:23 -07:00
Dan Gohman
6659ef7018 More code reorganization. 2018-08-03 13:35:25 -07:00
Dan Gohman
753d650f1a Update to cranelift 0.18.1. 2018-08-02 20:50:28 -07:00
Dan Gohman
dd3a9dab6e Make an initial pass through clippy warnings. 2018-07-21 06:46:53 -07:00
Dan Gohman
f3a6cab472 Make package names consistent with cranelift's. 2018-07-21 06:46:37 -07:00
Dan Gohman
2608dd0c47 Update to cranelift 0.16.1, target-lexicon 0.0.3, faerie 0.4.4. 2018-07-21 06:46:19 -07:00
Dan Gohman
7a26b76521 Change the license to "Apache-2.0 WITH LLVM-exception". 2018-07-21 06:46:02 -07:00