From 303d44cb0f5254dbbeb8d5a244cd44e90c3b166a Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 19:31:35 -0800 Subject: [PATCH 01/30] Remove backend code --- lib/runtime-core/Cargo.toml | 2 +- lib/runtime-core/src/backend.rs | 70 --------------------------------- 2 files changed, 1 insertion(+), 71 deletions(-) diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index c4cd63baa99..840e1941a5c 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -52,7 +52,7 @@ cc = "1.0" [features] debug = [] trace = ["debug"] -# backend flags used in conditional compilation of Backend::variants +# backend flags no longer used "backend-cranelift" = [] "backend-singlepass" = [] "backend-llvm" = [] diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index 19995f3a7a8..d98e9442aee 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -22,60 +22,6 @@ pub mod sys { } pub use crate::sig_registry::SigRegistry; -/// Enum used to select which compiler should be used to generate code. -#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] -pub enum Backend { - Cranelift, - Singlepass, - LLVM, - Auto, -} - -impl Backend { - /// Get a list of the currently enabled (via feature flag) backends. - pub fn variants() -> &'static [&'static str] { - &[ - #[cfg(feature = "backend-cranelift")] - "cranelift", - #[cfg(feature = "backend-singlepass")] - "singlepass", - #[cfg(feature = "backend-llvm")] - "llvm", - "auto", - ] - } - - /// Stable string representation of the backend. - /// It can be used as part of a cache key, for example. - pub fn to_string(&self) -> &'static str { - match self { - Backend::Cranelift => "cranelift", - Backend::Singlepass => "singlepass", - Backend::LLVM => "llvm", - Backend::Auto => "auto", - } - } -} - -impl Default for Backend { - fn default() -> Self { - Backend::Cranelift - } -} - -impl std::str::FromStr for Backend { - type Err = String; - fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { - "singlepass" => Ok(Backend::Singlepass), - "cranelift" => Ok(Backend::Cranelift), - "llvm" => Ok(Backend::LLVM), - "auto" => Ok(Backend::Auto), - _ => Err(format!("The backend {} doesn't exist", s)), - } - } -} - /// The target architecture for code generation. #[derive(Copy, Clone, Debug)] pub enum Architecture { @@ -104,22 +50,6 @@ pub struct InlineBreakpoint { pub ty: InlineBreakpointType, } -#[cfg(test)] -mod backend_test { - use super::*; - use std::str::FromStr; - - #[test] - fn str_repr_matches() { - // if this test breaks, think hard about why it's breaking - // can we avoid having these be different? - - for &backend in &[Backend::Cranelift, Backend::LLVM, Backend::Singlepass] { - assert_eq!(backend, Backend::from_str(backend.to_string()).unwrap()); - } - } -} - /// This type cannot be constructed from /// outside the runtime crate. pub struct Token { From d4e964519dc6c11732f8aab06e9134cde68de313 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 19:32:06 -0800 Subject: [PATCH 02/30] Move requires pre validation into the ModuleCodeGenerator --- lib/runtime-core/src/codegen.rs | 18 +++++++----------- lib/singlepass-backend/src/codegen_x64.rs | 9 +++++---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 94b1fd41c8a..e7c65b29cbe 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -4,7 +4,7 @@ use crate::fault::FaultInfo; use crate::{ backend::RunnableModule, - backend::{Backend, CacheGen, Compiler, CompilerConfig, Features, Token}, + backend::{CacheGen, Compiler, CompilerConfig, Features, Token}, cache::{Artifact, Error as CacheError}, error::{CompileError, CompileResult}, module::{ModuleInfo, ModuleInner}, @@ -94,6 +94,11 @@ pub trait ModuleCodeGenerator, RM: RunnableModule, /// Returns the backend id associated with this MCG. fn backend_id() -> Backend; + /// It sets if the current compiler requires validation before compilation + fn requires_pre_validation(&self) -> bool { + true + } + /// Feeds the compiler config. fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> { Ok(()) @@ -222,7 +227,7 @@ impl< compiler_config: CompilerConfig, _: Token, ) -> CompileResult { - if requires_pre_validation(MCG::backend_id()) { + if MCG::requires_pre_validation() { validate_with_features(wasm, &compiler_config.features)?; } @@ -263,15 +268,6 @@ impl< } } -fn requires_pre_validation(backend: Backend) -> bool { - match backend { - Backend::Cranelift => true, - Backend::LLVM => true, - Backend::Singlepass => false, - Backend::Auto => false, - } -} - /// A sink for parse events. pub struct EventSink<'a, 'b> { buffer: SmallVec<[Event<'a, 'b>; 2]>, diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index ccc1089931b..091658e5870 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -646,12 +646,13 @@ impl ModuleCodeGenerator } } - fn new_with_target(_: Option, _: Option, _: Option) -> Self { - unimplemented!("cross compilation is not available for singlepass backend") + /// Singlepass does validation as it compiles + fn requires_pre_validation(&self) -> bool { + false } - fn backend_id() -> Backend { - Backend::Singlepass + fn new_with_target(_: Option, _: Option, _: Option) -> Self { + unimplemented!("cross compilation is not available for singlepass backend") } fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> { From d7154fe791645410c4419a85d41e32d736e025ee Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 20:11:56 -0800 Subject: [PATCH 03/30] Remove Backend dependency --- Cargo.lock | 2 + lib/clif-backend/src/code.rs | 6 +-- lib/llvm-backend/src/code.rs | 4 +- lib/middleware-common-tests/src/lib.rs | 21 +++++---- lib/runtime-core/src/cache.rs | 25 ++--------- lib/runtime-core/src/codegen.rs | 9 ++-- lib/runtime-core/src/module.rs | 4 +- lib/runtime-core/src/parse.rs | 5 +-- lib/runtime-core/src/state.rs | 4 +- lib/runtime-core/src/tiering.rs | 12 ++--- lib/runtime-core/src/vm.rs | 4 +- lib/runtime/Cargo.toml | 8 ++++ lib/runtime/src/cache.rs | 25 +++++++++-- lib/runtime/src/lib.rs | 54 +++++++++++++++++++++-- lib/singlepass-backend/src/codegen_x64.rs | 8 +++- 15 files changed, 127 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f5d6d7c81c..27ee3e30d5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1752,6 +1752,8 @@ dependencies = [ "criterion", "lazy_static", "memmap", + "serde", + "serde_derive", "tempfile", "wabt", "wasmer-clif-backend", diff --git a/lib/clif-backend/src/code.rs b/lib/clif-backend/src/code.rs index 1811afb2452..390dbfecb53 100644 --- a/lib/clif-backend/src/code.rs +++ b/lib/clif-backend/src/code.rs @@ -18,7 +18,7 @@ use std::mem; use std::sync::{Arc, RwLock}; use wasmer_runtime_core::error::CompileError; use wasmer_runtime_core::{ - backend::{Backend, CacheGen, Token}, + backend::{CacheGen, Token}, cache::{Artifact, Error as CacheError}, codegen::*, memory::MemoryType, @@ -58,8 +58,8 @@ impl ModuleCodeGenerator unimplemented!("cross compilation is not available for clif backend") } - fn backend_id() -> Backend { - Backend::Cranelift + fn backend_id() -> String { + "cranelift".to_string() } fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> { diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index d8761e44a7c..871d5d48f7b 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -8721,8 +8721,8 @@ impl<'ctx> ModuleCodeGenerator, LLVMBackend, Cod } } - fn backend_id() -> Backend { - Backend::LLVM + fn backend_id() -> String { + "llvm".to_string() } fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> { diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index e3c0596d106..55ce39a9177 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -8,40 +8,40 @@ mod tests { use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; use wasmer_runtime_core::state::CodeVersion; use wasmer_runtime_core::{ - backend::{Backend, Compiler}, + backend::Compiler, compile_with, imports, Func, }; #[cfg(feature = "llvm")] - fn get_compiler(limit: u64) -> (impl Compiler, Backend) { + fn get_compiler(limit: u64) -> impl Compiler { use wasmer_llvm_backend::ModuleCodeGenerator as LLVMMCG; let c: StreamingCompiler = StreamingCompiler::new(move || { let mut chain = MiddlewareChain::new(); chain.push(Metering::new(limit)); chain }); - (c, Backend::LLVM) + c } #[cfg(feature = "singlepass")] - fn get_compiler(limit: u64) -> (impl Compiler, Backend) { + fn get_compiler(limit: u64) -> impl Compiler { use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG; let c: StreamingCompiler = StreamingCompiler::new(move || { let mut chain = MiddlewareChain::new(); chain.push(Metering::new(limit)); chain }); - (c, Backend::Singlepass) + c } #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] compile_error!("compiler not specified, activate a compiler via features"); #[cfg(feature = "clif")] - fn get_compiler(_limit: u64) -> (impl Compiler, Backend) { + fn get_compiler(_limit: u64) -> impl Compiler { compile_error!("cranelift does not implement metering"); use wasmer_clif_backend::CraneliftCompiler; - (CraneliftCompiler::new(), Backend::Cranelift) + CraneliftCompiler::new() } // Assemblyscript @@ -161,7 +161,12 @@ mod tests { let add_to: Func<(i32, i32), i32> = instance.func("add_to").unwrap(); - let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { + let cv_pushed = if let Some(msm) = instance + .module + .runnable_module + .borrow() + .get_module_state_map() + { push_code_version(CodeVersion { baseline: true, msm: msm, diff --git a/lib/runtime-core/src/cache.rs b/lib/runtime-core/src/cache.rs index e924cd9f5dd..376a4ba60ab 100644 --- a/lib/runtime-core/src/cache.rs +++ b/lib/runtime-core/src/cache.rs @@ -3,12 +3,11 @@ //! and loaded to allow skipping compilation and fast startup. use crate::{ - backend::Backend, - module::{Module, ModuleInfo}, + module::ModuleInfo, sys::Memory, }; use blake2b_simd::blake2bp; -use std::{fmt, io, mem, slice}; +use std::{io, mem, slice}; /// Indicates the invalid type of invalid cache file #[derive(Debug)] @@ -35,7 +34,7 @@ pub enum Error { /// The cached binary has been invalidated. InvalidatedCache, /// The current backend does not support caching. - UnsupportedBackend(Backend), + UnsupportedBackend(String), } impl From for Error { @@ -246,24 +245,6 @@ impl Artifact { } } -/// A generic cache for storing and loading compiled wasm modules. -/// -/// The `wasmer-runtime` supplies a naive `FileSystemCache` api. -pub trait Cache { - /// Error type to return when load error occurs - type LoadError: fmt::Debug; - /// Error type to return when store error occurs - type StoreError: fmt::Debug; - - /// loads a module using the default `Backend` - fn load(&self, key: WasmHash) -> Result; - /// loads a cached module using a specific `Backend` - fn load_with_backend(&self, key: WasmHash, backend: Backend) - -> Result; - /// Store a module into the cache with the given key - fn store(&mut self, key: WasmHash, module: Module) -> Result<(), Self::StoreError>; -} - /// A unique ID generated from the version of Wasmer for use with cache versioning pub const WASMER_VERSION_HASH: &'static str = include_str!(concat!(env!("OUT_DIR"), "/wasmer_version_hash.txt")); diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index e7c65b29cbe..e6f7558e14a 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -92,10 +92,10 @@ pub trait ModuleCodeGenerator, RM: RunnableModule, ) -> Self; /// Returns the backend id associated with this MCG. - fn backend_id() -> Backend; + fn backend_id() -> String; /// It sets if the current compiler requires validation before compilation - fn requires_pre_validation(&self) -> bool { + fn requires_pre_validation() -> bool { true } @@ -231,8 +231,8 @@ impl< validate_with_features(wasm, &compiler_config.features)?; } - let mut mcg = match MCG::backend_id() { - Backend::LLVM => MCG::new_with_target( + let mut mcg = match MCG::backend_id().as_ref() { + "llvm" => MCG::new_with_target( compiler_config.triple.clone(), compiler_config.cpu_name.clone(), compiler_config.cpu_features.clone(), @@ -242,7 +242,6 @@ impl< let mut chain = (self.middleware_chain_generator)(); let info = crate::parse::read_module( wasm, - MCG::backend_id(), &mut mcg, &mut chain, &compiler_config, diff --git a/lib/runtime-core/src/module.rs b/lib/runtime-core/src/module.rs index 9b991edccf0..cf99abc274f 100644 --- a/lib/runtime-core/src/module.rs +++ b/lib/runtime-core/src/module.rs @@ -1,7 +1,7 @@ //! The module module contains the implementation data structures and helper functions used to //! manipulate and access wasm modules. use crate::{ - backend::{Backend, RunnableModule}, + backend::RunnableModule, cache::{Artifact, Error as CacheError}, error, import::ImportObject, @@ -65,7 +65,7 @@ pub struct ModuleInfo { /// Map signature index to function signature. pub signatures: Map, /// Backend. - pub backend: Backend, + pub backend: String, /// Table of namespace indexes. pub namespace_table: StringTable, diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index d41efedcb55..5a050f5c1b0 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -3,7 +3,7 @@ use crate::codegen::*; use crate::{ - backend::{Backend, CompilerConfig, RunnableModule}, + backend::{CompilerConfig, RunnableModule}, error::CompileError, module::{ DataInitializer, ExportIndex, ImportName, ModuleInfo, StringTable, StringTableBuilder, @@ -57,7 +57,6 @@ pub fn read_module< E: Debug, >( wasm: &[u8], - backend: Backend, mcg: &mut MCG, middlewares: &mut MiddlewareChain, compiler_config: &CompilerConfig, @@ -83,7 +82,7 @@ pub fn read_module< func_assoc: Map::new(), signatures: Map::new(), - backend: backend, + backend: MCG::backend_id(), namespace_table: StringTable::new(), name_table: StringTable::new(), diff --git a/lib/runtime-core/src/state.rs b/lib/runtime-core/src/state.rs index 06dc9240027..870e955a515 100644 --- a/lib/runtime-core/src/state.rs +++ b/lib/runtime-core/src/state.rs @@ -2,7 +2,7 @@ //! state could read or updated at runtime. Use cases include generating stack traces, switching //! generated code from one tier to another, or serializing state of a running instace. -use crate::backend::{Backend, RunnableModule}; +use crate::backend::RunnableModule; use std::collections::BTreeMap; use std::ops::Bound::{Included, Unbounded}; use std::sync::Arc; @@ -186,7 +186,7 @@ pub struct CodeVersion { pub base: usize, /// The backend used to compile this module. - pub backend: Backend, + pub backend: String, /// `RunnableModule` for this code version. pub runnable_module: Arc>, diff --git a/lib/runtime-core/src/tiering.rs b/lib/runtime-core/src/tiering.rs index 697348ae398..15dc1bd1937 100644 --- a/lib/runtime-core/src/tiering.rs +++ b/lib/runtime-core/src/tiering.rs @@ -1,6 +1,6 @@ //! The tiering module supports switching between code compiled with different optimization levels //! as runtime. -use crate::backend::{Backend, Compiler, CompilerConfig}; +use crate::backend::{Compiler, CompilerConfig}; use crate::compile_with_config; use crate::fault::{ catch_unsafe_unwind, ensure_sighandler, pop_code_version, push_code_version, with_ctx, @@ -43,7 +43,7 @@ struct OptimizationState { } struct OptimizationOutcome { - backend_id: Backend, + backend_id: String, module: Module, } @@ -54,7 +54,7 @@ unsafe impl Sync for CtxWrapper {} unsafe fn do_optimize( binary: &[u8], - backend_id: Backend, + backend_id: String, compiler: Box, ctx: &Mutex, state: &OptimizationState, @@ -87,8 +87,8 @@ pub unsafe fn run_tiering ShellExitOperation>( import_object: &ImportObject, start_raw: extern "C" fn(&mut Ctx), baseline: &mut Instance, - baseline_backend: Backend, - optimized_backends: Vec<(Backend, Box Box + Send>)>, + baseline_backend: String, + optimized_backends: Vec<(String, Box Box + Send>)>, interactive_shell: F, ) -> Result<(), String> { ensure_sighandler(); @@ -140,7 +140,7 @@ pub unsafe fn run_tiering ShellExitOperation>( })); loop { - let new_optimized: Option<(Backend, &mut Instance)> = { + let new_optimized: Option<(String, &mut Instance)> = { let mut outcome = opt_state.outcome.lock().unwrap(); if let Some(x) = outcome.take() { let instance = x diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index f6f1c39a98f..2cbb32d32e7 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -1064,7 +1064,7 @@ mod vm_ctx_tests { fn generate_module() -> ModuleInner { use super::Func; - use crate::backend::{sys::Memory, Backend, CacheGen, RunnableModule}; + use crate::backend::{sys::Memory, CacheGen, RunnableModule}; use crate::cache::Error as CacheError; use crate::typed_func::Wasm; use crate::types::{LocalFuncIndex, SigIndex}; @@ -1118,7 +1118,7 @@ mod vm_ctx_tests { func_assoc: Map::new(), signatures: Map::new(), - backend: Backend::Cranelift, + backend: "".to_string(), namespace_table: StringTable::new(), name_table: StringTable::new(), diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index f90d57272a9..e3b135226cc 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -24,6 +24,14 @@ path = "../clif-backend" version = "0.12.0" optional = true +# Dependencies for caching. +[dependencies.serde] +version = "1.0" +# This feature is required for serde to support serializing/deserializing reference counted pointers (e.g. Rc and Arc). +features = ["rc"] +[dependencies.serde_derive] +version = "1.0" + [dev-dependencies] tempfile = "3.1" criterion = "0.2" diff --git a/lib/runtime/src/cache.rs b/lib/runtime/src/cache.rs index 30e08c1a077..dd27d54aaf9 100644 --- a/lib/runtime/src/cache.rs +++ b/lib/runtime/src/cache.rs @@ -5,6 +5,7 @@ use crate::Module; use memmap::Mmap; use std::{ + fmt, fs::{create_dir_all, File}, io::{self, Write}, path::PathBuf, @@ -12,9 +13,27 @@ use std::{ use wasmer_runtime_core::cache::Error as CacheError; pub use wasmer_runtime_core::{ - backend::Backend, - cache::{Artifact, Cache, WasmHash}, + cache::{Artifact, WasmHash}, }; +pub use super::Backend; + +/// A generic cache for storing and loading compiled wasm modules. +/// +/// The `wasmer-runtime` supplies a naive `FileSystemCache` api. +pub trait Cache { + /// Error type to return when load error occurs + type LoadError: fmt::Debug; + /// Error type to return when store error occurs + type StoreError: fmt::Debug; + + /// loads a module using the default `Backend` + fn load(&self, key: WasmHash) -> Result; + /// loads a cached module using a specific `Backend` + fn load_with_backend(&self, key: WasmHash, backend: Backend) + -> Result; + /// Store a module into the cache with the given key + fn store(&mut self, key: WasmHash, module: Module) -> Result<(), Self::StoreError>; +} /// Representation of a directory that contains compiled wasm artifacts. /// @@ -105,7 +124,7 @@ impl Cache for FileSystemCache { wasmer_runtime_core::load_cache_with( serialized_cache, crate::compiler_for_backend(backend) - .ok_or_else(|| CacheError::UnsupportedBackend(backend))? + .ok_or_else(|| CacheError::UnsupportedBackend(backend.to_string().to_owned()))? .as_ref(), ) } diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index af130f483c5..debd372db03 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -91,7 +91,10 @@ //! [`wasmer-singlepass-backend`]: https://crates.io/crates/wasmer-singlepass-backend //! [`wasmer-clif-backend`]: https://crates.io/crates/wasmer-clif-backend -pub use wasmer_runtime_core::backend::{Backend, Features}; +#[macro_use] +extern crate serde_derive; + +pub use wasmer_runtime_core::backend::Features; pub use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; pub use wasmer_runtime_core::export::Export; pub use wasmer_runtime_core::global::Global; @@ -144,6 +147,52 @@ pub mod cache; pub use wasmer_runtime_core::backend::{Compiler, CompilerConfig}; +/// Enum used to select which compiler should be used to generate code. +#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] +pub enum Backend { + #[cfg(feature = "singlepass")] + /// Singlepass backend + Singlepass, + #[cfg(feature = "cranelift")] + /// Cranelift backend + Cranelift, + #[cfg(feature = "llvm")] + /// LLVM backend + LLVM, + /// Auto backend + Auto, +} + +impl Backend { + /// Stable string representation of the backend. + /// It can be used as part of a cache key, for example. + pub fn to_string(&self) -> &'static str { + match self { + #[cfg(feature = "cranelift")] + Backend::Cranelift => "cranelift", + #[cfg(feature = "singlepass")] + Backend::Singlepass => "singlepass", + #[cfg(feature = "llvm")] + Backend::LLVM => "llvm", + Backend::Auto => "auto", + } + } +} + +impl Default for Backend { + fn default() -> Self { + #[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))] + return Backend::Singlepass; + + #[cfg(any(feature = "default-backend-cranelift", feature = "docs"))] + return Backend::Cranelift; + + #[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))] + return Backend::LLVM; + } +} + + /// Compile WebAssembly binary code into a [`Module`]. /// This function is useful if it is necessary to /// compile a module before it can be instantiated @@ -268,9 +317,6 @@ pub fn compiler_for_backend(backend: Backend) -> Option> { #[cfg(feature = "default-backend-llvm")] return Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())); } - - #[cfg(not(all(feature = "llvm", feature = "singlepass", feature = "cranelift")))] - _ => None, } } diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 091658e5870..e10b0fc98c4 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -23,7 +23,7 @@ use std::{ use wasmer_runtime_core::{ backend::{ sys::{Memory, Protect}, - Architecture, Backend, CacheGen, CompilerConfig, InlineBreakpoint, InlineBreakpointType, + Architecture, CacheGen, CompilerConfig, InlineBreakpoint, InlineBreakpointType, MemoryBoundCheckMode, RunnableModule, Token, }, cache::{Artifact, Error as CacheError}, @@ -647,10 +647,14 @@ impl ModuleCodeGenerator } /// Singlepass does validation as it compiles - fn requires_pre_validation(&self) -> bool { + fn requires_pre_validation() -> bool { false } + fn backend_id() -> String { + "singlepass".to_string() + } + fn new_with_target(_: Option, _: Option, _: Option) -> Self { unimplemented!("cross compilation is not available for singlepass backend") } From 18421e36235c7ccb669a6a7b0742979754223d8a Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 21:00:06 -0800 Subject: [PATCH 04/30] Make all tests pass --- CHANGELOG.md | 1 + lib/llvm-backend/src/code.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9528b5f48..296a274843e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#1098](https://github.com/wasmerio/wasmer/pull/1098) Remove `backend::Backend` from `wasmer_runtime_core` - [#1097](https://github.com/wasmerio/wasmer/pull/1097) Move inline breakpoint outside of runtime backend - [#1095](https://github.com/wasmerio/wasmer/pull/1095) Update to cranelift 0.52. - [#1092](https://github.com/wasmerio/wasmer/pull/1092) Add `get_utf8_string_with_nul` to `WasmPtr` to read nul-terminated strings from memory. diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 871d5d48f7b..4333dbbf0b2 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -32,7 +32,7 @@ use std::{ }; use wasmer_runtime_core::{ - backend::{Backend, CacheGen, CompilerConfig, Token}, + backend::{CacheGen, CompilerConfig, Token}, cache::{Artifact, Error as CacheError}, codegen::*, memory::MemoryType, From f3b9ecbaea7ad6341669afde22c0d381f1bf537c Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 21:06:19 -0800 Subject: [PATCH 05/30] Remove backend specific features from root Cargo --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a37286dcd2e..6dd5334291d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,19 +86,16 @@ extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] fast-tests = [] backend-cranelift = [ "wasmer-clif-backend", - "wasmer-runtime-core/backend-cranelift", "wasmer-runtime/cranelift", "wasmer-middleware-common-tests/clif", ] backend-llvm = [ "wasmer-llvm-backend", - "wasmer-runtime-core/backend-llvm", "wasmer-runtime/llvm", "wasmer-middleware-common-tests/llvm", ] backend-singlepass = [ "wasmer-singlepass-backend", - "wasmer-runtime-core/backend-singlepass", "wasmer-runtime/singlepass", "wasmer-middleware-common-tests/singlepass", ] From 71be5bea161802fc2e04a12616a44fb6a8f60b6f Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:01:18 -0800 Subject: [PATCH 06/30] Improved syntax --- lib/middleware-common-tests/src/lib.rs | 5 +---- lib/runtime-core/src/cache.rs | 5 +---- lib/runtime-core/src/codegen.rs | 7 +------ lib/runtime/src/cache.rs | 6 ++---- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index 55ce39a9177..d6fe2644f94 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -7,10 +7,7 @@ mod tests { use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; use wasmer_runtime_core::state::CodeVersion; - use wasmer_runtime_core::{ - backend::Compiler, - compile_with, imports, Func, - }; + use wasmer_runtime_core::{backend::Compiler, compile_with, imports, Func}; #[cfg(feature = "llvm")] fn get_compiler(limit: u64) -> impl Compiler { diff --git a/lib/runtime-core/src/cache.rs b/lib/runtime-core/src/cache.rs index 376a4ba60ab..f753b94232e 100644 --- a/lib/runtime-core/src/cache.rs +++ b/lib/runtime-core/src/cache.rs @@ -2,10 +2,7 @@ //! serializing compiled wasm code to a binary format. The binary format can be persisted, //! and loaded to allow skipping compilation and fast startup. -use crate::{ - module::ModuleInfo, - sys::Memory, -}; +use crate::{module::ModuleInfo, sys::Memory}; use blake2b_simd::blake2bp; use std::{io, mem, slice}; diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index e6f7558e14a..376b8337e5e 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -240,12 +240,7 @@ impl< _ => MCG::new(), }; let mut chain = (self.middleware_chain_generator)(); - let info = crate::parse::read_module( - wasm, - &mut mcg, - &mut chain, - &compiler_config, - )?; + let info = crate::parse::read_module(wasm, &mut mcg, &mut chain, &compiler_config)?; let (exec_context, cache_gen) = mcg.finalize(&info.read().unwrap()) .map_err(|x| CompileError::InternalError { diff --git a/lib/runtime/src/cache.rs b/lib/runtime/src/cache.rs index dd27d54aaf9..dbcda5b8781 100644 --- a/lib/runtime/src/cache.rs +++ b/lib/runtime/src/cache.rs @@ -11,11 +11,9 @@ use std::{ path::PathBuf, }; -use wasmer_runtime_core::cache::Error as CacheError; -pub use wasmer_runtime_core::{ - cache::{Artifact, WasmHash}, -}; pub use super::Backend; +use wasmer_runtime_core::cache::Error as CacheError; +pub use wasmer_runtime_core::cache::{Artifact, WasmHash}; /// A generic cache for storing and loading compiled wasm modules. /// From 0cb3df256d668c3e8ef0fc0715f8b9ba19898d86 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:01:44 -0800 Subject: [PATCH 07/30] Removed unnecessary checks --- Makefile | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/Makefile b/Makefile index a96c0d6ee9e..5699909d7ed 100644 --- a/Makefile +++ b/Makefile @@ -222,38 +222,9 @@ check: check-bench # as default, and test a minimal set of features with only one backend # at a time. cargo check --manifest-path lib/runtime/Cargo.toml - # Check some of the cases where deterministic execution could matter - cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution" - cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ - --features=default-backend-singlepass,deterministic-execution - cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ - --features=default-backend-llvm,deterministic-execution - cargo check --release --manifest-path lib/runtime/Cargo.toml $(RUNTIME_CHECK) \ - --features=cranelift,cache,debug,llvm,singlepass,default-backend-singlepass - $(RUNTIME_CHECK) --release \ - --features=cranelift,cache,llvm,singlepass,default-backend-singlepass - $(RUNTIME_CHECK) \ - --features=cranelift,cache,debug,llvm,singlepass,default-backend-cranelift - $(RUNTIME_CHECK) --release \ - --features=cranelift,cache,llvm,singlepass,default-backend-cranelift - $(RUNTIME_CHECK) \ - --features=cranelift,cache,debug,llvm,singlepass,default-backend-llvm - $(RUNTIME_CHECK) --release \ - --features=cranelift,cache,llvm,singlepass,default-backend-llvm - $(RUNTIME_CHECK) \ - --features=singlepass,default-backend-singlepass,debug - $(RUNTIME_CHECK) --release \ - --features=singlepass,default-backend-singlepass - $(RUNTIME_CHECK) \ - --features=cranelift,default-backend-cranelift,debug - $(RUNTIME_CHECK) --release \ - --features=cranelift,default-backend-cranelift - $(RUNTIME_CHECK) \ - --features=llvm,default-backend-llvm,debug - $(RUNTIME_CHECK) --release \ - --features=llvm,default-backend-llvm + --features=singlepass,cranelift,llvm,cache,debug,deterministic-execution # Release release: From 5d2ea93a89fc484293b0fd0d03f02f8b81f5c23e Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:03:08 -0800 Subject: [PATCH 08/30] Fixed changelog link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 296a274843e..90d14ded237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## **[Unreleased]** -- [#1098](https://github.com/wasmerio/wasmer/pull/1098) Remove `backend::Backend` from `wasmer_runtime_core` +- [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core` - [#1097](https://github.com/wasmerio/wasmer/pull/1097) Move inline breakpoint outside of runtime backend - [#1095](https://github.com/wasmerio/wasmer/pull/1095) Update to cranelift 0.52. - [#1092](https://github.com/wasmerio/wasmer/pull/1092) Add `get_utf8_string_with_nul` to `WasmPtr` to read nul-terminated strings from memory. From ac0c5c93ce558435392a5f5d0451874e7253ae62 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:10:57 -0800 Subject: [PATCH 09/30] Fixed lint --- lib/runtime/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index debd372db03..2447f4761a7 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -183,7 +183,7 @@ impl Default for Backend { fn default() -> Self { #[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))] return Backend::Singlepass; - + #[cfg(any(feature = "default-backend-cranelift", feature = "docs"))] return Backend::Cranelift; @@ -192,7 +192,6 @@ impl Default for Backend { } } - /// Compile WebAssembly binary code into a [`Module`]. /// This function is useful if it is necessary to /// compile a module before it can be instantiated From e57677b63f9750cb937ba71158dba68e7a504cb1 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:33:46 -0800 Subject: [PATCH 10/30] Make cranelift optional for middleware --- lib/middleware-common-tests/Cargo.toml | 4 +-- lib/middleware-common-tests/src/lib.rs | 35 +++++++++----------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/lib/middleware-common-tests/Cargo.toml b/lib/middleware-common-tests/Cargo.toml index f86e6189a95..72e84c8797d 100644 --- a/lib/middleware-common-tests/Cargo.toml +++ b/lib/middleware-common-tests/Cargo.toml @@ -10,12 +10,12 @@ publish = false [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.12.0" } wasmer-middleware-common = { path = "../middleware-common", version = "0.12.0" } -wasmer-clif-backend = { path = "../clif-backend", version = "0.12.0" } +wasmer-clif-backend = { path = "../clif-backend", version = "0.12.0", optional = true } wasmer-llvm-backend = { path = "../llvm-backend", version = "0.12.0", features = ["test"], optional = true } wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.12.0", optional = true } [features] -clif = [] +clif = ["wasmer-clif-backend"] llvm = ["wasmer-llvm-backend"] singlepass = ["wasmer-singlepass-backend"] diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index d6fe2644f94..b2a99767e24 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -3,27 +3,23 @@ mod tests { use wabt::wat2wasm; use wasmer_middleware_common::metering::*; - use wasmer_runtime_core::backend::RunnableModule; use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; + use wasmer_runtime_core::codegen::ModuleCodeGenerator; use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; use wasmer_runtime_core::state::CodeVersion; use wasmer_runtime_core::{backend::Compiler, compile_with, imports, Func}; #[cfg(feature = "llvm")] - fn get_compiler(limit: u64) -> impl Compiler { - use wasmer_llvm_backend::ModuleCodeGenerator as LLVMMCG; - let c: StreamingCompiler = StreamingCompiler::new(move || { - let mut chain = MiddlewareChain::new(); - chain.push(Metering::new(limit)); - chain - }); - c - } + use wasmer_llvm_backend::ModuleCodeGenerator as MCG; #[cfg(feature = "singlepass")] + use wasmer_singlepass_backend::ModuleCodeGenerator as MCG; + + #[cfg(feature = "clif")] + compile_error!("cranelift does not implement metering yet"); + fn get_compiler(limit: u64) -> impl Compiler { - use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG; - let c: StreamingCompiler = StreamingCompiler::new(move || { + let c: StreamingCompiler = StreamingCompiler::new(move || { let mut chain = MiddlewareChain::new(); chain.push(Metering::new(limit)); chain @@ -34,13 +30,6 @@ mod tests { #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] compile_error!("compiler not specified, activate a compiler via features"); - #[cfg(feature = "clif")] - fn get_compiler(_limit: u64) -> impl Compiler { - compile_error!("cranelift does not implement metering"); - use wasmer_clif_backend::CraneliftCompiler; - CraneliftCompiler::new() - } - // Assemblyscript // export function add_to(x: i32, y: i32): i32 { // for(var i = 0; i < x; i++){ @@ -106,7 +95,7 @@ mod tests { let limit = 100u64; - let (compiler, backend_id) = get_compiler(limit); + let compiler = get_compiler(limit); let module = compile_with(&wasm_binary, &compiler).unwrap(); let import_object = imports! {}; @@ -121,8 +110,8 @@ mod tests { baseline: true, msm: msm, base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, + backend: MCG::backend_id(), runnable_module: instance.module.runnable_module.clone(), - backend: backend_id, }); true } else { @@ -148,7 +137,7 @@ mod tests { let limit = 100u64; - let (compiler, backend_id) = get_compiler(limit); + let compiler = get_compiler(limit); let module = compile_with(&wasm_binary, &compiler).unwrap(); let import_object = imports! {}; @@ -168,7 +157,7 @@ mod tests { baseline: true, msm: msm, base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, - backend: backend_id, + backend: MCG::backend_id(), runnable_module: instance.module.runnable_module.clone(), }); true From d36d8835289382b655f7ee57691e151b30e812db Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:56:39 -0800 Subject: [PATCH 11/30] Fix lint --- lib/middleware-common-tests/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index b2a99767e24..4b6a791680a 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -3,8 +3,8 @@ mod tests { use wabt::wat2wasm; use wasmer_middleware_common::metering::*; - use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; use wasmer_runtime_core::codegen::ModuleCodeGenerator; + use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; use wasmer_runtime_core::state::CodeVersion; use wasmer_runtime_core::{backend::Compiler, compile_with, imports, Func}; From 8cff1adf5cd3b13e176e0d07ac5bb38e996df542 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:57:18 -0800 Subject: [PATCH 12/30] Fix wasmer binary --- lib/runtime/src/lib.rs | 33 +++++++++++++++++++++++++++++++-- src/bin/wasmer.rs | 27 ++++++++++++++------------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 2447f4761a7..339b29aec8f 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -164,14 +164,27 @@ pub enum Backend { } impl Backend { + /// Get a list of the currently enabled (via feature flag) backends. + pub fn variants() -> &'static [&'static str] { + &[ + #[cfg(feature = "singlepass")] + "singlepass", + #[cfg(feature = "cranelift")] + "cranelift", + #[cfg(feature = "llvm")] + "llvm", + "auto", + ] + } + /// Stable string representation of the backend. /// It can be used as part of a cache key, for example. pub fn to_string(&self) -> &'static str { match self { - #[cfg(feature = "cranelift")] - Backend::Cranelift => "cranelift", #[cfg(feature = "singlepass")] Backend::Singlepass => "singlepass", + #[cfg(feature = "cranelift")] + Backend::Cranelift => "cranelift", #[cfg(feature = "llvm")] Backend::LLVM => "llvm", Backend::Auto => "auto", @@ -192,6 +205,22 @@ impl Default for Backend { } } +impl std::str::FromStr for Backend { + type Err = String; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + #[cfg(feature = "singlepass")] + "singlepass" => Ok(Backend::Singlepass), + #[cfg(feature = "cranelift")] + "cranelift" => Ok(Backend::Cranelift), + #[cfg(feature = "llvm")] + "llvm" => Ok(Backend::LLVM), + "auto" => Ok(Backend::Auto), + _ => Err(format!("The backend {} doesn't exist", s)), + } + } +} + /// Compile WebAssembly binary code into a [`Module`]. /// This function is useful if it is necessary to /// compile a module before it can be instantiated diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 04ef6d3a2f3..91538b96b6f 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -30,13 +30,13 @@ use wasmer_llvm_backend::{ }; use wasmer_runtime::{ cache::{Cache as BaseCache, FileSystemCache, WasmHash}, - Value, VERSION, + Backend, Value, VERSION, }; #[cfg(feature = "managed")] use wasmer_runtime_core::tiering::{run_tiering, InteractiveShellContext, ShellExitOperation}; use wasmer_runtime_core::{ self, - backend::{Backend, Compiler, CompilerConfig, Features, MemoryBoundCheckMode}, + backend::{Compiler, CompilerConfig, Features, MemoryBoundCheckMode}, debug, loader::{Instance as LoadedInstance, LocalLoader}, Module, @@ -143,7 +143,7 @@ struct Run { #[structopt(parse(from_os_str))] path: PathBuf, - /// Name of the backend to use. (x86_64) + /// Name of the backend to use (x86_64) #[cfg(target_arch = "x86_64")] #[structopt( long = "backend", @@ -153,7 +153,7 @@ struct Run { )] backend: Backend, - /// Name of the backend to use. (aarch64) + /// Name of the backend to use (aarch64) #[cfg(target_arch = "aarch64")] #[structopt( long = "backend", @@ -486,7 +486,7 @@ fn execute_wasi( baseline: true, msm: msm, base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, - backend: options.backend, + backend: options.backend.to_string().to_owned(), runnable_module: instance.module.runnable_module.clone(), }); true @@ -618,8 +618,15 @@ fn execute_wasm(options: &Run) -> Result<(), String> { }; // Don't error on --enable-all for other backends. - if options.features.simd && options.backend != Backend::LLVM { - return Err("SIMD is only supported in the LLVM backend for now".to_string()); + if options.features.simd { + #[cfg(feature = "backend-llvm")] + { + if options.backend != Backend::LLVM { + return Err("SIMD is only supported in the LLVM backend for now".to_string()); + } + } + #[cfg(not(feature = "backend-llvm"))] + return Err("SIMD is not supported in this backend".to_string()); } if !utils::is_wasm_binary(&wasm_binary) { @@ -1031,16 +1038,10 @@ fn get_compiler_by_backend(backend: Backend, _opts: &Run) -> Option return None, #[cfg(feature = "backend-cranelift")] Backend::Cranelift => Box::new(CraneliftCompiler::new()), - #[cfg(not(feature = "backend-cranelift"))] - Backend::Cranelift => return None, #[cfg(feature = "backend-llvm")] Backend::LLVM => Box::new(LLVMCompiler::new()), - #[cfg(not(feature = "backend-llvm"))] - Backend::LLVM => return None, Backend::Auto => return None, }) } From 720d4ec99c34f6a8eaaefa66b7b67cdb5903a973 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 23:26:43 -0800 Subject: [PATCH 13/30] Fix checks on binary --- Makefile | 2 +- src/bin/wasmer.rs | 44 ++++++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 5699909d7ed..2a5461c5189 100644 --- a/Makefile +++ b/Makefile @@ -224,7 +224,7 @@ check: check-bench cargo check --manifest-path lib/runtime/Cargo.toml $(RUNTIME_CHECK) \ - --features=singlepass,cranelift,llvm,cache,debug,deterministic-execution + --features=default-backend-singlepass,singlepass,cranelift,llvm,cache,debug,deterministic-execution # Release release: diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 91538b96b6f..dec6d2eb545 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -12,7 +12,7 @@ extern crate structopt; use std::collections::HashMap; use std::env; use std::error::Error; -use std::fs::{metadata, read_to_string, File}; +use std::fs::{read_to_string, File}; use std::io; use std::io::Read; use std::path::PathBuf; @@ -941,29 +941,41 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation { } } -fn update_backend(options: &mut Run) { - let binary_size = match metadata(&options.path) { - Ok(wasm_binary) => wasm_binary.len(), - Err(_e) => 0, - }; - +fn get_backend(backend: Backend, _path: &PathBuf) -> Backend { // Update backend when a backend flag is `auto`. // Use the Singlepass backend if it's enabled and the file provided is larger // than 10MiB (10485760 bytes), or it's enabled and the target architecture // is AArch64. Otherwise, use the Cranelift backend. - if options.backend == Backend::Auto { - if Backend::variants().contains(&Backend::Singlepass.to_string()) - && (binary_size > 10485760 || cfg!(target_arch = "aarch64")) - { - options.backend = Backend::Singlepass; - } else { - options.backend = Backend::Cranelift; + match backend { + Backend::Auto => { + #[cfg(feature = "backend-singlepass")] + { + let binary_size = match &_path.metadata() { + Ok(wasm_binary) => wasm_binary.len(), + Err(_e) => 0, + }; + if binary_size > 10485760 || cfg!(target_arch = "aarch64") + { + return Backend::Singlepass; + } + } + + #[cfg(feature = "backend-cranelift")] { + return Backend::Cranelift; + } + + #[cfg(feature = "backend-llvm")] { + return Backend::LLVM; + } + + panic!("Can't find any backend"); } + backend => backend } } fn run(options: &mut Run) { - update_backend(options); + options.backend = get_backend(options.backend, &options.path); match execute_wasm(options) { Ok(()) => {} Err(message) => { @@ -1042,7 +1054,7 @@ fn get_compiler_by_backend(backend: Backend, _opts: &Run) -> Option Box::new(CraneliftCompiler::new()), #[cfg(feature = "backend-llvm")] Backend::LLVM => Box::new(LLVMCompiler::new()), - Backend::Auto => return None, + _ => return None, }) } From f967770ccf25de04b01b014f829e9c9fbf6ac22e Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 23:32:29 -0800 Subject: [PATCH 14/30] Fixed linting --- src/bin/wasmer.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index dec6d2eb545..ff15a306fd8 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -954,23 +954,24 @@ fn get_backend(backend: Backend, _path: &PathBuf) -> Backend { Ok(wasm_binary) => wasm_binary.len(), Err(_e) => 0, }; - if binary_size > 10485760 || cfg!(target_arch = "aarch64") - { + if binary_size > 10485760 || cfg!(target_arch = "aarch64") { return Backend::Singlepass; } } - - #[cfg(feature = "backend-cranelift")] { + + #[cfg(feature = "backend-cranelift")] + { return Backend::Cranelift; } - #[cfg(feature = "backend-llvm")] { + #[cfg(feature = "backend-llvm")] + { return Backend::LLVM; } panic!("Can't find any backend"); } - backend => backend + backend => backend, } } From 63f1d6b7babeb12e91cb3e389cdbe7cd1aada084 Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 7 Jan 2020 15:01:45 +0100 Subject: [PATCH 15/30] Fixed path variable name --- src/bin/wasmer.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index ff15a306fd8..339b0a1bbac 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -941,7 +941,8 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation { } } -fn get_backend(backend: Backend, _path: &PathBuf) -> Backend { +#[allow(unused_variables)] +fn get_backend(backend: Backend, path: &PathBuf) -> Backend { // Update backend when a backend flag is `auto`. // Use the Singlepass backend if it's enabled and the file provided is larger // than 10MiB (10485760 bytes), or it's enabled and the target architecture @@ -950,7 +951,7 @@ fn get_backend(backend: Backend, _path: &PathBuf) -> Backend { Backend::Auto => { #[cfg(feature = "backend-singlepass")] { - let binary_size = match &_path.metadata() { + let binary_size = match &path.metadata() { Ok(wasm_binary) => wasm_binary.len(), Err(_e) => 0, }; From 3b9cdc396d4e72adb62476e787960075944844a8 Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 7 Jan 2020 15:01:55 +0100 Subject: [PATCH 16/30] Recovered deleted tests --- lib/runtime/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 339b29aec8f..a839ab93ea0 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -350,3 +350,26 @@ pub fn compiler_for_backend(backend: Backend) -> Option> { /// The current version of this crate. pub const VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[cfg(test)] +mod test { + use super::*; + use std::str::FromStr; + + #[test] + fn str_repr_matches() { + // if this test breaks, think hard about why it's breaking + // can we avoid having these be different? + + for &backend in &[ + #[cfg(feature = "cranelift")] + Backend::Cranelift, + #[cfg(feature = "llvm")] + Backend::LLVM, + #[cfg(feature = "singlepass")] + Backend::Singlepass + ] { + assert_eq!(backend, Backend::from_str(backend.to_string()).unwrap()); + } + } +} From 59945a8875e9518f788344076612c3d946517dcd Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 7 Jan 2020 15:02:02 +0100 Subject: [PATCH 17/30] Use detault --- lib/runtime-core/src/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 2cbb32d32e7..2864bf8ed64 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -1118,7 +1118,7 @@ mod vm_ctx_tests { func_assoc: Map::new(), signatures: Map::new(), - backend: "".to_string(), + backend: Default::default(), namespace_table: StringTable::new(), name_table: StringTable::new(), From ee6949bcb4aa8de753593d0322e6cd205b7aec08 Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 7 Jan 2020 16:10:36 +0100 Subject: [PATCH 18/30] Add checks back into makefile --- Makefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Makefile b/Makefile index 2a5461c5189..272a473127d 100644 --- a/Makefile +++ b/Makefile @@ -222,8 +222,38 @@ check: check-bench # as default, and test a minimal set of features with only one backend # at a time. cargo check --manifest-path lib/runtime/Cargo.toml + # Check some of the cases where deterministic execution could matter + cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution" + cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ + --features=default-backend-singlepass,deterministic-execution + cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ + --features=default-backend-llvm,deterministic-execution + cargo check --release --manifest-path lib/runtime/Cargo.toml $(RUNTIME_CHECK) \ + --features=cranelift,cache,debug,llvm,singlepass,default-backend-singlepass + $(RUNTIME_CHECK) --release \ + --features=cranelift,cache,llvm,singlepass,default-backend-singlepass + $(RUNTIME_CHECK) \ + --features=cranelift,cache,debug,llvm,singlepass,default-backend-cranelift + $(RUNTIME_CHECK) --release \ + --features=cranelift,cache,llvm,singlepass,default-backend-cranelift + $(RUNTIME_CHECK) \ + --features=cranelift,cache,debug,llvm,singlepass,default-backend-llvm + $(RUNTIME_CHECK) --release \ + --features=cranelift,cache,llvm,singlepass,default-backend-llvm + $(RUNTIME_CHECK) \ + --features=singlepass,default-backend-singlepass,debug + $(RUNTIME_CHECK) --release \ + --features=singlepass,default-backend-singlepass + $(RUNTIME_CHECK) \ + --features=cranelift,default-backend-cranelift,debug + $(RUNTIME_CHECK) --release \ + --features=cranelift,default-backend-cranelift + $(RUNTIME_CHECK) \ + --features=llvm,default-backend-llvm,debug + $(RUNTIME_CHECK) --release \ + --features=llvm,default-backend-llvm --features=default-backend-singlepass,singlepass,cranelift,llvm,cache,debug,deterministic-execution # Release From d544f5a80f8edc732c2dc02b0815c17542625b2e Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 7 Jan 2020 16:14:58 +0100 Subject: [PATCH 19/30] Run formatting --- lib/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index a839ab93ea0..a4913896d4b 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -367,7 +367,7 @@ mod test { #[cfg(feature = "llvm")] Backend::LLVM, #[cfg(feature = "singlepass")] - Backend::Singlepass + Backend::Singlepass, ] { assert_eq!(backend, Backend::from_str(backend.to_string()).unwrap()); } From f353ac00eb6bd18e65e490f1f075c297f5fa9903 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 10 Jan 2020 13:40:21 +0100 Subject: [PATCH 20/30] Remove unused backend flags --- lib/runtime-core/Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index 840e1941a5c..b8d781ed4c2 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -52,9 +52,5 @@ cc = "1.0" [features] debug = [] trace = ["debug"] -# backend flags no longer used -"backend-cranelift" = [] -"backend-singlepass" = [] -"backend-llvm" = [] managed = [] deterministic-execution = ["wasmparser/deterministic"] From cc28804efe6f2e9521f6efe3f68695522d447bdb Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 10 Jan 2020 17:00:26 -0800 Subject: [PATCH 21/30] Update the name of experimental IO devices in fs --- lib/wasi-experimental-io-devices/src/lib.rs | 25 ++++++--------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/wasi-experimental-io-devices/src/lib.rs b/lib/wasi-experimental-io-devices/src/lib.rs index e5acd15c841..ae78fadec9b 100644 --- a/lib/wasi-experimental-io-devices/src/lib.rs +++ b/lib/wasi-experimental-io-devices/src/lib.rs @@ -451,21 +451,10 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { cursor: 0, }); - let dev_fd = unsafe { + let base_dir_fd = unsafe { fs.open_dir_all( VIRTUAL_ROOT_FD, - "dev".to_string(), - ALL_RIGHTS, - ALL_RIGHTS, - 0, - ) - .map_err(|e| format!("fb: Failed to create dev folder {:?}", e))? - }; - - let fb_fd = unsafe { - fs.open_dir_all( - VIRTUAL_ROOT_FD, - "sys/class/graphics/wasmerfb0".to_string(), + "_wasmer/fb0".to_string(), ALL_RIGHTS, ALL_RIGHTS, 0, @@ -475,7 +464,7 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { let _fd = fs .open_file_at( - dev_fd, + base_dir_fd, input_file, Fd::READ, "input".to_string(), @@ -489,10 +478,10 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { let _fd = fs .open_file_at( - dev_fd, + base_dir_fd, frame_buffer_file, Fd::READ | Fd::WRITE, - "wasmerfb0".to_string(), + "fb".to_string(), ALL_RIGHTS, ALL_RIGHTS, 0, @@ -503,7 +492,7 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { let _fd = fs .open_file_at( - fb_fd, + base_dir_fd, resolution_file, Fd::READ | Fd::WRITE, "virtual_size".to_string(), @@ -517,7 +506,7 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { let _fd = fs .open_file_at( - fb_fd, + base_dir_fd, index_file, Fd::READ | Fd::WRITE, "buffer_index_display".to_string(), From 5b5258902124350ca970295b9361044f3ffa0e8f Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 10 Jan 2020 17:10:46 -0800 Subject: [PATCH 22/30] Update the experimental io device path to include /dev/ --- lib/wasi-experimental-io-devices/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wasi-experimental-io-devices/src/lib.rs b/lib/wasi-experimental-io-devices/src/lib.rs index ae78fadec9b..292ec362a1a 100644 --- a/lib/wasi-experimental-io-devices/src/lib.rs +++ b/lib/wasi-experimental-io-devices/src/lib.rs @@ -454,7 +454,7 @@ pub fn initialize(fs: &mut WasiFs) -> Result<(), String> { let base_dir_fd = unsafe { fs.open_dir_all( VIRTUAL_ROOT_FD, - "_wasmer/fb0".to_string(), + "_wasmer/dev/fb0".to_string(), ALL_RIGHTS, ALL_RIGHTS, 0, From 8fd143368d2625c48774a81e6bf8e18d3ba64c58 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2020 07:56:50 +0000 Subject: [PATCH 23/30] Bump getrandom from 0.1.13 to 0.1.14 Bumps [getrandom](https://github.com/rust-random/getrandom) from 0.1.13 to 0.1.14. - [Release notes](https://github.com/rust-random/getrandom/releases) - [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/getrandom/compare/v0.1.13...v0.1.14) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f088c25da23..6589e44e0ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -471,9 +471,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ "cfg-if", "libc", @@ -1634,9 +1634,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.7.0" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" @@ -1745,7 +1745,7 @@ dependencies = [ "regex", "rustc_version", "semver", - "smallvec 1.1.0", + "smallvec 0.6.13", "wabt", "wasmer-runtime-core", "wasmparser", @@ -1832,7 +1832,7 @@ dependencies = [ "serde-bench", "serde_bytes", "serde_derive", - "smallvec 1.1.0", + "smallvec 0.6.13", "wasmparser", "winapi", ] @@ -1861,7 +1861,7 @@ dependencies = [ "nix", "serde", "serde_derive", - "smallvec 1.1.0", + "smallvec 0.6.13", "wasmer-runtime-core", ] From 00618e852e507c9273660c3f310814c32c8d1294 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2020 07:57:23 +0000 Subject: [PATCH 24/30] Bump parking_lot from 0.9.0 to 0.10.0 Bumps [parking_lot](https://github.com/Amanieu/parking_lot) from 0.9.0 to 0.10.0. - [Release notes](https://github.com/Amanieu/parking_lot/releases) - [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md) - [Commits](https://github.com/Amanieu/parking_lot/compare/0.9.0...0.10.0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6589e44e0ed..4aee3b2ddda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,7 +558,7 @@ dependencies = [ "libc", "llvm-sys", "once_cell", - "parking_lot 0.10.0", + "parking_lot", "regex", ] @@ -827,17 +827,6 @@ dependencies = [ "md5", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core 0.6.2", - "rustc_version", -] - [[package]] name = "parking_lot" version = "0.10.0" @@ -845,22 +834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" dependencies = [ "lock_api", - "parking_lot_core 0.7.0", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi", + "parking_lot_core", ] [[package]] @@ -1826,7 +1800,7 @@ dependencies = [ "libc", "nix", "page_size", - "parking_lot 0.9.0", + "parking_lot", "rustc_version", "serde", "serde-bench", From f18a4280a66420a95bb6385f2c0376d222ff9a2a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2020 07:58:45 +0000 Subject: [PATCH 25/30] Bump regex from 1.3.1 to 1.3.3 Bumps [regex](https://github.com/rust-lang/regex) from 1.3.1 to 1.3.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.3.1...1.3.3) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aee3b2ddda..17404893767 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,9 +1150,9 @@ checksum = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" [[package]] name = "regex" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +checksum = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" dependencies = [ "aho-corasick", "memchr", @@ -1469,9 +1469,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "0.3.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ "lazy_static", ] From 22e35fc6706f74273b6ac55092fcb9e49bca3f5d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2020 07:59:14 +0000 Subject: [PATCH 26/30] Bump cc from 1.0.48 to 1.0.50 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.48 to 1.0.50. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.48...1.0.50) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17404893767..1282e76f35d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,9 +128,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" +checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" [[package]] name = "cfg-if" From aa6189a06a3a2ace7dd80f0eb3e082c666234303 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 21:00:06 -0800 Subject: [PATCH 27/30] Make all tests pass --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62805ceb3ff..1db96939461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#1128](https://github.com/wasmerio/wasmer/pull/1128) Fix a crash when a host function is missing and the `allow_missing_functions` flag is enabled - [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core` +- [#1098](https://github.com/wasmerio/wasmer/pull/1098) Remove `backend::Backend` from `wasmer_runtime_core` - [#1097](https://github.com/wasmerio/wasmer/pull/1097) Move inline breakpoint outside of runtime backend - [#1095](https://github.com/wasmerio/wasmer/pull/1095) Update to cranelift 0.52. - [#1092](https://github.com/wasmerio/wasmer/pull/1092) Add `get_utf8_string_with_nul` to `WasmPtr` to read nul-terminated strings from memory. From 4faa78b38c7a94f23be72aea28b0eea3ef482a9e Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 20 Dec 2019 22:03:08 -0800 Subject: [PATCH 28/30] Fixed changelog link --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db96939461..7485882d6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [#1128](https://github.com/wasmerio/wasmer/pull/1128) Fix a crash when a host function is missing and the `allow_missing_functions` flag is enabled - [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core` - [#1098](https://github.com/wasmerio/wasmer/pull/1098) Remove `backend::Backend` from `wasmer_runtime_core` +- [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core` - [#1097](https://github.com/wasmerio/wasmer/pull/1097) Move inline breakpoint outside of runtime backend - [#1095](https://github.com/wasmerio/wasmer/pull/1095) Update to cranelift 0.52. - [#1092](https://github.com/wasmerio/wasmer/pull/1092) Add `get_utf8_string_with_nul` to `WasmPtr` to read nul-terminated strings from memory. From 846c632b50db6e78bac8a81aa5057beea2ae08ae Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 10 Jan 2020 13:53:53 +0100 Subject: [PATCH 29/30] Fixed runtime check --- lib/middleware-common-tests/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index 4b6a791680a..076a6a94c6b 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -150,7 +150,6 @@ mod tests { let cv_pushed = if let Some(msm) = instance .module .runnable_module - .borrow() .get_module_state_map() { push_code_version(CodeVersion { From 3892ea827dc4d420957e390a29830a8b42a27737 Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 13 Jan 2020 12:04:39 +0100 Subject: [PATCH 30/30] Fixed lint --- lib/middleware-common-tests/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/middleware-common-tests/src/lib.rs b/lib/middleware-common-tests/src/lib.rs index 076a6a94c6b..20d69bb3d0a 100644 --- a/lib/middleware-common-tests/src/lib.rs +++ b/lib/middleware-common-tests/src/lib.rs @@ -147,11 +147,7 @@ mod tests { let add_to: Func<(i32, i32), i32> = instance.func("add_to").unwrap(); - let cv_pushed = if let Some(msm) = instance - .module - .runnable_module - .get_module_state_map() - { + let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { push_code_version(CodeVersion { baseline: true, msm: msm,