merge and respond to feedback

This commit is contained in:
Mackenzie Clark
2019-03-28 11:41:45 -07:00
20 changed files with 234 additions and 41 deletions

View File

@ -6,7 +6,7 @@ use inkwell::{
OptimizationLevel,
};
use wasmer_runtime_core::{
backend::{Compiler, Token},
backend::{Compiler, CompilerConfig, Token},
cache::{Artifact, Error as CacheError},
error::CompileError,
module::ModuleInner,
@ -32,10 +32,15 @@ impl LLVMCompiler {
}
impl Compiler for LLVMCompiler {
fn compile(&self, wasm: &[u8], _: Token) -> Result<ModuleInner, CompileError> {
fn compile(
&self,
wasm: &[u8],
compiler_config: CompilerConfig,
_: Token,
) -> Result<ModuleInner, CompileError> {
validate(wasm)?;
let (info, code_reader) = read_info::read_module(wasm).unwrap();
let (info, code_reader) = read_info::read_module(wasm, compiler_config).unwrap();
let (module, intrinsics) = code::parse_function_bodies(&info, code_reader).unwrap();
let (backend, protected_caller) = backend::LLVMBackend::new(module, intrinsics);
@ -121,7 +126,7 @@ fn test_read_module() {
"#;
let wasm = wat2wasm(wat).unwrap();
let (info, code_reader) = read_info::read_module(&wasm).unwrap();
let (info, code_reader) = read_info::read_module(&wasm, Default::default()).unwrap();
let (module, intrinsics) = code::parse_function_bodies(&info, code_reader).unwrap();

View File

@ -1,5 +1,5 @@
use wasmer_runtime_core::{
backend::Backend,
backend::{Backend, CompilerConfig},
module::{
DataInitializer, ExportIndex, ImportName, ModuleInfo, StringTable, StringTableBuilder,
TableInitializer,
@ -20,7 +20,10 @@ use wasmparser::{
use hashbrown::HashMap;
pub fn read_module(wasm: &[u8]) -> Result<(ModuleInfo, CodeSectionReader), BinaryReaderError> {
pub fn read_module(
wasm: &[u8],
compiler_config: CompilerConfig,
) -> Result<(ModuleInfo, CodeSectionReader), BinaryReaderError> {
let mut info = ModuleInfo {
memories: Map::new(),
globals: Map::new(),
@ -45,6 +48,8 @@ pub fn read_module(wasm: &[u8]) -> Result<(ModuleInfo, CodeSectionReader), Binar
namespace_table: StringTable::new(),
name_table: StringTable::new(),
em_symbol_map: compiler_config.symbol_map.clone(),
custom_sections: HashMap::new(),
};