* 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
50 lines
1.8 KiB
Rust
50 lines
1.8 KiB
Rust
/// Tunable parameters for WebAssembly compilation.
|
|
#[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,
|
|
|
|
/// The size in bytes of the offset guard for static heaps.
|
|
pub static_memory_offset_guard_size: u64,
|
|
|
|
/// 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 {
|
|
fn default() -> Self {
|
|
Self {
|
|
#[cfg(target_pointer_width = "32")]
|
|
/// Size in wasm pages of the bound for static memories.
|
|
static_memory_bound: 0x4000,
|
|
#[cfg(target_pointer_width = "64")]
|
|
/// Size in wasm pages of the bound for static memories.
|
|
///
|
|
/// When we allocate 4 GiB of address space, we can avoid the
|
|
/// need for explicit bounds checks.
|
|
static_memory_bound: 0x1_0000,
|
|
|
|
#[cfg(target_pointer_width = "32")]
|
|
/// Size in bytes of the offset guard for static memories.
|
|
static_memory_offset_guard_size: 0x1_0000,
|
|
#[cfg(target_pointer_width = "64")]
|
|
/// Size in bytes of the offset guard for static memories.
|
|
///
|
|
/// Allocating 2 GiB of address space lets us translate wasm
|
|
/// offsets into x86 offsets as aggressively as we can.
|
|
static_memory_offset_guard_size: 0x8000_0000,
|
|
|
|
/// Size in bytes of the offset guard for dynamic memories.
|
|
///
|
|
/// Allocate a small guard to optimize common cases but without
|
|
/// wasting too much memor.
|
|
dynamic_memory_offset_guard_size: 0x1_0000,
|
|
|
|
debug_info: false,
|
|
}
|
|
}
|
|
}
|