Add updates from feedback

Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
This commit is contained in:
Mark McCaskey
2020-02-21 14:33:32 -08:00
parent 3d6e915108
commit 40e4dddc4b
10 changed files with 124 additions and 73 deletions

View File

@ -71,7 +71,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
fn next_function(
&mut self,
module_info: Arc<RwLock<ModuleInfo>>,
loc: (u32, u32),
loc: WasmSpan,
) -> Result<&mut CraneliftFunctionCodeGenerator, CodegenError> {
// define_function_body(
@ -102,8 +102,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
target_config: self.isa.frontend_config().clone(),
clif_signatures: self.clif_signatures.clone(),
},
start: loc.0,
end: loc.1,
loc,
};
let generate_debug_info = module_info.read().unwrap().generate_debug_info;
@ -120,7 +119,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
&mut func_env.position,
);
builder.set_srcloc(ir::SourceLoc::new(loc.0));
builder.set_srcloc(ir::SourceLoc::new(loc.start()));
let entry_block = builder.create_ebb();
builder.append_ebb_params_for_function_params(entry_block);
@ -156,9 +155,9 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
),
CodegenError,
> {
let mut func_bodies: Map<LocalFuncIndex, (ir::Function, (u32, u32))> = Map::new();
let mut func_bodies: Map<LocalFuncIndex, (ir::Function, WasmSpan)> = Map::new();
for f in self.functions.into_iter() {
func_bodies.push((f.func, (f.start, f.end)));
func_bodies.push((f.func, f.loc));
}
let (func_resolver_builder, debug_metadata, handler_data) =
@ -256,12 +255,8 @@ pub struct CraneliftFunctionCodeGenerator {
next_local: usize,
position: Position,
func_env: FunctionEnvironment,
/// Start location of the function as an offset in bytes in the Wasm module
/// from the beginning of the code section.
start: u32,
/// End location of the function as an offset in bytes in the Wasm module
/// from the beginning of the code section.
end: u32,
/// Where the function lives in the Wasm module as a span of bytes
loc: WasmSpan,
}
pub struct FunctionEnvironment {

View File

@ -26,6 +26,7 @@ use wasmer_runtime_core::{
SigRegistry,
},
cache::Error as CacheError,
codegen::WasmSpan,
error::{CompileError, CompileResult},
module::ModuleInfo,
structures::{Map, SliceMap, TypedIndex},
@ -96,7 +97,7 @@ impl FuncResolverBuilder {
pub fn new(
isa: &dyn isa::TargetIsa,
function_bodies: Map<LocalFuncIndex, (ir::Function, (u32, u32))>,
function_bodies: Map<LocalFuncIndex, (ir::Function, WasmSpan)>,
info: &ModuleInfo,
) -> CompileResult<(
Self,
@ -127,7 +128,7 @@ impl FuncResolverBuilder {
.par_iter()
.map_init(
|| Context::new(),
|ctx, (lfi, (func, (start, end)))| {
|ctx, (lfi, (func, loc))| {
let mut code_buf = Vec::new();
ctx.func = func.to_owned();
let mut reloc_sink = RelocSink::new();
@ -179,8 +180,8 @@ impl FuncResolverBuilder {
let entry = CompiledFunctionData {
instructions,
start_srcloc: wasm_debug::types::SourceLoc::new(*start),
end_srcloc: wasm_debug::types::SourceLoc::new(*end),
start_srcloc: wasm_debug::types::SourceLoc::new(loc.start()),
end_srcloc: wasm_debug::types::SourceLoc::new(loc.end()),
// this not being 0 breaks inst-level debugging
body_offset: 0,
body_len: code_buf.len(),