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" wasmparser = "0.42.1"
wasmprinter = "0.2.0" wasmprinter = "0.2.0"
wasmtime-jit = { path = "../jit" } 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... #[allow(unused_imports)] // Until we actually have some regression tests...
use wasmtime_fuzzing::*; 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,7 +156,8 @@ impl Compiler {
let dbg = if let Some(debug_data) = debug_data { let dbg = if let Some(debug_data) = debug_data {
let target_config = self.isa.frontend_config(); let target_config = self.isa.frontend_config();
let triple = self.isa.triple().clone(); let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
if ofs.num_defined_memories > 0 {
let mut funcs = Vec::new(); let mut funcs = Vec::new();
for (i, allocated) in allocated_functions.into_iter() { for (i, allocated) in allocated_functions.into_iter() {
let ptr = (*allocated) as *const u8; let ptr = (*allocated) as *const u8;
@@ -164,7 +165,6 @@ impl Compiler {
funcs.push((ptr, body_len)); funcs.push((ptr, body_len));
} }
let module_vmctx_info = { let module_vmctx_info = {
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
let memory_offset = let memory_offset =
ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64; ofs.vmctx_vmmemory_definition_base(DefinedMemoryIndex::new(0)) as i64;
ModuleVmctxInfo { ModuleVmctxInfo {
@@ -173,7 +173,7 @@ impl Compiler {
} }
}; };
let bytes = emit_debugsections_image( let bytes = emit_debugsections_image(
triple, self.isa.triple().clone(),
&target_config, &target_config,
&debug_data, &debug_data,
&module_vmctx_info, &module_vmctx_info,
@@ -185,6 +185,9 @@ impl Compiler {
Some(bytes) Some(bytes)
} else { } else {
None None
}
} else {
None
}; };
let jt_offsets = compilation.get_jt_offsets(); let jt_offsets = compilation.get_jt_offsets();