Yury Delendik
2019-07-12 15:00:01 -05:00
committed by Dan Gohman
parent 748abd97d6
commit d27d190b74
9 changed files with 46 additions and 38 deletions

View File

@@ -20,7 +20,6 @@ failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false }
indexmap = "1.0.2"
rayon = "1.0"
wasmtime-debug = { path = "../wasmtime-debug", default-features = false }
[features]
default = ["std"]

View File

@@ -0,0 +1,37 @@
//! Data structures to provide transformation of the source
// addresses of a WebAssembly module into the native code.
use cranelift_codegen::ir;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
use std::vec::Vec;
/// Single source location to generated address mapping.
#[derive(Debug, Clone)]
pub struct InstructionAddressMap {
/// Original source location.
pub srcloc: ir::SourceLoc,
/// Generated instructions offset.
pub code_offset: usize,
/// Generated instructions length.
pub code_len: usize,
}
/// Function and its instructions addresses mappings.
#[derive(Debug, Clone)]
pub struct FunctionAddressMap {
/// Instructions maps.
/// The array is sorted by the InstructionAddressMap::code_offset field.
pub instructions: Vec<InstructionAddressMap>,
/// Generated function body offset if applicable, otherwise 0.
pub body_offset: usize,
/// Generated function body length.
pub body_len: usize,
}
/// Module functions addresses mappings.
pub type ModuleAddressMap = PrimaryMap<DefinedFuncIndex, FunctionAddressMap>;

View File

@@ -1,6 +1,7 @@
//! A `Compilation` contains the compiled function bodies for a WebAssembly
//! module.
use crate::address_map::ModuleAddressMap;
use crate::module;
use crate::module_environ::FunctionBodyData;
use cranelift_codegen::{binemit, ir, isa, CodegenError};
@@ -8,7 +9,6 @@ use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError};
use std::ops::Range;
use std::vec::Vec;
use wasmtime_debug::ModuleAddressMap;
/// Compiled machine code: body and jump table offsets.
#[derive(Debug, Clone)]

View File

@@ -1,5 +1,6 @@
//! Support for compiling with Cranelift.
use crate::address_map::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
use crate::compilation::{
CodeAndJTOffsets, Compilation, CompileError, Relocation, RelocationTarget, Relocations,
};
@@ -18,7 +19,6 @@ use cranelift_entity::PrimaryMap;
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use std::vec::Vec;
use wasmtime_debug::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
/// Implementation of a relocation sink that just saves all the information for later
pub struct RelocSink {

View File

@@ -37,6 +37,7 @@ extern crate std;
#[macro_use]
extern crate failure_derive;
mod address_map;
mod compilation;
mod func_environ;
mod module;
@@ -48,6 +49,7 @@ pub mod cranelift;
#[cfg(feature = "lightbeam")]
pub mod lightbeam;
pub use crate::address_map::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
pub use crate::compilation::{
Compilation, CompileError, Compiler, Relocation, RelocationTarget, Relocations,
};