Don't re-parse wasm for debuginfo (#2085)
* Don't re-parse wasm for debuginfo This commit updates debuginfo parsing to happen during the main translation of the original wasm module. This avoid re-parsing the wasm module twice (at least the section-level headers). Additionally this ties debuginfo directly to a `ModuleTranslation` which makes it easier to process debuginfo for nested modules in the upcoming module linking proposal. The changes here are summarized by taking the `read_debuginfo` function and merging it with the main module translation that happens which is driven by cranelift. Some new hooks were added to the module environment trait to support this, but most of it was integrating with existing hooks. * Fix tests in debug crate
This commit is contained in:
@@ -59,7 +59,10 @@ pub fn translate_module<'data>(
|
||||
parse_element_section(elements, environ)?;
|
||||
}
|
||||
|
||||
Payload::CodeSectionStart { .. } => {}
|
||||
Payload::CodeSectionStart { count, range, .. } => {
|
||||
environ.reserve_function_bodies(count, range.start as u64);
|
||||
}
|
||||
|
||||
Payload::CodeSectionEntry(code) => {
|
||||
let mut code = code.get_binary_reader();
|
||||
let size = code.bytes_remaining();
|
||||
@@ -91,7 +94,14 @@ pub fn translate_module<'data>(
|
||||
name: "name",
|
||||
data,
|
||||
data_offset,
|
||||
} => parse_name_section(NameSectionReader::new(data, data_offset)?, environ)?,
|
||||
} => {
|
||||
let result = NameSectionReader::new(data, data_offset)
|
||||
.map_err(|e| e.into())
|
||||
.and_then(|s| parse_name_section(s, environ));
|
||||
if let Err(e) = result {
|
||||
log::warn!("failed to parse name section {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Payload::CustomSection { name, data, .. } => environ.custom_section(name, data)?,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user