Fix compilation errors and warnings

This commit is contained in:
Brandon Fish 2019-05-26 11:13:37 -05:00
parent 5da0c4766a
commit 6ca311f92d
5 changed files with 38 additions and 43 deletions

14
Cargo.lock generated
View File

@ -309,7 +309,7 @@ dependencies = [
[[package]]
name = "cranelift-bforest"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cranelift-entity 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
]
@ -317,7 +317,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cranelift-bforest 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
"cranelift-codegen-meta 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
@ -331,7 +331,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cranelift-entity 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
]
@ -339,12 +339,12 @@ dependencies = [
[[package]]
name = "cranelift-entity"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
[[package]]
name = "cranelift-frontend"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -354,7 +354,7 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -364,7 +364,7 @@ dependencies = [
[[package]]
name = "cranelift-wasm"
version = "0.30.0"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#50eaeb72cfd02e508d9416b599f0882767ced69f"
source = "git+https://github.com/wasmerio/cranelift.git?branch=wasmer#84ec31b0fdfc10db491ef950815ee2961db057cb"
dependencies = [
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cranelift-codegen 0.30.0 (git+https://github.com/wasmerio/cranelift.git?branch=wasmer)",

View File

@ -2,29 +2,18 @@
// and subject to the license https://github.com/CraneStation/cranelift/blob/c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2/cranelift-wasm/LICENSE
use crate::{
cache::{BackendCache, CacheGenerator},
func_env::FuncEnv,
get_isa, module,
module::{Converter, Module},
relocation::call_names,
resolver::FuncResolverBuilder,
signal::Caller,
trampoline::Trampolines,
cache::CacheGenerator, get_isa, module, module::Converter, relocation::call_names,
resolver::FuncResolverBuilder, signal::Caller, trampoline::Trampolines,
};
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::flowgraph::BasicBlock;
use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder, ValueLabel};
use cranelift_codegen::packed_option::ReservedValue;
use cranelift_codegen::timing;
use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder};
use cranelift_codegen::{cursor::FuncCursor, isa};
use cranelift_entity::packed_option::PackedOption;
use cranelift_frontend::{Block, FunctionBuilder, FunctionBuilderContext, Position, Variable};
use cranelift_wasm::{self, translate_module, FuncTranslator, ModuleEnvironment};
use cranelift_wasm::{get_vmctx_value_label, translate_operator, TranslationState};
use cranelift_wasm::{FuncEnvironment, ReturnMode, WasmError, WasmResult};
use cranelift_frontend::{FunctionBuilder, Position, Variable};
use cranelift_wasm::{self, FuncTranslator};
use cranelift_wasm::{get_vmctx_value_label, translate_operator};
use cranelift_wasm::{FuncEnvironment, ReturnMode, WasmError};
use std::mem;
use std::rc::Rc;
use std::sync::{Arc, RwLock};
use wasmer_runtime_core::error::CompileError;
use wasmer_runtime_core::{
@ -35,13 +24,11 @@ use wasmer_runtime_core::{
module::{ModuleInfo, ModuleInner},
structures::{Map, TypedIndex},
types::{
ElementType, FuncIndex, FuncSig, GlobalDescriptor, GlobalIndex, GlobalInit, Initializer,
LocalFuncIndex, LocalOrImport, MemoryDescriptor, MemoryIndex, SigIndex, TableDescriptor,
TableIndex, Value,
FuncIndex, FuncSig, GlobalIndex, LocalFuncIndex, LocalOrImport, MemoryIndex, SigIndex,
TableIndex,
},
vm,
};
use wasmparser::Operator;
use wasmparser::Type as WpType;
pub struct CraneliftModuleCodeGenerator {
@ -50,11 +37,8 @@ pub struct CraneliftModuleCodeGenerator {
pub clif_signatures: Map<SigIndex, ir::Signature>,
function_signatures: Option<Arc<Map<FuncIndex, SigIndex>>>,
functions: Vec<CraneliftFunctionCodeGenerator>,
func_bodies: Map<LocalFuncIndex, ir::Function>,
}
pub struct ClifFuncEnv {}
impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
for CraneliftModuleCodeGenerator
{
@ -66,7 +50,6 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
functions: vec![],
function_signatures: None,
signatures: None,
func_bodies: Map::new(),
}
}
@ -84,7 +67,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
) -> Result<&mut CraneliftFunctionCodeGenerator, CodegenError> {
// define_function_body(
let mut func_translator = FuncTranslator::new();
let func_translator = FuncTranslator::new();
let func_index = LocalFuncIndex::new(self.functions.len());
let name = ir::ExternalName::user(0, func_index.index() as u32);
@ -97,7 +80,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
),
);
let mut func = ir::Function::with_name_signature(name, sig);
let func = ir::Function::with_name_signature(name, sig);
//func_translator.translate(body_bytes, body_offset, &mut func, &mut func_env)?;
@ -370,6 +353,14 @@ impl From<CompileError> for CodegenError {
}
}
impl From<WasmError> for CodegenError {
fn from(other: WasmError) -> CodegenError {
CodegenError {
message: format!("{:?}", other),
}
}
}
pub struct CraneliftFunctionCodeGenerator {
func: Function,
func_translator: FuncTranslator,
@ -1086,7 +1077,7 @@ impl FunctionCodeGenerator<CodegenError> for CraneliftFunctionCodeGenerator {
fn feed_local(&mut self, ty: WpType, n: usize) -> Result<(), CodegenError> {
let mut next_local = self.next_local;
cranelift_wasm::declare_locals(&mut self.builder(), n as u32, ty, &mut next_local);
cranelift_wasm::declare_locals(&mut self.builder(), n as u32, ty, &mut next_local)?;
self.next_local = next_local;
Ok(())
}
@ -1112,7 +1103,7 @@ impl FunctionCodeGenerator<CodegenError> for CraneliftFunctionCodeGenerator {
clif_signatures: self.clif_signatures.clone(),
};
if (self.func_translator.state.control_stack.is_empty()) {
if self.func_translator.state.control_stack.is_empty() {
return Ok(());
}
@ -1122,7 +1113,7 @@ impl FunctionCodeGenerator<CodegenError> for CraneliftFunctionCodeGenerator {
&mut self.position,
);
let state = &mut self.func_translator.state;
translate_operator(op, &mut builder, state, &mut function_environment);
translate_operator(op, &mut builder, state, &mut function_environment)?;
Ok(())
}

View File

@ -8,7 +8,7 @@ use inkwell::{
AddressSpace, FloatPredicate, IntPredicate,
};
use smallvec::SmallVec;
use std::sync::Arc;
use std::sync::{Arc, RwLock};
use wasmer_runtime_core::{
backend::{Backend, CacheGen, Token},
cache::{Artifact, Error as CacheError},
@ -2475,7 +2475,7 @@ impl ModuleCodeGenerator<LLVMFunctionCodeGenerator, LLVMBackend, CodegenError>
fn next_function(
&mut self,
_module_info: Arc<ModuleInfo>,
_module_info: Arc<RwLock<ModuleInfo>>,
) -> Result<&mut LLVMFunctionCodeGenerator, CodegenError> {
// Creates a new function and returns the function-scope code generator for it.
let (context, builder, intrinsics) = match self.functions.last_mut() {

View File

@ -54,7 +54,7 @@ pub fn read_module<
middlewares: &mut MiddlewareChain,
compiler_config: &CompilerConfig,
) -> Result<Arc<RwLock<ModuleInfo>>, LoadError> {
let mut info = Arc::new(RwLock::new(ModuleInfo {
let info = Arc::new(RwLock::new(ModuleInfo {
memories: Map::new(),
globals: Map::new(),
tables: Map::new(),

View File

@ -8,7 +8,11 @@ use dynasmrt::{
};
use smallvec::SmallVec;
use std::ptr::NonNull;
use std::{any::Any, collections::HashMap, sync::Arc};
use std::{
any::Any,
collections::HashMap,
sync::{Arc, RwLock},
};
use wasmer_runtime_core::{
backend::{sys::Memory, Backend, CacheGen, RunnableModule, Token},
cache::{Artifact, Error as CacheError},
@ -302,7 +306,7 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
fn next_function(
&mut self,
_module_info: Arc<ModuleInfo>,
_module_info: Arc<RwLock<ModuleInfo>>,
) -> Result<&mut X64FunctionCode, CodegenError> {
let (mut assembler, mut function_labels, br_table_data, breakpoints) =
match self.functions.last_mut() {