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:
@@ -1,11 +1,9 @@
|
||||
use crate::CompiledFunctions;
|
||||
use crate::{CompiledFunctions, FunctionAddressMap};
|
||||
use gimli::write;
|
||||
use more_asserts::assert_le;
|
||||
use std::collections::BTreeMap;
|
||||
use std::iter::FromIterator;
|
||||
use wasmtime_environ::{
|
||||
DefinedFuncIndex, EntityRef, FilePos, FunctionAddressMap, PrimaryMap, WasmFileInfo,
|
||||
};
|
||||
use wasmtime_environ::{DefinedFuncIndex, EntityRef, FilePos, PrimaryMap, WasmFileInfo};
|
||||
|
||||
pub type GeneratedAddress = usize;
|
||||
pub type WasmAddress = u64;
|
||||
@@ -199,7 +197,7 @@ fn build_function_addr_map(
|
||||
) -> PrimaryMap<DefinedFuncIndex, FunctionMap> {
|
||||
let mut map = PrimaryMap::new();
|
||||
for (_, f) in funcs {
|
||||
let ft = &f.info.address_map;
|
||||
let ft = &f.address_map;
|
||||
let mut fn_map = Vec::new();
|
||||
for t in ft.instructions.iter() {
|
||||
if t.srcloc.file_offset().is_none() {
|
||||
@@ -460,7 +458,7 @@ impl AddressTransform {
|
||||
|
||||
let mut func = BTreeMap::new();
|
||||
for (i, f) in funcs {
|
||||
let ft = &f.info.address_map;
|
||||
let ft = &f.address_map;
|
||||
let (fn_start, fn_end, lookup) = build_function_lookup(ft, code_section_offset);
|
||||
|
||||
func.insert(
|
||||
@@ -611,14 +609,12 @@ impl AddressTransform {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{build_function_lookup, get_wasm_code_offset, AddressTransform};
|
||||
use crate::{CompiledFunction, CompiledFunctions};
|
||||
use crate::{CompiledFunction, CompiledFunctions, FunctionAddressMap};
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use gimli::write::Address;
|
||||
use std::iter::FromIterator;
|
||||
use std::mem;
|
||||
use wasmtime_environ::{
|
||||
FilePos, FunctionAddressMap, FunctionInfo, InstructionAddressMap, WasmFileInfo,
|
||||
};
|
||||
use wasmtime_environ::{FilePos, InstructionAddressMap, WasmFileInfo};
|
||||
|
||||
#[test]
|
||||
fn test_get_wasm_code_offset() {
|
||||
@@ -660,10 +656,7 @@ mod tests {
|
||||
|
||||
fn create_simple_module(address_map: FunctionAddressMap) -> CompiledFunctions {
|
||||
PrimaryMap::from_iter(vec![CompiledFunction {
|
||||
info: FunctionInfo {
|
||||
address_map,
|
||||
..Default::default()
|
||||
},
|
||||
address_map,
|
||||
..Default::default()
|
||||
}])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user