reverse dependency
https://github.com/CraneStation/wasmtime/pull/186#discussion_r302780035
This commit is contained in:
committed by
Dan Gohman
parent
748abd97d6
commit
d27d190b74
@@ -18,6 +18,7 @@ cranelift-codegen = "0.33.0"
|
|||||||
cranelift-entity = "0.33.0"
|
cranelift-entity = "0.33.0"
|
||||||
cranelift-wasm = "0.33.0"
|
cranelift-wasm = "0.33.0"
|
||||||
faerie = "0.10.1"
|
faerie = "0.10.1"
|
||||||
|
wasmtime-environ = { path = "../wasmtime-environ", default-features = false }
|
||||||
target-lexicon = { version = "0.4.0", default-features = false }
|
target-lexicon = { version = "0.4.0", default-features = false }
|
||||||
failure = { version = "0.1.3", default-features = false }
|
failure = { version = "0.1.3", default-features = false }
|
||||||
failure_derive = { version = "0.1.3", default-features = false }
|
failure_derive = { version = "0.1.3", default-features = false }
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use crate::read_debuginfo::WasmFileInfo;
|
use crate::read_debuginfo::WasmFileInfo;
|
||||||
use crate::transform::ModuleAddressMap;
|
|
||||||
use cranelift_entity::{EntityRef, PrimaryMap};
|
use cranelift_entity::{EntityRef, PrimaryMap};
|
||||||
use cranelift_wasm::DefinedFuncIndex;
|
use cranelift_wasm::DefinedFuncIndex;
|
||||||
use gimli::write;
|
use gimli::write;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
use wasmtime_environ::ModuleAddressMap;
|
||||||
|
|
||||||
pub type GeneratedAddress = usize;
|
pub type GeneratedAddress = usize;
|
||||||
pub type WasmAddress = u64;
|
pub type WasmAddress = u64;
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ use cranelift_codegen::isa::TargetFrontendConfig;
|
|||||||
use faerie::{Artifact, Decl};
|
use faerie::{Artifact, Decl};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use target_lexicon::{BinaryFormat, Triple};
|
use target_lexicon::{BinaryFormat, Triple};
|
||||||
|
use wasmtime_environ::ModuleAddressMap;
|
||||||
|
|
||||||
pub use crate::read_debuginfo::{read_debuginfo, DebugInfoData, WasmFileInfo};
|
pub use crate::read_debuginfo::{read_debuginfo, DebugInfoData, WasmFileInfo};
|
||||||
pub use crate::transform::{
|
pub use crate::transform::{transform_dwarf, ModuleVmctxInfo, ValueLabelsRanges};
|
||||||
transform_dwarf, FunctionAddressMap, InstructionAddressMap, ModuleAddressMap, ModuleVmctxInfo,
|
|
||||||
ValueLabelsRanges,
|
|
||||||
};
|
|
||||||
pub use crate::write_debuginfo::{emit_dwarf, ResolvedSymbol, SymbolResolver};
|
pub use crate::write_debuginfo::{emit_dwarf, ResolvedSymbol, SymbolResolver};
|
||||||
|
|
||||||
mod address_transform;
|
mod address_transform;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use cranelift_wasm::DefinedFuncIndex;
|
|||||||
use failure::Error;
|
use failure::Error;
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
use wasmtime_environ::ModuleAddressMap;
|
||||||
|
|
||||||
use gimli;
|
use gimli;
|
||||||
|
|
||||||
@@ -27,36 +28,6 @@ impl<'input, Endian> Reader for gimli::EndianSlice<'input, Endian> where Endian:
|
|||||||
#[fail(display = "Debug info transform error: {}", _0)]
|
#[fail(display = "Debug info transform error: {}", _0)]
|
||||||
pub struct TransformError(&'static str);
|
pub struct TransformError(&'static str);
|
||||||
|
|
||||||
/// Single wasm 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>;
|
|
||||||
|
|
||||||
/// Module `vmctx` related info.
|
/// Module `vmctx` related info.
|
||||||
pub struct ModuleVmctxInfo {
|
pub struct ModuleVmctxInfo {
|
||||||
pub memory_offset: i64,
|
pub memory_offset: i64,
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ failure = { version = "0.1.3", default-features = false }
|
|||||||
failure_derive = { version = "0.1.3", default-features = false }
|
failure_derive = { version = "0.1.3", default-features = false }
|
||||||
indexmap = "1.0.2"
|
indexmap = "1.0.2"
|
||||||
rayon = "1.0"
|
rayon = "1.0"
|
||||||
wasmtime-debug = { path = "../wasmtime-debug", default-features = false }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
37
wasmtime-environ/src/address_map.rs
Normal file
37
wasmtime-environ/src/address_map.rs
Normal 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>;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
//! A `Compilation` contains the compiled function bodies for a WebAssembly
|
//! A `Compilation` contains the compiled function bodies for a WebAssembly
|
||||||
//! module.
|
//! module.
|
||||||
|
|
||||||
|
use crate::address_map::ModuleAddressMap;
|
||||||
use crate::module;
|
use crate::module;
|
||||||
use crate::module_environ::FunctionBodyData;
|
use crate::module_environ::FunctionBodyData;
|
||||||
use cranelift_codegen::{binemit, ir, isa, CodegenError};
|
use cranelift_codegen::{binemit, ir, isa, CodegenError};
|
||||||
@@ -8,7 +9,6 @@ use cranelift_entity::PrimaryMap;
|
|||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmtime_debug::ModuleAddressMap;
|
|
||||||
|
|
||||||
/// Compiled machine code: body and jump table offsets.
|
/// Compiled machine code: body and jump table offsets.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//! Support for compiling with Cranelift.
|
//! Support for compiling with Cranelift.
|
||||||
|
|
||||||
|
use crate::address_map::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
|
||||||
use crate::compilation::{
|
use crate::compilation::{
|
||||||
CodeAndJTOffsets, Compilation, CompileError, Relocation, RelocationTarget, Relocations,
|
CodeAndJTOffsets, Compilation, CompileError, Relocation, RelocationTarget, Relocations,
|
||||||
};
|
};
|
||||||
@@ -18,7 +19,6 @@ use cranelift_entity::PrimaryMap;
|
|||||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, FuncTranslator};
|
||||||
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmtime_debug::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
|
|
||||||
|
|
||||||
/// Implementation of a relocation sink that just saves all the information for later
|
/// Implementation of a relocation sink that just saves all the information for later
|
||||||
pub struct RelocSink {
|
pub struct RelocSink {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ extern crate std;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
|
|
||||||
|
mod address_map;
|
||||||
mod compilation;
|
mod compilation;
|
||||||
mod func_environ;
|
mod func_environ;
|
||||||
mod module;
|
mod module;
|
||||||
@@ -48,6 +49,7 @@ pub mod cranelift;
|
|||||||
#[cfg(feature = "lightbeam")]
|
#[cfg(feature = "lightbeam")]
|
||||||
pub mod lightbeam;
|
pub mod lightbeam;
|
||||||
|
|
||||||
|
pub use crate::address_map::{FunctionAddressMap, InstructionAddressMap, ModuleAddressMap};
|
||||||
pub use crate::compilation::{
|
pub use crate::compilation::{
|
||||||
Compilation, CompileError, Compiler, Relocation, RelocationTarget, Relocations,
|
Compilation, CompileError, Compiler, Relocation, RelocationTarget, Relocations,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user