Renamed dynasm backend to singlepass

This commit is contained in:
Syrus 2019-04-11 12:44:03 -07:00
parent 1f06e90729
commit d67bfdb2c5
24 changed files with 100 additions and 76 deletions

View File

@ -152,7 +152,7 @@ jobs:
sudo apt-get install -y cmake
curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
# Use rust nightly (for dynasm, for now)
# Use rust nightly (for singlepass, for now)
- run: rustup default nightly-2019-04-11
- run:
name: Tests
@ -220,7 +220,7 @@ jobs:
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo --version
# Use rust nightly (for dynasm, for now)
# Use rust nightly (for singlepass, for now)
- run: rustup default nightly-2019-04-11
- run:
name: Tests
@ -242,7 +242,7 @@ jobs:
ulimit -n 8000
sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680
make test-emscripten-clif
make test-emscripten-dynasm
make test-emscripten-singlepass
- run:
name: Release Build
command: |
@ -288,9 +288,9 @@ jobs:
- run: |
export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/"
make test
make test-dynasm
make test-singlepass
make test-emscripten-clif
make test-emscripten-dynasm
make test-emscripten-singlepass
- save_cache:
paths:
- /usr/local/cargo/registry

40
Cargo.lock generated
View File

@ -2230,12 +2230,12 @@ dependencies = [
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
"wasmer-dynasm-backend 0.1.0",
"wasmer-emscripten 0.2.1",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime 0.2.1",
"wasmer-runtime-abi 0.2.1",
"wasmer-runtime-core 0.2.1",
"wasmer-singlepass-backend 0.1.0",
"wasmer-wasi 0.2.1",
]
@ -2263,22 +2263,6 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-dynasm-backend"
version = "0.1.0"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.2.1",
"wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-emscripten"
version = "0.2.1"
@ -2291,9 +2275,9 @@ dependencies = [
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
"wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
"wasmer-singlepass-backend 0.1.0",
]
[[package]]
@ -2327,9 +2311,9 @@ dependencies = [
"tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
"wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
"wasmer-singlepass-backend 0.1.0",
]
[[package]]
@ -2381,15 +2365,31 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-singlepass-backend"
version = "0.1.0"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.2.1",
"wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-spectests"
version = "0.2.0"
dependencies = [
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0",
"wasmer-dynasm-backend 0.1.0",
"wasmer-llvm-backend 0.1.0",
"wasmer-runtime-core 0.2.1",
"wasmer-singlepass-backend 0.1.0",
]
[[package]]

View File

