mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 05:01:33 +00:00
Clean up, everything works
This commit is contained in:
@ -112,7 +112,11 @@ pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule,
|
||||
/// Checks the precondition for a module.
|
||||
fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>;
|
||||
/// Creates a new function and returns the function-scope code generator for it.
|
||||
fn next_function(&mut self, module_info: Arc<RwLock<ModuleInfo>>, loc: (u32, u32)) -> Result<&mut FCG, E>;
|
||||
fn next_function(
|
||||
&mut self,
|
||||
module_info: Arc<RwLock<ModuleInfo>>,
|
||||
loc: (u32, u32),
|
||||
) -> Result<&mut FCG, E>;
|
||||
/// Finalizes this module.
|
||||
fn finalize(
|
||||
self,
|
||||
@ -278,13 +282,17 @@ impl<
|
||||
if compiler_config.generate_debug_info {
|
||||
let debug_metadata = debug_metadata.expect("debug metadata");
|
||||
let debug_info = wasm_debug::read_debuginfo(wasm);
|
||||
let extra_info = wasm_debug::types::ModuleVmctxInfo::new(14 * 8, debug_metadata.stack_slot_offsets.values());
|
||||
let extra_info = wasm_debug::types::ModuleVmctxInfo::new(
|
||||
14 * 8,
|
||||
debug_metadata.stack_slot_offsets.values(),
|
||||
);
|
||||
// lazy type hack (TODO:)
|
||||
let compiled_fn_map = wasm_debug::types::create_module_address_map(debug_metadata.func_info.values());
|
||||
let range_map = wasm_debug::types::build_values_ranges(debug_metadata.inst_info.values());
|
||||
let compiled_fn_map =
|
||||
wasm_debug::types::create_module_address_map(debug_metadata.func_info.values());
|
||||
let range_map =
|
||||
wasm_debug::types::build_values_ranges(debug_metadata.inst_info.values());
|
||||
let raw_func_slice = debug_metadata.pointers;
|
||||
|
||||
dbg!("DEBUG INFO GENERATED");
|
||||
let debug_image = wasm_debug::emit_debugsections_image(
|
||||
X86_64_OSX,
|
||||
std::mem::size_of::<usize>() as u8,
|
||||
|
@ -88,12 +88,12 @@ impl Instance {
|
||||
vmctx.as_mut_ptr().write(real_ctx);
|
||||
for (_, memory) in backing.vm_memories.iter_mut() {
|
||||
let mem: &mut vm::LocalMemory = &mut **memory;
|
||||
// remaining left to do:
|
||||
mem.vmctx = dbg!(vmctx.as_mut_ptr());
|
||||
}
|
||||
};
|
||||
Box::leak(vmctx);
|
||||
|
||||
|
||||
let instance = Instance {
|
||||
module,
|
||||
inner,
|
||||
|
@ -78,17 +78,9 @@ pub struct ModuleInfo {
|
||||
/// Custom sections.
|
||||
pub custom_sections: HashMap<String, Vec<u8>>,
|
||||
|
||||
/// Debug info for funcs
|
||||
pub func_debug_info: Map<FuncIndex, FuncDebugInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
/// info about functions for debugging
|
||||
pub struct FuncDebugInfo {
|
||||
/// byte offset from start of code section where the function starts at
|
||||
pub start: u32,
|
||||
/// byte offset from start of code section where the function starts at
|
||||
pub end: u32,
|
||||
/// Flag controlling whether or not debug information for use in a debugger
|
||||
/// will be generated
|
||||
pub generate_debug_info: bool,
|
||||
}
|
||||
|
||||
impl ModuleInfo {
|
||||
|
@ -6,8 +6,8 @@ use crate::{
|
||||
backend::{CompilerConfig, RunnableModule},
|
||||
error::CompileError,
|
||||
module::{
|
||||
DataInitializer, ExportIndex, FuncDebugInfo, ImportName, ModuleInfo, StringTable,
|
||||
StringTableBuilder, TableInitializer,
|
||||
DataInitializer, ExportIndex, ImportName, ModuleInfo, StringTable, StringTableBuilder,
|
||||
TableInitializer,
|
||||
},
|
||||
structures::{Map, TypedIndex},
|
||||
types::{
|
||||
@ -91,7 +91,7 @@ pub fn read_module<
|
||||
|
||||
custom_sections: HashMap::new(),
|
||||
|
||||
func_debug_info: Map::new(),
|
||||
generate_debug_info: compiler_config.generate_debug_info,
|
||||
}));
|
||||
|
||||
let mut parser = wasmparser::ValidatingParser::new(
|
||||
@ -226,7 +226,6 @@ pub fn read_module<
|
||||
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
|
||||
}
|
||||
|
||||
|
||||
let fcg = mcg
|
||||
.next_function(Arc::clone(&info), (range.start as u32, range.end as u32))
|
||||
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
|
||||
@ -263,7 +262,8 @@ pub fn read_module<
|
||||
let local_count = operator_parser.read_local_count().unwrap();
|
||||
let mut total = 0;
|
||||
for _ in 0..local_count {
|
||||
let cur_pos = range.start as u32 + operator_parser.current_position() as u32;
|
||||
let cur_pos =
|
||||
range.start as u32 + operator_parser.current_position() as u32;
|
||||
let (count, ty) = operator_parser
|
||||
.read_local_decl(&mut total)
|
||||
.expect("Expected local");
|
||||
@ -275,7 +275,8 @@ pub fn read_module<
|
||||
// read instruction locations into vector for debug purposes
|
||||
{
|
||||
let info_read = info.read().unwrap();
|
||||
let mut cur_pos = range.start as u32 + operator_parser.current_position() as u32;
|
||||
let mut cur_pos =
|
||||
range.start as u32 + operator_parser.current_position() as u32;
|
||||
fcg.begin_body(&info_read)
|
||||
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
|
||||
middlewares
|
||||
@ -308,13 +309,6 @@ pub fn read_module<
|
||||
fcg.finalize()
|
||||
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
|
||||
func_count = func_count.wrapping_add(1);
|
||||
|
||||
// debug info
|
||||
let debug_entry = FuncDebugInfo {
|
||||
start: range.start as u32,
|
||||
end: range.end as u32,
|
||||
};
|
||||
info.write().unwrap().func_debug_info.push(debug_entry);
|
||||
}
|
||||
ParserState::BeginActiveElementSectionEntry(table_index) => {
|
||||
let table_index = TableIndex::new(table_index as usize);
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
module::{ModuleInfo, ModuleInner},
|
||||
sig_registry::SigRegistry,
|
||||
structures::TypedIndex,
|
||||
types::{LocalOrImport, MemoryIndex, TableIndex, Value, LocalMemoryIndex},
|
||||
types::{LocalMemoryIndex, LocalOrImport, MemoryIndex, TableIndex, Value},
|
||||
vmcalls,
|
||||
};
|
||||
use std::{
|
||||
@ -286,7 +286,6 @@ impl Ctx {
|
||||
};
|
||||
((*mem).base, (*mem).bound)
|
||||
};
|
||||
dbg!(mem_bound);
|
||||
Self {
|
||||
internal: InternalCtx {
|
||||
memories: local_backing.vm_memories.as_mut_ptr(),
|
||||
|
Reference in New Issue
Block a user