wasmer_compiler/address_map.rs
1//! Data structures to provide transformation of the source
2// addresses of a WebAssembly module into the native code.
3
4use crate::lib::std::vec::Vec;
5use crate::sourceloc::SourceLoc;
6
7/// Single source location to generated address mapping.
8#[derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive, Debug, Clone, PartialEq, Eq)]
9pub struct InstructionAddressMap {
10 /// Original source location.
11 pub srcloc: SourceLoc,
12
13 /// Generated instructions offset.
14 pub code_offset: usize,
15
16 /// Generated instructions length.
17 pub code_len: usize,
18}
19
20/// Function and its instructions addresses mappings.
21#[derive(
22 rkyv::Serialize, rkyv::Deserialize, rkyv::Archive, Debug, Clone, PartialEq, Eq, Default,
23)]
24pub struct FunctionAddressMap {
25 /// Instructions maps.
26 /// The array is sorted by the InstructionAddressMap::code_offset field.
27 pub instructions: Vec<InstructionAddressMap>,
28
29 /// Function start source location (normally declaration).
30 pub start_srcloc: SourceLoc,
31
32 /// Function end source location.
33 pub end_srcloc: SourceLoc,
34
35 /// Generated function body offset if applicable, otherwise 0.
36 pub body_offset: usize,
37
38 /// Generated function body length.
39 pub body_len: usize,
40}