Make compilers to take non-mutable inputs

This commit is contained in:
Syrus Akbary
2021-04-26 21:14:23 -07:00
parent ae20af8426
commit 2df5854e37
11 changed files with 70 additions and 46 deletions

View File

@ -41,12 +41,17 @@ impl SinglepassCompiler {
}
impl Compiler for SinglepassCompiler {
/// Get the middlewares for this compiler
fn get_middlewares(&self) -> Vec<Arc<dyn ModuleMiddleware>> {
self.config.get_middlewares()
}
/// Compile the module using Singlepass, producing a compilation result with
/// associated relocations.
fn compile_module(
&self,
target: &Target,
compile_info: &mut CompileModuleInfo,
compile_info: &CompileModuleInfo,
_module_translation: &ModuleTranslationState,
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
) -> Result<Compilation, CompileError> {
@ -63,9 +68,6 @@ impl Compiler for SinglepassCompiler {
}
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 vmoffsets = VMOffsets::new(8, &compile_info.module);
let module = &compile_info.module;
let import_trampolines: PrimaryMap<SectionIndex, _> = (0..module.num_imported_functions)