Deny many warnings in CI; fix warnings

This commit is contained in:
Mark McCaskey
2020-05-13 12:44:34 -07:00
parent e01588ef55
commit e77cbd8b94
28 changed files with 67 additions and 76 deletions

View File

@@ -43,13 +43,18 @@ jobs:
- run: cargo test --release - run: cargo test --release
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs`
- name: Build and Test C API - name: Build and Test C API
run: | run: |
make capi make capi
make test-capi-cranelift make test-capi-cranelift
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs`
if: matrix.os != 'windows-latest' if: matrix.os != 'windows-latest'
- name: Build C API on Windows - name: Build C API on Windows
run: make capi run: make capi
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
RUSTFLAGS: "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects -D mutable-borrow-reservation-conflict" # TODO: add `-D missing-docs`

4
Cargo.lock generated
View File

@@ -569,7 +569,7 @@ dependencies = [
[[package]] [[package]]
name = "inkwell" name = "inkwell"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/theDan64/inkwell?rev=af1846fd8aea530cef9a59170715e5c6c64346f6#af1846fd8aea530cef9a59170715e5c6c64346f6" source = "git+https://github.com/theDan64/inkwell?rev=1bfecc0a095d7ffdfa20a64630864f0297349508#1bfecc0a095d7ffdfa20a64630864f0297349508"
dependencies = [ dependencies = [
"either", "either",
"inkwell_internals", "inkwell_internals",
@@ -583,7 +583,7 @@ dependencies = [
[[package]] [[package]]
name = "inkwell_internals" name = "inkwell_internals"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/theDan64/inkwell?rev=af1846fd8aea530cef9a59170715e5c6c64346f6#af1846fd8aea530cef9a59170715e5c6c64346f6" source = "git+https://github.com/theDan64/inkwell?rev=1bfecc0a095d7ffdfa20a64630864f0297349508#1bfecc0a095d7ffdfa20a64630864f0297349508"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -13,10 +13,6 @@ use test_generator::{
with_features, with_test_module, Testsuite, with_features, with_test_module, Testsuite,
}; };
fn is_truthy_env(name: &str) -> bool {
env::var(name).map(|n| n == "1").unwrap_or_default()
}
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=tests/ignores.txt"); println!("cargo:rerun-if-changed=tests/ignores.txt");

View File

@@ -7,8 +7,7 @@ use crate::RuntimeError;
use crate::{ExternType, FunctionType, GlobalType, MemoryType, TableType, ValType}; use crate::{ExternType, FunctionType, GlobalType, MemoryType, TableType, ValType};
use std::cmp::max; use std::cmp::max;
use std::slice; use std::slice;
use wasm_common::{Bytes, HostFunction, Pages, ValueType, WasmTypeList, WithEnv, WithoutEnv}; use wasm_common::{HostFunction, Pages, ValueType, WasmTypeList, WithEnv, WithoutEnv};
use wasmer_engine::Engine as _;
use wasmer_runtime::{ use wasmer_runtime::{
wasmer_call_trampoline, Export, ExportFunction, ExportGlobal, ExportMemory, ExportTable, wasmer_call_trampoline, Export, ExportFunction, ExportGlobal, ExportMemory, ExportTable,
LinearMemory, MemoryError, Table as RuntimeTable, VMCallerCheckedAnyfunc, VMContext, LinearMemory, MemoryError, Table as RuntimeTable, VMCallerCheckedAnyfunc, VMContext,

View File

@@ -7,7 +7,7 @@ use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
use thiserror::Error; use thiserror::Error;
use wasmer_compiler::{CompileError, WasmError}; use wasmer_compiler::{CompileError, WasmError};
use wasmer_engine::{CompiledModule, DeserializeError, Engine, Resolver, SerializeError}; use wasmer_engine::{CompiledModule, DeserializeError, Resolver, SerializeError};
use wasmer_runtime::{ExportsIterator, ImportsIterator, InstanceHandle, Module as ModuleInfo}; use wasmer_runtime::{ExportsIterator, ImportsIterator, InstanceHandle, Module as ModuleInfo};
#[derive(Error, Debug)] #[derive(Error, Debug)]
@@ -74,6 +74,7 @@ impl Module {
/// let bytes: Vec<u8> = vec![]; /// let bytes: Vec<u8> = vec![];
/// let module = Module::new(&store, bytes)?; /// let module = Module::new(&store, bytes)?;
/// ``` /// ```
#[allow(unreachable_code)]
pub fn new(store: &Store, bytes: impl AsRef<[u8]>) -> Result<Module, CompileError> { pub fn new(store: &Store, bytes: impl AsRef<[u8]>) -> Result<Module, CompileError> {
#[cfg(feature = "wat")] #[cfg(feature = "wat")]
{ {
@@ -206,7 +207,7 @@ impl Module {
Ok(Self::from_compiled_module(store, compiled)) Ok(Self::from_compiled_module(store, compiled))
} }
fn from_compiled_module(store: &Store, compiled: Arc<CompiledModule>) -> Self { fn from_compiled_module(store: &Store, compiled: Arc<dyn CompiledModule>) -> Self {
Module { Module {
store: store.clone(), store: store.clone(),
compiled, compiled,

View File

@@ -1,7 +1,9 @@
#[cfg(all(feature = "compiler", feature = "engine"))]
use crate::tunables::Tunables; use crate::tunables::Tunables;
use std::sync::Arc; #[cfg(all(feature = "compiler", feature = "engine"))]
#[cfg(feature = "compiler")]
use wasmer_compiler::CompilerConfig; use wasmer_compiler::CompilerConfig;
use std::sync::Arc;
use wasmer_engine::Engine; use wasmer_engine::Engine;
#[derive(Clone)] #[derive(Clone)]

View File

@@ -1,3 +1,8 @@
//! Wasmer Cranelift compiler build script.
//!
//! Sets the git revsion? for $PURPOSE
//! TODO(syrus): explain what's happening here
use std::process::Command; use std::process::Command;
use std::str; use std::str;

View File

@@ -6,26 +6,22 @@ use crate::func_environ::{get_func_name, FuncEnvironment};
use crate::sink::{RelocSink, TrapSink}; use crate::sink::{RelocSink, TrapSink};
use crate::trampoline::{make_wasm_trampoline, FunctionBuilderContext}; use crate::trampoline::{make_wasm_trampoline, FunctionBuilderContext};
use crate::translator::{ use crate::translator::{
compiled_function_unwind_info, irlibcall_to_libcall, irreloc_to_relocationkind, compiled_function_unwind_info, signature_to_cranelift_ir, transform_jump_table, FuncTranslator,
signature_to_cranelift_ir, transform_jump_table, FuncTranslator,
}; };
use cranelift_codegen::ir::{self, ExternalName}; use cranelift_codegen::ir;
use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::{binemit, isa, Context}; use cranelift_codegen::{binemit, isa, Context};
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use wasm_common::entity::{EntityRef, PrimaryMap}; use wasm_common::entity::PrimaryMap;
use wasm_common::{ use wasm_common::{
Features, FunctionIndex, FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, Features, FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, TableIndex,
TableIndex,
}; };
use wasmer_compiler::CompileError; use wasmer_compiler::CompileError;
use wasmer_compiler::{ use wasmer_compiler::{
Compilation, CompiledFunction, CompiledFunctionFrameInfo, Compiler, FunctionBody, Compilation, CompiledFunction, CompiledFunctionFrameInfo, Compiler, FunctionBody,
FunctionBodyData, SourceLoc, TrapInformation, FunctionBodyData,
}; };
use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target}; use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target};
use wasmer_compiler::{Relocation, RelocationTarget};
use wasmer_runtime::TrapCode;
use wasmer_runtime::{MemoryPlan, Module, TablePlan}; use wasmer_runtime::{MemoryPlan, Module, TablePlan};
/// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR, /// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR,

View File

@@ -1,9 +1,6 @@
//! Support for compiling with Cranelift. //! Support for compiling with Cranelift.
use crate::translator::{ use crate::translator::{irlibcall_to_libcall, irreloc_to_relocationkind};
irlibcall_to_libcall, irreloc_to_relocationkind, signature_to_cranelift_ir,
transform_jump_table, FuncTranslator,
};
use cranelift_codegen::binemit; use cranelift_codegen::binemit;
use cranelift_codegen::ir::{self, ExternalName}; use cranelift_codegen::ir::{self, ExternalName};
use wasm_common::entity::EntityRef; use wasm_common::entity::EntityRef;
@@ -136,7 +133,7 @@ fn translate_ir_trapcode(trap: ir::TrapCode) -> TrapCode {
ir::TrapCode::BadConversionToInteger => TrapCode::BadConversionToInteger, ir::TrapCode::BadConversionToInteger => TrapCode::BadConversionToInteger,
ir::TrapCode::UnreachableCodeReached => TrapCode::UnreachableCodeReached, ir::TrapCode::UnreachableCodeReached => TrapCode::UnreachableCodeReached,
ir::TrapCode::Interrupt => TrapCode::Interrupt, ir::TrapCode::Interrupt => TrapCode::Interrupt,
ir::TrapCode::User(user_code) => unimplemented!("User trap code not supported"), ir::TrapCode::User(_user_code) => unimplemented!("User trap code not supported"),
// ir::TrapCode::User(user_code) => TrapCode::User(user_code), // ir::TrapCode::User(user_code) => TrapCode::User(user_code),
} }
} }

View File

@@ -7,7 +7,7 @@
//! ``` //! ```
use super::binemit::TrampolineRelocSink; use super::binemit::TrampolineRelocSink;
use crate::translator::{ use crate::translator::{
compiled_function_unwind_info, signature_to_cranelift_ir, transform_jump_table, compiled_function_unwind_info, signature_to_cranelift_ir, /*transform_jump_table, */
}; };
use cranelift_codegen::ir::InstBuilder; use cranelift_codegen::ir::InstBuilder;
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
@@ -16,7 +16,7 @@ use cranelift_codegen::Context;
use cranelift_codegen::{binemit, ir}; use cranelift_codegen::{binemit, ir};
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use wasm_common::FunctionType; use wasm_common::FunctionType;
use wasmer_compiler::{CompileError, CompiledFunction, CompiledFunctionFrameInfo, FunctionBody}; use wasmer_compiler::{CompileError, FunctionBody};
/// Create a trampoline for invoking a WebAssembly function. /// Create a trampoline for invoking a WebAssembly function.
pub fn make_wasm_trampoline( pub fn make_wasm_trampoline(

View File

@@ -16,6 +16,7 @@ use wasmer_compiler::WasmResult;
/// The value of a WebAssembly global variable. /// The value of a WebAssembly global variable.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum GlobalVariable { pub enum GlobalVariable {
#[allow(dead_code)]
/// This is a constant global with a value known at compile time. /// This is a constant global with a value known at compile time.
Const(ir::Value), Const(ir::Value),
@@ -29,10 +30,12 @@ pub enum GlobalVariable {
ty: ir::Type, ty: ir::Type,
}, },
#[allow(dead_code)]
/// This is a global variable that needs to be handled by the environment. /// This is a global variable that needs to be handled by the environment.
Custom, Custom,
} }
#[allow(dead_code)]
/// How to return from functions. /// How to return from functions.
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum ReturnMode { pub enum ReturnMode {

View File

@@ -216,8 +216,11 @@ pub struct FuncTranslationState {
functions: HashMap<FunctionIndex, (ir::FuncRef, usize)>, functions: HashMap<FunctionIndex, (ir::FuncRef, usize)>,
} }
// TODO: review this comment it seems to be not true, `FuncTranslationState` is _not_ exposed
// publicly from this crate.
// Public methods that are exposed to non-`wasmer_compiler` API consumers. // Public methods that are exposed to non-`wasmer_compiler` API consumers.
impl FuncTranslationState { impl FuncTranslationState {
#[allow(dead_code)]
/// True if the current translation state expresses reachable code, false if it is unreachable. /// True if the current translation state expresses reachable code, false if it is unreachable.
#[inline] #[inline]
pub fn reachable(&self) -> bool { pub fn reachable(&self) -> bool {

View File

@@ -15,7 +15,7 @@ use crate::{Addend, CodeOffset, JumpTable};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt; use std::fmt;
use wasm_common::entity::PrimaryMap; use wasm_common::entity::PrimaryMap;
use wasm_common::{FunctionIndex, LocalFunctionIndex}; use wasm_common::LocalFunctionIndex;
use wasmer_runtime::libcalls::LibCall; use wasmer_runtime::libcalls::LibCall;
/// Relocation kinds for every ISA. /// Relocation kinds for every ISA.
@@ -106,15 +106,15 @@ impl Relocation {
/// The function returns the relocation address and the delta. /// The function returns the relocation address and the delta.
pub fn for_address(&self, start: usize, target_func_address: u64) -> (usize, u64) { pub fn for_address(&self, start: usize, target_func_address: u64) -> (usize, u64) {
match self.kind { match self.kind {
RelocationKind::Abs8 => unsafe { RelocationKind::Abs8 => {
let reloc_address = start + self.offset as usize; let reloc_address = start + self.offset as usize;
let reloc_addend = self.addend as isize; let reloc_addend = self.addend as isize;
let reloc_abs = (target_func_address) let reloc_abs = (target_func_address)
.checked_add(reloc_addend as u64) .checked_add(reloc_addend as u64)
.unwrap(); .unwrap();
(reloc_address, reloc_abs) (reloc_address, reloc_abs)
}, }
RelocationKind::X86PCRel4 => unsafe { RelocationKind::X86PCRel4 => {
let reloc_address = start + self.offset as usize; let reloc_address = start + self.offset as usize;
let reloc_addend = self.addend as isize; let reloc_addend = self.addend as isize;
let reloc_delta_u32 = (target_func_address as u32) let reloc_delta_u32 = (target_func_address as u32)
@@ -122,7 +122,7 @@ impl Relocation {
.checked_add(reloc_addend as u32) .checked_add(reloc_addend as u32)
.unwrap(); .unwrap();
(reloc_address, reloc_delta_u32 as u64) (reloc_address, reloc_delta_u32 as u64)
}, }
RelocationKind::X86CallPCRel4 => { RelocationKind::X86CallPCRel4 => {
let reloc_address = start + self.offset as usize; let reloc_address = start + self.offset as usize;
let reloc_addend = self.addend as isize; let reloc_addend = self.addend as isize;

View File

@@ -2,7 +2,6 @@
use enumset::{EnumSet, EnumSetType}; use enumset::{EnumSet, EnumSetType};
pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple}; pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple};
use crate::std::boxed::Box;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use raw_cpuid::CpuId; use raw_cpuid::CpuId;

View File

@@ -1,5 +1,4 @@
use crate::WasmError; use crate::WasmError;
use thiserror::Error;
use wasmparser::BinaryReaderError; use wasmparser::BinaryReaderError;
/// Return an `Err(WasmError::Unsupported(msg))` where `msg` the string built by calling `format!` /// Return an `Err(WasmError::Unsupported(msg))` where `msg` the string built by calling `format!`

View File

@@ -4,8 +4,8 @@ use crate::{CodeMemory, CompiledModule};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use wasm_common::entity::PrimaryMap; use wasm_common::entity::PrimaryMap;
use wasm_common::{FunctionType, LocalFunctionIndex, MemoryIndex, SignatureIndex, TableIndex}; use wasm_common::{FunctionType, LocalFunctionIndex, SignatureIndex};
use wasmer_compiler::{Compilation, CompileError, FunctionBody, Target}; use wasmer_compiler::{CompileError, FunctionBody};
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
use wasmer_compiler::{Compiler, CompilerConfig}; use wasmer_compiler::{Compiler, CompilerConfig};
use wasmer_engine::{ use wasmer_engine::{
@@ -13,8 +13,7 @@ use wasmer_engine::{
SerializeError, Tunables, SerializeError, Tunables,
}; };
use wasmer_runtime::{ use wasmer_runtime::{
InstanceHandle, MemoryPlan, Module, SignatureRegistry, TablePlan, VMFunctionBody, InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline,
VMSharedSignatureIndex, VMTrampoline,
}; };
/// A WebAssembly `JIT` Engine. /// A WebAssembly `JIT` Engine.
@@ -129,7 +128,7 @@ impl Engine for JITEngine {
resolver: &dyn Resolver, resolver: &dyn Resolver,
) -> Result<InstanceHandle, InstantiationError> { ) -> Result<InstanceHandle, InstantiationError> {
let compiled_module = compiled_module.downcast_ref::<CompiledModule>().unwrap(); let compiled_module = compiled_module.downcast_ref::<CompiledModule>().unwrap();
unsafe { compiled_module.instantiate(&self, resolver, Box::new(())) } compiled_module.instantiate(&self, resolver, Box::new(()))
} }
/// Finish the instantiation of a WebAssembly module /// Finish the instantiation of a WebAssembly module
@@ -139,7 +138,7 @@ impl Engine for JITEngine {
handle: &InstanceHandle, handle: &InstanceHandle,
) -> Result<(), InstantiationError> { ) -> Result<(), InstantiationError> {
let compiled_module = compiled_module.downcast_ref::<CompiledModule>().unwrap(); let compiled_module = compiled_module.downcast_ref::<CompiledModule>().unwrap();
unsafe { compiled_module.finish_instantiation(&handle) } compiled_module.finish_instantiation(&handle)
} }
/// Serializes a WebAssembly module /// Serializes a WebAssembly module

View File

@@ -13,7 +13,7 @@ use wasmer_runtime::VMFunctionBody;
/// Links a module, patching the allocated functions with the /// Links a module, patching the allocated functions with the
/// required relocations and jump tables. /// required relocations and jump tables.
pub fn link_module( pub fn link_module(
module: &Module, _module: &Module,
allocated_functions: &PrimaryMap<LocalFunctionIndex, *mut [VMFunctionBody]>, allocated_functions: &PrimaryMap<LocalFunctionIndex, *mut [VMFunctionBody]>,
jt_offsets: &PrimaryMap<LocalFunctionIndex, JumpTableOffsets>, jt_offsets: &PrimaryMap<LocalFunctionIndex, JumpTableOffsets>,
relocations: Relocations, relocations: Relocations,

View File

@@ -4,25 +4,23 @@
use crate::engine::{JITEngine, JITEngineInner}; use crate::engine::{JITEngine, JITEngineInner};
use crate::link::link_module; use crate::link::link_module;
use crate::serialize::{SerializableCompilation, SerializableModule}; use crate::serialize::{SerializableCompilation, SerializableModule};
use serde::{Deserialize, Serialize};
use std::any::Any; use std::any::Any;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use wasm_common::entity::{BoxedSlice, EntityRef, PrimaryMap}; use wasm_common::entity::{BoxedSlice, PrimaryMap};
use wasm_common::{ use wasm_common::{
DataInitializer, LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, DataInitializer, LocalFunctionIndex, MemoryIndex, OwnedDataInitializer, SignatureIndex,
MemoryIndex, OwnedDataInitializer, SignatureIndex, TableIndex, TableIndex,
}; };
use wasmer_compiler::CompileError; use wasmer_compiler::CompileError;
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
use wasmer_compiler::ModuleEnvironment; use wasmer_compiler::ModuleEnvironment;
use wasmer_engine::{ use wasmer_engine::{
register_frame_info, resolve_imports, CompiledModule as BaseCompiledModule, DeserializeError, register_frame_info, resolve_imports, CompiledModule as BaseCompiledModule, DeserializeError,
Engine, GlobalFrameInfoRegistration, InstantiationError, LinkError, Resolver, RuntimeError, Engine, GlobalFrameInfoRegistration, InstantiationError, Resolver, RuntimeError,
SerializableFunctionFrameInfo, SerializeError, Tunables, SerializableFunctionFrameInfo, SerializeError,
}; };
use wasmer_runtime::{ use wasmer_runtime::{
InstanceHandle, LinearMemory, Module, SignatureRegistry, Table, VMFunctionBody, InstanceHandle, Module, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex,
VMGlobalDefinition, VMSharedSignatureIndex,
}; };
use wasmer_runtime::{MemoryPlan, TablePlan}; use wasmer_runtime::{MemoryPlan, TablePlan};

View File

@@ -15,7 +15,7 @@ use wasmer_runtime::{InstanceHandle, VMSharedSignatureIndex, VMTrampoline};
/// such as: JIT or Native. /// such as: JIT or Native.
pub trait Engine { pub trait Engine {
/// Get the tunables /// Get the tunables
fn tunables(&self) -> &Tunables; fn tunables(&self) -> &dyn Tunables;
/// Register a signature /// Register a signature
fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex; fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex;
@@ -30,7 +30,7 @@ pub trait Engine {
fn validate(&self, binary: &[u8]) -> Result<(), CompileError>; fn validate(&self, binary: &[u8]) -> Result<(), CompileError>;
/// Compile a WebAssembly binary /// Compile a WebAssembly binary
fn compile(&self, binary: &[u8]) -> Result<Arc<CompiledModule>, CompileError>; fn compile(&self, binary: &[u8]) -> Result<Arc<dyn CompiledModule>, CompileError>;
/// Instantiates a WebAssembly module /// Instantiates a WebAssembly module
unsafe fn instantiate( unsafe fn instantiate(
@@ -50,13 +50,13 @@ pub trait Engine {
fn serialize(&self, compiled_module: &dyn CompiledModule) -> Result<Vec<u8>, SerializeError>; fn serialize(&self, compiled_module: &dyn CompiledModule) -> Result<Vec<u8>, SerializeError>;
/// Deserializes a WebAssembly module /// Deserializes a WebAssembly module
fn deserialize(&self, bytes: &[u8]) -> Result<Arc<CompiledModule>, DeserializeError>; fn deserialize(&self, bytes: &[u8]) -> Result<Arc<dyn CompiledModule>, DeserializeError>;
/// Deserializes a WebAssembly module from a path /// Deserializes a WebAssembly module from a path
fn deserialize_from_file( fn deserialize_from_file(
&self, &self,
file_ref: &Path, file_ref: &Path,
) -> Result<Arc<CompiledModule>, DeserializeError> { ) -> Result<Arc<dyn CompiledModule>, DeserializeError> {
// TODO: Return an IoDeserializeError, so we don't need to map the error // TODO: Return an IoDeserializeError, so we don't need to map the error
let bytes = let bytes =
std::fs::read(file_ref).map_err(|e| DeserializeError::Generic(format!("{}", e)))?; std::fs::read(file_ref).map_err(|e| DeserializeError::Generic(format!("{}", e)))?;

View File

@@ -1,6 +1,3 @@
use crate::error::InstantiationError;
use std::sync::Arc;
use wasmer_runtime::InstanceHandle;
use wasmer_runtime::Module; use wasmer_runtime::Module;
use downcast_rs::{impl_downcast, Downcast}; use downcast_rs::{impl_downcast, Downcast};

View File

@@ -66,7 +66,7 @@ impl ModuleFrameInfo {
} }
fn process_function_debug_info(&mut self, local_index: LocalFunctionIndex) { fn process_function_debug_info(&mut self, local_index: LocalFunctionIndex) {
let mut func = self.frame_infos.get_mut(local_index).unwrap(); let func = self.frame_infos.get_mut(local_index).unwrap();
let processed: CompiledFunctionFrameInfo = match func { let processed: CompiledFunctionFrameInfo = match func {
SerializableFunctionFrameInfo::Processed(_) => { SerializableFunctionFrameInfo::Processed(_) => {
// This should be a no-op on processed info // This should be a no-op on processed info
@@ -187,7 +187,8 @@ impl GlobalFrameInfo {
pub fn maybe_process_frame(&mut self, pc: usize) -> Option<()> { pub fn maybe_process_frame(&mut self, pc: usize) -> Option<()> {
let module = self.module_info_mut(pc)?; let module = self.module_info_mut(pc)?;
let func = module.function_info(pc)?; let func = module.function_info(pc)?;
module.process_function_debug_info(func.local_index); let func_local_index = func.local_index;
module.process_function_debug_info(func_local_index);
Some(()) Some(())
} }

View File

@@ -1,8 +1,8 @@
use crate::error::LinkError; use crate::error::LinkError;
use wasm_common::entity::{EntityRef, PrimaryMap}; use wasm_common::entity::{EntityRef, PrimaryMap};
use wasm_common::{ use wasm_common::{
GlobalIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, MemoryType, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex, MemoryType, TableIndex,
TableIndex, TableType, TableType,
}; };
use wasmer_runtime::MemoryError; use wasmer_runtime::MemoryError;
use wasmer_runtime::{LinearMemory, Module, Table, VMGlobalDefinition}; use wasmer_runtime::{LinearMemory, Module, Table, VMGlobalDefinition};

View File

@@ -1,3 +1,5 @@
//! Runtime build script compiles C code using setjmp for trap handling.
fn main() { fn main() {
println!("cargo:rerun-if-changed=src/trap/helpers.c"); println!("cargo:rerun-if-changed=src/trap/helpers.c");
cc::Build::new() cc::Build::new()

View File

@@ -1,5 +1,4 @@
use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport}; use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
use std::collections::HashSet;
use wasm_common::entity::{BoxedSlice, PrimaryMap}; use wasm_common::entity::{BoxedSlice, PrimaryMap};
use wasm_common::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex}; use wasm_common::{FunctionIndex, GlobalIndex, MemoryIndex, TableIndex};

View File

@@ -18,7 +18,7 @@ use more_asserts::assert_lt;
use std::alloc::{self, Layout}; use std::alloc::{self, Layout};
use std::any::Any; use std::any::Any;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::collections::{HashMap, HashSet}; use std::collections::HashMap;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::sync::Arc; use std::sync::Arc;
use std::{mem, ptr, slice}; use std::{mem, ptr, slice};

View File

@@ -19,7 +19,6 @@ mod types;
pub use self::builder::*; pub use self::builder::*;
pub use self::types::*; pub use self::types::*;
use crate::syscalls::types::*; use crate::syscalls::types::*;
use crate::WasiEnv;
use generational_arena::Arena; use generational_arena::Arena;
pub use generational_arena::Index as Inode; pub use generational_arena::Index as Inode;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -52,15 +51,6 @@ const STDOUT_DEFAULT_RIGHTS: __wasi_rights_t = __WASI_RIGHT_FD_DATASYNC
| __WASI_RIGHT_POLL_FD_READWRITE; | __WASI_RIGHT_POLL_FD_READWRITE;
const STDERR_DEFAULT_RIGHTS: __wasi_rights_t = STDOUT_DEFAULT_RIGHTS; const STDERR_DEFAULT_RIGHTS: __wasi_rights_t = STDOUT_DEFAULT_RIGHTS;
/// Get WasiState from a Ctx
///
/// # Safety
/// - This function must be called on a `WasiEnv` that was created with `WasiState`
/// in the data field
pub unsafe fn get_wasi_state<'a>(env: &'a mut WasiEnv) -> &'a mut WasiState {
env.state_mut()
}
/// A completely aribtrary "big enough" number used as the upper limit for /// A completely aribtrary "big enough" number used as the upper limit for
/// the number of symlinks that can be traversed when resolving a path /// the number of symlinks that can be traversed when resolving a path
pub const MAX_SYMLINKS: u32 = 128; pub const MAX_SYMLINKS: u32 = 128;

View File

@@ -1,4 +1,4 @@
use wasmer::{ExternType, ImportType, Module}; use wasmer::{ExternType, Module};
#[allow(dead_code)] #[allow(dead_code)]
/// Check if a provided module is compiled for some version of WASI. /// Check if a provided module is compiled for some version of WASI.

View File

@@ -1,5 +1,5 @@
//! When wasmer self-update is executed, this is what gets executed //! When wasmer self-update is executed, this is what gets executed
use anyhow::{bail, Context, Result}; use anyhow::{Context, Result};
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use structopt::StructOpt; use structopt::StructOpt;
@@ -35,6 +35,6 @@ impl SelfUpdate {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
fn inner_execute(&self) -> Result<()> { fn inner_execute(&self) -> Result<()> {
bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io"); anyhow::bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
} }
} }