Restructure to use external crate, add integration

This commit is contained in:
Mark McCaskey
2020-02-03 16:01:23 -08:00
parent 800b2a42cc
commit 42132c42b6
13 changed files with 256 additions and 191 deletions

View File

@ -6,7 +6,7 @@ use crate::{
resolver::FuncResolverBuilder, signal::Caller, trampoline::Trampolines,
};
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::entity::{EntityRef, PrimaryMap};
use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder};
use cranelift_codegen::isa::CallConv;
use cranelift_codegen::{cursor::FuncCursor, isa};
@ -141,9 +141,33 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
fn finalize(
self,
module_info: &ModuleInfo,
) -> Result<(Caller, Box<dyn CacheGen>), CodegenError> {
) -> Result<((Caller, Option<wasmer_runtime_core::codegen::DebugMetadata>), Box<dyn CacheGen>), CodegenError> {
use wasm_debug::types::{CompiledFunctionData};
let mut debug_metadata = wasmer_runtime_core::codegen::DebugMetadata {
func_info: PrimaryMap::new(),
inst_info: PrimaryMap::new(),
};
let mut func_bodies: Map<LocalFuncIndex, ir::Function> = Map::new();
for f in self.functions.into_iter() {
// TODO: review
// if container is stable, then first and last probably makes more sense here,
let min_srcloc = f.func.srclocs.iter().map(|x| x.1.bits()).min().unwrap_or_default();
let max_srcloc = f.func.srclocs.iter().map(|x| x.1.bits()).max().unwrap_or_default();
let entry = CompiledFunctionData {
instructions: vec![],
start: wasm_debug::types::SourceLoc::new(min_srcloc),
end: wasm_debug::types::SourceLoc::new(max_srcloc),
compiled_offset: 0,
compiled_size: 0,
};
debug_metadata.func_info.push(entry);
/*let mut map = std::collections::HashMap::new();
for (k, v) in f.func.srclocs {
map.
}
debug_metadata.inst_info.push(map);*/
func_bodies.push(f.func);
}
@ -171,7 +195,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
));
Ok((
Caller::new(handler_data, trampolines, func_resolver),
(Caller::new(handler_data, trampolines, func_resolver), Some(debug_metadata)),
cache_gen,
))
}

View File

@ -56,7 +56,7 @@ macro_rules! convert_clif_to_runtime_index {
($clif_index:ident, $runtime_index:ident) => {
impl From<Converter<cranelift_wasm::$clif_index>> for $runtime_index {
fn from(clif_index: Converter<cranelift_wasm::$clif_index>) -> Self {
$runtime_index::new(clif_index.0.index())
<$runtime_index as TypedIndex>::new(clif_index.0.index())
}
}