Update module info in-place.

This commit is contained in:
losfair
2020-06-23 23:36:16 +08:00
committed by Nick Lewycky
parent 13a979a53d
commit 9d8f315d4c
11 changed files with 59 additions and 24 deletions

View File

@ -8,15 +8,16 @@ use inkwell::module::{Linkage, Module};
use inkwell::targets::FileType;
use inkwell::DLLStorageClass;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use std::sync::Arc;
use wasmer_compiler::{
Compilation, CompileError, CompileModuleInfo, Compiler, CustomSection, CustomSectionProtection,
Dwarf, FunctionBodyData, ModuleTranslationState, RelocationTarget, SectionBody, SectionIndex,
Symbol, SymbolRegistry, Target,
Dwarf, FunctionBodyData, ModuleMiddlewareChain, ModuleTranslationState, RelocationTarget,
SectionBody, SectionIndex, Symbol, SymbolRegistry, Target,
};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::{FunctionIndex, LocalFunctionIndex, SignatureIndex};
//use std::sync::{Arc, Mutex};
//use std::sync::Mutex;
/// A compiler that compiles a WebAssembly module with LLVM, translating the Wasm to LLVM IR,
/// optimizing it and then translating to assembly.
@ -233,13 +234,17 @@ impl Compiler for LLVMCompiler {
fn compile_module<'data, 'module>(
&self,
target: &Target,
compile_info: &'module CompileModuleInfo,
compile_info: &'module mut CompileModuleInfo,
module_translation: &ModuleTranslationState,
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>,
) -> Result<Compilation, CompileError> {
//let data = Arc::new(Mutex::new(0));
let memory_styles = &compile_info.memory_styles;
let table_styles = &compile_info.table_styles;
let mut module = (*compile_info.module).clone();
self.config.middlewares.apply_on_module_info(&mut module);
compile_info.module = Arc::new(module);
let module = &compile_info.module;
// TODO: merge constants in sections.
@ -260,7 +265,7 @@ impl Compiler for LLVMCompiler {
// TODO: remove (to serialize)
//let _data = data.lock().unwrap();
func_translator.translate(
&module,
module,
module_translation,
i,
input,