Assorted fixes:

Fix creation of the target machine. Fix CPU features, architecture and target name.

Function names are not mandatory. Support unnamed functions.

Include parameters and local variables in the list of local variables for LLVMFunctionCodeGenerator.

Run the tests single-threaded, using a Mutex in the rayon code. This means that only the first error is real, subsequent errors are just picking up the panic across threads.

Add TODOs about attributes on vmctx.
This commit is contained in:
Nick Lewycky
2020-04-23 23:23:21 -07:00
parent 7951e9bc79
commit 56fe08ad00
4 changed files with 38 additions and 21 deletions

View File

@ -16,6 +16,8 @@ use wasmer_runtime::{MemoryPlan, Module, TablePlan, TrapCode};
use inkwell::targets::{InitializationConfig, Target as InkwellTarget};
use std::sync::{Arc, Mutex}; // TODO: remove
/// A compiler that compiles a WebAssembly module with LLVM, translating the Wasm to LLVM IR,
/// optimizing it and then translating to assembly.
pub struct LLVMCompiler {
@ -57,11 +59,14 @@ impl Compiler for LLVMCompiler {
memory_plans: PrimaryMap<MemoryIndex, MemoryPlan>,
table_plans: PrimaryMap<TableIndex, TablePlan>,
) -> Result<Compilation, CompileError> {
let data = Arc::new(Mutex::new(0));
let functions = function_body_inputs
.into_iter()
.collect::<Vec<(LocalFuncIndex, &FunctionBodyData<'_>)>>()
.par_iter()
.map_init(FuncTranslator::new, |func_translator, (i, input)| {
// TODO: remove (to serialize)
let mut data = data.lock().unwrap();
func_translator.translate(
module,
i,