@ -24,7 +24,7 @@ structopt = "0.2.11"
wabt = "0.7.2"
hashbrown = "0.1.8"
wasmer-clif-backend = { path = "lib/clif-backend" }
wasmer-dynasm-backend = { path = "lib/dynasm-backend", optional = true }
wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true }
wasmer-runtime = { path = "lib/runtime" }
wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true }
wasmer-runtime-core = { path = "lib/runtime-core" }
@ -33,7 +33,7 @@ wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
wasmer-wasi = { path = "lib/wasi", optional = true }
[workspace]
members = ["lib/clif-backend", "lib/dynasm-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"]
members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"]
[build-dependencies]
wabt = "0.7.2"
@ -45,6 +45,6 @@ debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
llvm = ["wasmer-llvm-backend", "wasmer-runtime/llvm"]
dynasm = ["wasmer-dynasm-backend", "wasmer-runtime/dynasm"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/singlepass"]
wasi = ["wasmer-wasi"]
vfs = ["wasmer-runtime-abi"]

View File

@ -34,15 +34,15 @@ precommit: lint test
test:
# We use one thread so the emscripten stdouts doesn't collide
cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-dynasm-backend -- $(runargs)
cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-singlepass-backend -- $(runargs)
# cargo test --all --exclude wasmer-emscripten -- --test-threads=1 $(runargs)
cargo test --manifest-path lib/spectests/Cargo.toml --features clif
cargo test --manifest-path lib/spectests/Cargo.toml --features llvm
cargo build -p wasmer-runtime-c-api
cargo test -p wasmer-runtime-c-api -- --nocapture
test-dynasm:
cargo test --manifest-path lib/spectests/Cargo.toml --features dynasm
test-singlepass:
cargo test --manifest-path lib/spectests/Cargo.toml --features singlepass
test-emscripten-llvm:
cargo test --manifest-path lib/emscripten/Cargo.toml --features llvm -- --test-threads=1 $(runargs)
@ -50,17 +50,17 @@ test-emscripten-llvm:
test-emscripten-clif:
cargo test --manifest-path lib/emscripten/Cargo.toml --features clif -- --test-threads=1 $(runargs)
test-emscripten-dynasm:
cargo test --manifest-path lib/emscripten/Cargo.toml --features dynasm -- --test-threads=1 $(runargs)
test-emscripten-singlepass:
cargo test --manifest-path lib/emscripten/Cargo.toml --features singlepass -- --test-threads=1 $(runargs)
dynasm-debug-release:
cargo +nightly build --features "dynasm debug" --release
singlepass-debug-release:
cargo +nightly build --features "singlepass debug" --release
dynasm-release:
cargo +nightly build --features "dynasm" --release
singlepass-release:
cargo +nightly build --features "singlepass" --release
dynasm-build:
cargo +nightly build --features "dynasm debug"
singlepass-build:
cargo +nightly build --features "singlepass debug"
release:
# If you are in OS-X, you will need mingw-w64 for cross compiling to windows

View File

@ -34,6 +34,6 @@ to tune the codegen properties (compile speed, performance, etc) to best fit the
Currently, we support multiple backends for compiling WebAssembly to machine code:
- [dynasm-backend](./dynasm-backend/): Dynasm backend - super fast compilation, slower runtime speed
- [singlepass-backend](./singlepass-backend/): Single pass backend - super fast compilation, slower runtime speed
- [clif-backend](./clif-backend/): Cranelift backend - slower compilation, normal runtime speed
- [llvm-backend](./llvm-backend/): LLVM backend - slow compilation, native runtime speed

View File

@ -15,7 +15,7 @@ libc = "0.2.49"
byteorder = "1"
time = "0.1.41"
wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" }
wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true }
[target.'cfg(windows)'.dependencies]
@ -30,5 +30,5 @@ glob = "0.2.11"
[features]
clif = []
llvm = ["wasmer-llvm-backend"]
dynasm = ["wasmer-dynasm-backend"]
singlepass = ["wasmer-singlepass-backend"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]

View File

@ -186,13 +186,13 @@ mod tests {
LLVMCompiler::new()
}
#[cfg(feature = "dynasm")]
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_dynasm_backend::SinglePassCompiler;
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;

View File

@ -20,13 +20,13 @@ macro_rules! assert_emscripten_output {
LLVMCompiler::new()
}
#[cfg(feature = "dynasm")]
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_dynasm_backend::SinglePassCompiler;
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;

View File

@ -25,7 +25,7 @@ pub use crate::sig_registry::SigRegistry;
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
pub enum Backend {
Cranelift,
Dynasm,
Singlepass,
LLVM,
}

View File

