Commit Graph

2007 Commits

Author SHA1 Message Date
Dan Gohman
00a4e93bcd Add a concept of "global exports".
This adds a feature which allows one to look up an export by name
without knowing what module it's in -- `lookup_global_export` on an
`InstanceContents`.

The main expected use for this is to support APIs where module A
imports a function from module B, and module B needs to access module
A's memory. B can't import it from A in the normal way, because that
would create a dependency cycle. So for now, allow B to look up A's
exported memory dynamically with `lookup_global_export`.

In the future, with reference types and possibly host bindings, we'll be
able to pass references to memory as arguments, which will obviate the
need for this mechanism.
2019-01-22 16:32:07 -08:00
Dan Gohman
dae04be948 Switch from hashmap_core to hashbrown.
As suggested
[here](https://github.com/Amanieu/hashmap_core/pull/10#issuecomment-455866083).

This also allows us to re-enable the basic compile fuzz target.
2019-01-22 13:41:04 -08:00
Dan Gohman
8769febdbd Formest with latest stable rustfmt. 2019-01-20 10:42:50 -08:00
Jef
26cb8de303 Only generate a single trap to reduce code size and complexity in call_indirect 2019-01-18 16:59:29 +01:00
Jef
2c8efa32b8 Unnecessarily optimise asm_println 2019-01-18 14:03:23 +01:00
Jef
c7956dbdb2 Fail if we try to call past the end of the table 2019-01-18 14:01:12 +01:00
Jef
b6e29a899e Add todo comments 2019-01-18 13:07:41 +01:00
Jef
b23e00893c Fix saving volatile registers now that we use unused args as scratch 2019-01-18 13:04:53 +01:00
Jef
e57cec3b3f Do call_indirect properly, by accessing the table section 2019-01-18 13:01:42 +01:00
Jef
d06be92a4e Don't allocate context if it's unused 2019-01-17 14:34:34 +01:00
Jef
e0f032a0e5 clz/ctz/popcnt 2019-01-17 13:51:18 +01:00
Jef
74d168ec4b Merge ends, store locals in registers where possible 2019-01-17 11:07:51 +01:00
Jef
a7fa7da7d4 Support a proper vmctx that contains more than just memory offset 2019-01-16 16:34:24 +01:00
Jef
d7434fe5d2 Have vmctx be the first argument so we (almost) never have to shuffle it around 2019-01-16 09:33:46 +01:00
Jef
b86d11e4ad Avoid unnecessary work when passing arguments on 2019-01-15 17:24:30 +01:00
Jef
62fe065e85 Fix miscompilation for maliciously-crafted use of locals 2019-01-15 14:00:43 +01:00
Jef
45b2a5dae2 Merge remote-tracking branch 'forked/master' into loops 2019-01-15 12:59:55 +01:00
Jef
1b6952bb99 Implement vmctx as a hidden argument for cranelift compat 2019-01-15 12:27:55 +01:00
buckle2000
01ed463c7a Change SignalHandlers.h to SignalHandlers.hpp 2019-01-14 21:30:25 -08:00
Jef
8312730377 Make calling functions safe 2019-01-14 18:45:14 +01:00
Jef
1eebc65c9e First baby steps to supporting memory accesses
Currently we don't actually sandbox the memory at all, so you can do evil things
like read and write the host's memory. We also don't support growing memory or
cranelift-compatible ABI that passes the memory offset as an argument.

We also always immediately allocate the buffer when encountering a memory section,
there is preliminary support for translating a buffer which can then have the real
offset replaced using relocations (and returning a different type when doing so)
but I haven't written the code that actually does relocation so it doesn't work yet.
2019-01-11 15:20:32 +01:00
Dan Gohman
9fe08c9341 Tidy up pointer casting to avoid casts that change mutability. 2019-01-08 10:31:58 -08:00
Jef
ddb4c0fd19 x64 sign-extends imm32 arguments, so don't truncate them in an unsigned way 2019-01-08 11:10:59 +01:00
Jef
010f2d8569 Fix comparisons, add more tests for binops 2019-01-08 09:45:39 +01:00
Jef
fcd18746a7 Add 64-bit operations 2019-01-07 19:17:29 +01:00
Dan Gohman
0a2b0ee9b0 Mmap API tidying.
Establish more clear expectations for who is expected to page-align what
and when.
2019-01-06 10:08:40 -08:00
Dan Gohman
0826e32c9a Tidy up unnecessary return statements. 2019-01-05 16:23:04 -08:00
Dan Gohman
3143e22566 Move the creation of linear-memory guard pages into the mmap module.
Create linear-memory pages as PROT_NONE and then make them accessible on
demand.
2019-01-05 16:23:04 -08:00
Dan Gohman
3ac4269dc5 Add host_state() accessors to InstanceContents and VMContext too. 2019-01-04 17:24:14 -08:00
Dan Gohman
73b2c45313 Add a host_state field to Instance.
This allows hosts to embed arbitrary state along with instances.
2019-01-04 17:15:22 -08:00
Dan Gohman
3aef763046 Delete an unneeded comment. 2019-01-03 15:50:04 -08:00
Dan Gohman
6661228c86 Tidy up whitespace. 2019-01-03 14:44:30 -08:00
Dan Gohman
e876f0fb1d Add some Cargo.toml keywords. 2019-01-03 14:25:33 -08:00
Dan Gohman
35d7f78a11 Handle errors cleanly in the wast runner. 2019-01-03 14:16:48 -08:00
Dan Gohman
40acc1f340 Add crate version identifiers. 2019-01-03 14:16:48 -08:00
Dan Gohman
585bdac91e Use vec![0; size] instead of creating an empty Vec and resizing. 2019-01-03 14:16:48 -08:00
Dan Gohman
a41bc1fe1e Fix unused use warnings. 2019-01-03 14:16:48 -08:00
Dan Gohman
ca2fdc5ccb Update no_std support.
This `no_std` support isn't complete though, as some dependencies
don't support it.
2019-01-03 14:16:48 -08:00
Dan Gohman
f6c2fe7d2d Update to Rust 2018 Edition. 2019-01-03 12:58:11 -08:00
Dan Gohman
00a84672f7 Use Vec::with_capacity. 2019-01-03 12:37:14 -08:00
Dan Gohman
fdc66e130f Eliminate unneeded casts. 2019-01-03 12:05:32 -08:00
Dan Gohman
39770ec72c Minor code tidying. 2019-01-03 12:05:26 -08:00
Dan Gohman
701b1998e9 Avoid creating slices with null pointers. 2019-01-03 12:05:17 -08:00
Dan Gohman
57e183f5f8 Use TablePlan::for_table and MemoryPlan::for_memory instead of manual code. 2019-01-03 12:05:07 -08:00
Dan Gohman
8a5429ce74 Factor out functions for working with table and memory initializers. 2019-01-03 12:04:58 -08:00
Dan Gohman
747dbb23e7 Add fuzz targets for module instantiation. 2019-01-03 12:04:48 -08:00
Dan Gohman
df7724ce2b Update Cargo.toml authors fields. 2019-01-03 12:04:37 -08:00
Dan Gohman
2f04b78ecf Use cast::usize rather than as usize to avoid silent overflow. 2019-01-03 12:04:24 -08:00
Dan Gohman
529de7ca60 Tidy up unneeded '&'s. 2019-01-03 12:03:52 -08:00
Dan Gohman
c66a3c23f3 Tidy up some documentation comments. 2019-01-03 12:03:43 -08:00