wasmtime: Pass around more contexts instead of fields (#1486)

* wasmtime: Pass around more contexts instead of fields

This commit refactors some wasmtime internals to pass around more
context-style structures rather than individual fields of each
structure. The intention here is to make the addition of fields to a
structure easier to plumb throughout the internals of wasmtime.
Currently you need to edit lots of functions to pass lots of parameters,
but ideally after this you'll only need to edit one or two struct fields
and then relevant locations have access to the information already.

Updates in this commit are:

* `debug_info` configuration is now folded into `Tunables`. Additionally
  a `wasmtime::Config` now holds a `Tunables` directly and is passed
  into an internal `Compiler`. Eventually this should allow for direct
  configuration of the `Tunables` attributes from the `wasmtime` API,
  but no new configuration is exposed at this time.

* `ModuleTranslation` is now passed around as a whole rather than
  passing individual components to allow access to all the fields,
  including `Tunables`.

This was motivated by investigating what it would take to optionally
allow loops and such to get interrupted, but that sort of codegen
setting was currently relatively difficult to plumb all the way through
and now it's hoped to be largely just an addition to `Tunables`.

* Fix lightbeam compile
This commit is contained in:
Alex Crichton
2020-04-08 19:02:49 -05:00
committed by GitHub
parent e29c224f24
commit c4e90f729c
14 changed files with 112 additions and 180 deletions

View File

@@ -1,5 +1,5 @@
/// Tunable parameters for WebAssembly compilation.
#[derive(Clone)]
#[derive(Clone, Hash)]
pub struct Tunables {
/// For static heaps, the size in wasm pages of the heap protected by bounds checking.
pub static_memory_bound: u32,
@@ -9,6 +9,9 @@ pub struct Tunables {
/// The size in bytes of the offset guard for dynamic heaps.
pub dynamic_memory_offset_guard_size: u64,
/// Whether or not to generate DWARF debug information.
pub debug_info: bool,
}
impl Default for Tunables {
@@ -39,6 +42,8 @@ impl Default for Tunables {
/// Allocate a small guard to optimize common cases but without
/// wasting too much memor.
dynamic_memory_offset_guard_size: 0x1_0000,
debug_info: false,
}
}
}