Move address maps to a section of the compiled image (#3240)
This commit moves the `address_map` field of `FunctionInfo` into a custom-encoded section of the executable. The goal of this commit is, as previous commits, to push less data through `bincode`. The `address_map` field is actually extremely large and has huge benefits of not being decoded when we load a module. This data is only used for traps and such as well, so it's not overly important that it's massaged in to precise data the runtime can extremely speedily use. The `FunctionInfo` type does retain a tiny bit of information about the function itself (it's start source location), but other than that the `FunctionAddressMap` structure is moved from `wasmtime-environ` to `wasmtime-cranelift` since it's now no longer needed outside of that context.
This commit is contained in:
@@ -94,7 +94,7 @@ use cranelift_codegen::isa::{unwind::UnwindInfo, CallConv, TargetIsa};
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmFuncType, WasmType};
|
||||
use target_lexicon::CallingConvention;
|
||||
use wasmtime_environ::{FunctionInfo, Module, TypeTables};
|
||||
use wasmtime_environ::{FilePos, FunctionInfo, InstructionAddressMap, Module, TypeTables};
|
||||
|
||||
pub use builder::builder;
|
||||
|
||||
@@ -118,6 +118,10 @@ pub struct CompiledFunction {
|
||||
/// The unwind information.
|
||||
unwind_info: Option<UnwindInfo>,
|
||||
|
||||
/// Information used to translate from binary offsets back to the original
|
||||
/// location found in the wasm input.
|
||||
address_map: FunctionAddressMap,
|
||||
|
||||
relocations: Vec<Relocation>,
|
||||
value_labels_ranges: cranelift_codegen::ValueLabelsRanges,
|
||||
stack_slots: ir::StackSlots,
|
||||
@@ -125,6 +129,32 @@ pub struct CompiledFunction {
|
||||
info: FunctionInfo,
|
||||
}
|
||||
|
||||
/// Function and its instructions addresses mappings.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
struct FunctionAddressMap {
|
||||
/// An array of data for the instructions in this function, indicating where
|
||||
/// each instruction maps back to in the original function.
|
||||
///
|
||||
/// This array is sorted least-to-greatest by the `code_offset` field.
|
||||
/// Additionally the span of each `InstructionAddressMap` is implicitly the
|
||||
/// gap between it and the next item in the array.
|
||||
instructions: Box<[InstructionAddressMap]>,
|
||||
|
||||
/// Function's initial offset in the source file, specified in bytes from
|
||||
/// the front of the file.
|
||||
start_srcloc: FilePos,
|
||||
|
||||
/// Function's end offset in the source file, specified in bytes from
|
||||
/// the front of the file.
|
||||
end_srcloc: FilePos,
|
||||
|
||||
/// Generated function body offset if applicable, otherwise 0.
|
||||
body_offset: usize,
|
||||
|
||||
/// Generated function body length.
|
||||
body_len: u32,
|
||||
}
|
||||
|
||||
/// A record of a relocation to perform.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
struct Relocation {
|
||||
|
||||
Reference in New Issue
Block a user