@ -9,7 +9,7 @@ edition = "2018"
readme = "README.md"
[dependencies]
wasmer-dynasm-backend = { path = "../dynasm-backend", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", optional = true }
lazy_static = "1.2.0"
memmap = "0.7.0"
@ -37,7 +37,7 @@ default-compiler = ["wasmer-clif-backend"]
cache = ["default-compiler"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
llvm = ["wasmer-llvm-backend"]
dynasm = ["wasmer-dynasm-backend"]
singlepass = ["wasmer-singlepass-backend"]
[[bench]]
name = "nginx"

View File

@ -171,10 +171,10 @@ pub fn default_compiler() -> &'static dyn Compiler {
#[cfg(feature = "llvm")]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
#[cfg(feature = "dynasm")]
use wasmer_dynasm_backend::SinglePassCompiler as DefaultCompiler;
#[cfg(feature = "singlepass")]
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
#[cfg(not(any(feature = "llvm", feature = "dynasm")))]
#[cfg(not(any(feature = "llvm", feature = "singlepass")))]
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
lazy_static! {

View File

@ -1,8 +1,8 @@
[package]
name = "wasmer-dynasm-backend"
name = "wasmer-singlepass-backend"
version = "0.1.0"
repository = "https://github.com/wasmerio/wasmer"
description = "Wasmer runtime Dynasm compiler backend"
description = "Wasmer runtime single pass compiler backend"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
edition = "2018"

View File

@ -14,18 +14,18 @@
<a href="https://spectrum.chat/wasmer">
<img src="https://withspectrum.github.io/badge/badge.svg" alt="Join the Wasmer Community">
</a>
<a href="https://crates.io/crates/wasmer-dynasm-backend">
<img src="https://img.shields.io/crates/d/wasmer-dynasm-backend.svg" alt="Number of downloads from crates.io">
<a href="https://crates.io/crates/wasmer-singlepass-backend">
<img src="https://img.shields.io/crates/d/wasmer-singlepass-backend.svg" alt="Number of downloads from crates.io">
</a>
<a href="https://docs.rs/wasmer-dynasm-backend">
<img src="https://docs.rs/wasmer-dynasm-backend/badge.svg" alt="Read our API documentation">
<a href="https://docs.rs/wasmer-singlepass-backend">
<img src="https://docs.rs/wasmer-singlepass-backend/badge.svg" alt="Read our API documentation">
</a>
</p>
# Wasmer dynasm backend
# Wasmer singlepass backend
Wasmer is a standalone JIT WebAssembly runtime, aiming to be fully
compatible with Emscripten, Rust and Go. [Learn
more](https://github.com/wasmerio/wasmer).
This crate represents the dynasm backend.
This crate represents the singlepass backend.

View File

@ -41,7 +41,7 @@ impl CacheGen for Placeholder {
_module: &ModuleInner,
) -> Result<(Box<ModuleInfo>, Box<[u8]>, Memory), CacheError> {
Err(CacheError::Unknown(
"the dynasm backend doesn't support caching yet".to_string(),
"the singlepass backend doesn't support caching yet".to_string(),
))
}
}
@ -61,7 +61,7 @@ impl Compiler for SinglePassCompiler {
_: Token,
) -> CompileResult<ModuleInner> {
let mut mcg = codegen_x64::X64ModuleCodeGenerator::new();
let info = parse::read_module(wasm, Backend::Dynasm, &mut mcg, &compiler_config)?;
let info = parse::read_module(wasm, Backend::Singlepass, &mut mcg, &compiler_config)?;
let (ec, resolver) = mcg.finalize(&info)?;
Ok(ModuleInner {
cache_gen: Box::new(Placeholder),
@ -73,7 +73,7 @@ impl Compiler for SinglePassCompiler {
unsafe fn from_cache(&self, _artifact: Artifact, _: Token) -> Result<ModuleInner, CacheError> {
Err(CacheError::Unknown(
"the dynasm backend doesn't support caching yet".to_string(),
"the singlepass backend doesn't support caching yet".to_string(),
))
}
}

View File

@ -12,7 +12,7 @@ build = "build/mod.rs"
wasmer-runtime-core = { path = "../runtime-core", version = "0.2.0" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true }
wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true }
[build-dependencies]
wabt = "0.7.2"
@ -25,4 +25,4 @@ default = ["fast-tests"]
fast-tests = []
clif = []
llvm = ["wasmer-llvm-backend"]
dynasm = ["wasmer-dynasm-backend"]
singlepass = ["wasmer-singlepass-backend"]

View File

@ -107,13 +107,13 @@ fn get_compiler() -> impl Compiler {
LLVMCompiler::new()
}
#[cfg(feature = "dynasm")]
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_dynasm_backend::SinglePassCompiler;
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;

View File

@ -22,13 +22,13 @@ fn get_compiler() -> impl Compiler {
LLVMCompiler::new()
}
#[cfg(feature = "dynasm")]
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_dynasm_backend::SinglePassCompiler;
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))]
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;

View File

@ -6,6 +6,7 @@ use std::io;
use std::io::Read;
use std::path::PathBuf;
use std::process::exit;
use std::str::FromStr;
use hashbrown::HashMap;
use structopt::StructOpt;
@ -62,13 +63,36 @@ struct Run {
#[structopt(parse(from_os_str))]
path: PathBuf,
/// Application arguments
#[structopt(name = "--", raw(multiple = "true"))]
args: Vec<String>,
// Disable the cache
#[structopt(long = "backend", default_value="cranelift")]
backend: Backend,
/// Emscripten symbol map
#[structopt(long = "em-symbol-map", parse(from_os_str))]
em_symbol_map: Option<PathBuf>,
/// Application arguments
#[structopt(name = "--", raw(multiple = "true"))]
args: Vec<String>,
}
#[derive(Debug)]
enum Backend {
Cranelift,
Singlepass,
LLVM,
}
impl FromStr for Backend {
type Err = String;
fn from_str(s: &str) -> Result<Backend, String> {
match s {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
"llvm" => Ok(Backend::LLVM),
_ => Err(format!("The backend {} doesn't exist", s))
}
}
}
#[derive(Debug, StructOpt)]