Fix all compilation issues simplifying the code

This commit is contained in:
Syrus Akbary
2020-12-04 15:58:23 -08:00
parent 601294dfaf
commit 1ee0146954
14 changed files with 24 additions and 24 deletions

View File

@@ -77,7 +77,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// In this situation, the compiler is
// `wasmer_compiler_cranelift`. The compiler is responsible to
// compile the Wasm module into executable code.
let mut compiler_config = Cranelift::default();
let compiler_config = Cranelift::default();
println!("Creating Native engine...");
// Define the engine that will drive everything.

View File

@@ -43,7 +43,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// In this situation, the compiler is
// `wasmer_compiler_cranelift`. The compiler is responsible to
// compile the Wasm module into executable code.
let mut compiler_config = Cranelift::default();
let compiler_config = Cranelift::default();
println!("Creating Native engine...");
// Define the engine that will drive everything.

View File

@@ -80,7 +80,7 @@ impl Default for Store {
// sure this function doesn't emit a compile error even if
// more than one compiler is enabled.
#[allow(unreachable_code)]
fn get_config() -> impl CompilerConfig + Send + Sync + 'static {
fn get_config() -> impl CompilerConfig + 'static {
cfg_if::cfg_if! {
if #[cfg(feature = "default-cranelift")] {
wasmer_compiler_cranelift::Cranelift::default()
@@ -96,7 +96,7 @@ impl Default for Store {
#[allow(unreachable_code, unused_mut)]
fn get_engine(
mut config: impl CompilerConfig + Send + Sync + 'static,
mut config: impl CompilerConfig + 'static,
) -> impl Engine + Send + Sync {
cfg_if::cfg_if! {
if #[cfg(feature = "default-jit")] {

View File

@@ -194,7 +194,7 @@ impl CompilerConfig for Cranelift {
}
/// Transform it into the compiler
fn compiler(self: Box<Self>) -> Box<dyn Compiler + Send> {
fn compiler(self: Box<Self>) -> Box<dyn Compiler> {
Box::new(CraneliftCompiler::new(*self))
}

View File

@@ -207,7 +207,7 @@ impl CompilerConfig for LLVM {
}
/// Transform it into the compiler.
fn compiler(self: Box<Self>) -> Box<dyn Compiler + Send> {
fn compiler(self: Box<Self>) -> Box<dyn Compiler> {
Box::new(LLVMCompiler::new(*self))
}

View File

@@ -54,7 +54,7 @@ impl CompilerConfig for Singlepass {
}
/// Transform it into the compiler
fn compiler(self: Box<Self>) -> Box<dyn Compiler + Send> {
fn compiler(self: Box<Self>) -> Box<dyn Compiler> {
Box::new(SinglepassCompiler::new(*self))
}

View File

@@ -23,7 +23,7 @@ To create a compiler, one needs to implement two traits:
/// The compiler configuration options.
pub trait CompilerConfig {
/// Gets the custom compiler config
fn compiler(&self) -> Box<dyn Compiler + Send>;
fn compiler(&self) -> Box<dyn Compiler>;
}
/// An implementation of a compiler from parsed WebAssembly module to compiled native code.

View File

@@ -37,7 +37,7 @@ pub trait CompilerConfig {
}
/// Gets the custom compiler config
fn compiler(self: Box<Self>) -> Box<dyn Compiler + Send>;
fn compiler(self: Box<Self>) -> Box<dyn Compiler>;
/// Gets the default features for this compiler in the given target
fn default_features_for_target(&self, _target: &Target) -> Features {
@@ -49,9 +49,9 @@ pub trait CompilerConfig {
}
impl<T> From<T> for Box<dyn CompilerConfig + Send + Sync + 'static>
impl<T> From<T> for Box<dyn CompilerConfig + 'static>
where
T: CompilerConfig + Send + Sync + 'static,
T: CompilerConfig + 'static,
{
fn from(other: T) -> Self {
Box::new(other)
@@ -59,7 +59,7 @@ where
}
/// An implementation of a Compiler from parsed WebAssembly module to Compiled native code.
pub trait Compiler {
pub trait Compiler: Send {
/// Validates a module.
///
/// It returns the a succesful Result in case is valid, `CompileError` in case is not.

View File

@@ -4,7 +4,7 @@ use wasmer_compiler::{CompilerConfig, Features, Target};
/// The JIT builder
pub struct JIT {
#[allow(dead_code)]
compiler_config: Option<Box<dyn CompilerConfig + Send + Sync>>,
compiler_config: Option<Box<dyn CompilerConfig>>,
target: Option<Target>,
features: Option<Features>,
}
@@ -13,7 +13,7 @@ impl JIT {
/// Create a new JIT
pub fn new<T>(compiler_config: T) -> Self
where
T: Into<Box<dyn CompilerConfig + Send + Sync>>,
T: Into<Box<dyn CompilerConfig>>,
{
Self {
compiler_config: Some(compiler_config.into()),

View File

@@ -28,7 +28,7 @@ pub struct JITEngine {
impl JITEngine {
/// Create a new `JITEngine` with the given config
#[cfg(feature = "compiler")]
pub fn new(compiler: Box<dyn Compiler + Send>, target: Target, features: Features) -> Self {
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
Self {
inner: Arc::new(Mutex::new(JITEngineInner {
compiler: Some(compiler),
@@ -141,7 +141,7 @@ impl Engine for JITEngine {
pub struct JITEngineInner {
/// The compiler
#[cfg(feature = "compiler")]
compiler: Option<Box<dyn Compiler + Send>>,
compiler: Option<Box<dyn Compiler>>,
/// The features to compile the Wasm module with
features: Features,
/// The code memory is responsible of publishing the compiled

View File

@@ -13,7 +13,7 @@ impl Native {
/// Create a new Native
pub fn new<T>(compiler_config: T) -> Self
where
T: Into<Box<dyn CompilerConfig + Send + Sync>>,
T: Into<Box<dyn CompilerConfig>>,
{
let mut compiler_config = compiler_config.into();
compiler_config.enable_pic();
@@ -91,7 +91,7 @@ mod tests {
self.enabled_pic = true;
}
fn compiler(&self) -> Box<dyn Compiler + Send> {
fn compiler(&self) -> Box<dyn Compiler> {
unimplemented!("compiler not implemented");
}

View File

@@ -28,7 +28,7 @@ pub struct NativeEngine {
impl NativeEngine {
/// Create a new `NativeEngine` with the given config
#[cfg(feature = "compiler")]
pub fn new(compiler: Box<dyn Compiler + Send>, target: Target, features: Features) -> Self {
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
let host_target = Triple::host();
let is_cross_compiling = target.triple() != &host_target;
@@ -213,7 +213,7 @@ impl Into<&'static str> for Linker {
pub struct NativeEngineInner {
/// The compiler
#[cfg(feature = "compiler")]
compiler: Option<Box<dyn Compiler + Send>>,
compiler: Option<Box<dyn Compiler>>,
/// The WebAssembly features to use
#[cfg(feature = "compiler")]
features: Features,

View File

@@ -13,7 +13,7 @@ impl ObjectFile {
/// Create a new ObjectFile
pub fn new<T>(compiler_config: T) -> Self
where
T: Into<Box<dyn CompilerConfig + Send + Sync>>,
T: Into<Box<dyn CompilerConfig>>,
{
let mut compiler_config = compiler_config.into();
compiler_config.enable_pic();
@@ -91,7 +91,7 @@ mod tests {
self.enabled_pic = true;
}
fn compiler(&self) -> Box<dyn Compiler + Send> {
fn compiler(&self) -> Box<dyn Compiler> {
unimplemented!("compiler not implemented");
}

View File

@@ -23,7 +23,7 @@ pub struct ObjectFileEngine {
impl ObjectFileEngine {
/// Create a new `ObjectFileEngine` with the given config
#[cfg(feature = "compiler")]
pub fn new(compiler: Box<dyn Compiler + Send>, target: Target, features: Features) -> Self {
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
Self {
inner: Arc::new(Mutex::new(ObjectFileEngineInner {
compiler: Some(compiler),
@@ -168,7 +168,7 @@ impl Engine for ObjectFileEngine {
pub struct ObjectFileEngineInner {
/// The compiler
#[cfg(feature = "compiler")]
compiler: Option<Box<dyn Compiler + Send>>,
compiler: Option<Box<dyn Compiler>>,
/// The WebAssembly features to use
#[cfg(feature = "compiler")]
features: Features,