Connect trampoline code to trampoline module. Still unimplemented.

This commit is contained in:
Nick Lewycky
2020-04-24 16:31:31 -07:00
parent 474b3eb2f2
commit a6bde15ce5
5 changed files with 49 additions and 13 deletions

View File

@ -45,6 +45,10 @@ use wasmer_runtime::Module as WasmerCompilerModule;
use wasmer_runtime::{MemoryPlan, MemoryStyle, TablePlan};
use wasmparser::{BinaryReader, MemoryImmediate, Operator};
// TODO: debugging
use std::fs;
use std::io::Write;
// TODO
fn wptype_to_type(ty: wasmparser::Type) -> WasmResult<Type> {
match ty {
@ -222,6 +226,9 @@ impl FuncTranslator {
}
}
// TODO: debugging
//module.print_to_stderr();
// TODO: llvm-callbacks pre-opt-ir
let pass_manager = PassManager::create(());
@ -268,6 +275,13 @@ impl FuncTranslator {
.write_to_memory_buffer(&mut module, FileType::Object)
.unwrap();
let mem_buf_slice = memory_buffer.as_slice();
let mut file = fs::File::create("/home/nicholas/x.o").unwrap();
let mut pos = 0;
while pos < mem_buf_slice.len() {
pos += file.write(&mem_buf_slice[pos..]).unwrap();
}
let object = memory_buffer.create_object_file().map_err(|()| {
CompileError::Codegen("failed to create object file from llvm ir".to_string())
})?;