Merge pull request #641 from data-pup/instantiate_empty

Instantiate empty module
This commit is contained in:
Nick Fitzgerald
2019-11-26 15:22:23 -08:00
committed by GitHub
4 changed files with 39 additions and 26 deletions

View File

@@ -19,3 +19,6 @@ log = "0.4.8"
wasmparser = "0.42.1"
wasmprinter = "0.2.0"
wasmtime-jit = { path = "../jit" }
[dev-dependencies]
wat = "1.0"

View File

@@ -7,3 +7,9 @@
#[allow(unused_imports)] // Until we actually have some regression tests...
use wasmtime_fuzzing::*;
#[test]
fn instantiate_empty_module() {
let data = wat::parse_str(include_str!("./regressions/empty.wat")).unwrap();
oracles::instantiate(&data, wasmtime_jit::CompilationStrategy::Auto);
}

View File

@@ -0,0 +1 @@
(module)

View File

@@ -156,33 +156,36 @@ impl Compiler {
let dbg = if let Some(debug_data) = debug_data {
let target_config = self.isa.frontend_config();
let triple = self.isa.triple().clone();
let mut funcs = Vec::new();
for (i, allocated) in allocated_functions.into_iter() {
let ptr = (*allocated) as *const u8;
let body_len = compilation.get(i).body.len();
funcs.push((ptr, body_len));
}
let module_vmctx_info = {
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
let memory_offset =
ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64;
ModuleVmctxInfo {
memory_offset,
stack_slots,
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
if ofs.num_defined_memories > 0 {
let mut funcs = Vec::new();
for (i, allocated) in allocated_functions.into_iter() {
let ptr = (*allocated) as *const u8;
let body_len = compilation.get(i).body.len();
funcs.push((ptr, body_len));
}
};
let bytes = emit_debugsections_image(
triple,
&target_config,
&debug_data,
&module_vmctx_info,
&address_transform,
&value_ranges,
&funcs,
)
.map_err(|e| SetupError::DebugInfo(e))?;
Some(bytes)
let module_vmctx_info = {
let memory_offset =
ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64;
ModuleVmctxInfo {
memory_offset,
stack_slots,
}
};
let bytes = emit_debugsections_image(
self.isa.triple().clone(),
&target_config,
&debug_data,
&module_vmctx_info,
&address_transform,
&value_ranges,
&funcs,
)
.map_err(|e| SetupError::DebugInfo(e))?;
Some(bytes)
} else {
None
}
} else {
None
};