From e5a784a00633615f43c5169745e2902c4b614309 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 25 May 2021 15:51:20 +0200 Subject: [PATCH 1/3] feat: Rename `wasmer-engine-jit` to `wasmer-engine-universal`. This (small) patch renames the `wasmer-engine-jit` crate into `wasmer-engine-universal`. --- Cargo.lock | 38 ++--- Cargo.toml | 22 +-- Makefile | 76 ++++----- benches/static_and_dynamic_functions.rs | 16 +- docs/deps_dedup.dot | 4 +- docs/deps_dedup.svg | 160 +++++++++--------- examples/README.md | 10 +- examples/compiler_cranelift.rs | 4 +- examples/compiler_llvm.rs | 4 +- examples/compiler_singlepass.rs | 4 +- examples/early_exit.rs | 4 +- examples/engine_headless.rs | 2 +- .../{engine_jit.rs => engine_universal.rs} | 20 +-- examples/errors.rs | 4 +- examples/exports_function.rs | 4 +- examples/exports_global.rs | 4 +- examples/exports_memory.rs | 4 +- examples/features.rs | 4 +- examples/hello_world.rs | 6 +- examples/imports_exports.rs | 4 +- examples/imports_function.rs | 4 +- examples/imports_function_env.rs | 4 +- examples/imports_global.rs | 4 +- examples/instance.rs | 4 +- examples/memory.rs | 4 +- examples/metering.rs | 6 +- examples/table.rs | 4 +- examples/tunables_limit_memory.rs | 4 +- examples/wasi.rs | 4 +- examples/wasi_pipes.rs | 4 +- fuzz/Cargo.toml | 30 ++-- fuzz/README.md | 10 +- ...alence_jit.rs => equivalence_universal.rs} | 8 +- fuzz/fuzz_targets/metering.rs | 4 +- ...it_cranelift.rs => universal_cranelift.rs} | 4 +- .../{jit_llvm.rs => universal_llvm.rs} | 4 +- ..._singlepass.rs => universal_singlepass.rs} | 4 +- fuzzbuzz.yaml | 2 +- lib/api/Cargo.toml | 14 +- lib/api/README.md | 5 +- lib/api/src/lib.rs | 16 +- lib/api/src/module.rs | 2 +- lib/api/src/store.rs | 4 +- lib/c-api/Cargo.toml | 10 +- lib/c-api/build.rs | 6 +- lib/c-api/src/wasm_c_api/engine.rs | 52 +++--- lib/c-api/src/wasm_c_api/unstable/engine.rs | 15 +- lib/c-api/tests/wasm.h | 4 +- lib/c-api/wasmer_wasm.h | 6 +- lib/cache/Cargo.toml | 2 +- lib/cache/benches/bench_filesystem_cache.rs | 16 +- lib/cli/Cargo.toml | 12 +- lib/cli/README.md | 4 +- lib/cli/src/commands/compile.rs | 8 +- lib/cli/src/commands/run.rs | 13 +- lib/cli/src/store.rs | 38 +++-- lib/compiler-cranelift/README.md | 4 +- lib/compiler-llvm/README.md | 4 +- lib/compiler-singlepass/README.md | 4 +- lib/compiler/src/function.rs | 4 - lib/deprecated/runtime-core/Cargo.lock | 6 +- lib/deprecated/runtime-core/Cargo.toml | 2 +- lib/deprecated/runtime/Cargo.lock | 6 +- lib/engine-native/README.md | 4 +- .../Cargo.toml | 6 +- .../README.md | 10 +- .../src/artifact.rs | 64 +++---- .../src/builder.rs | 26 +-- .../src/code_memory.rs | 0 .../src/engine.rs | 42 ++--- .../src/lib.rs | 8 +- .../src/link.rs | 2 +- .../src/serialize.rs | 2 +- .../src/unwind/dummy.rs | 0 .../src/unwind/mod.rs | 0 .../src/unwind/systemv.rs | 0 .../src/unwind/windows_x64.rs | 0 lib/engine/README.md | 11 +- lib/engine/src/engine.rs | 4 +- lib/middlewares/src/metering.rs | 6 +- scripts/publish.py | 8 +- tests/compilers/config.rs | 12 +- tests/ignores.txt | 4 +- tests/integration/cli/src/util.rs | 4 +- tests/lib/compiler-test-derive/src/ignores.rs | 6 +- tests/lib/compiler-test-derive/src/lib.rs | 4 +- tests/lib/compiler-test-derive/src/tests.rs | 24 +-- tests/lib/test-generator/Cargo.toml | 2 +- 88 files changed, 511 insertions(+), 497 deletions(-) rename examples/{engine_jit.rs => engine_universal.rs} (80%) rename fuzz/fuzz_targets/{equivalence_jit.rs => equivalence_universal.rs} (96%) rename fuzz/fuzz_targets/{jit_cranelift.rs => universal_cranelift.rs} (94%) rename fuzz/fuzz_targets/{jit_llvm.rs => universal_llvm.rs} (94%) rename fuzz/fuzz_targets/{jit_singlepass.rs => universal_singlepass.rs} (95%) rename lib/{engine-jit => engine-universal}/Cargo.toml (89%) rename lib/{engine-jit => engine-universal}/README.md (54%) rename lib/{engine-jit => engine-universal}/src/artifact.rs (87%) rename lib/{engine-jit => engine-universal}/src/builder.rs (71%) rename lib/{engine-jit => engine-universal}/src/code_memory.rs (100%) rename lib/{engine-jit => engine-universal}/src/engine.rs (89%) rename lib/{engine-jit => engine-universal}/src/lib.rs (85%) rename lib/{engine-jit => engine-universal}/src/link.rs (98%) rename lib/{engine-jit => engine-universal}/src/serialize.rs (99%) rename lib/{engine-jit => engine-universal}/src/unwind/dummy.rs (100%) rename lib/{engine-jit => engine-universal}/src/unwind/mod.rs (100%) rename lib/{engine-jit => engine-universal}/src/unwind/systemv.rs (100%) rename lib/{engine-jit => engine-universal}/src/unwind/windows_x64.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 141a3741291..adcb2d430be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2436,8 +2436,8 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-jit", "wasmer-engine-native", + "wasmer-engine-universal", "wasmer-types", "wasmer-vm", "wat", @@ -2455,8 +2455,8 @@ dependencies = [ "wasmer-compiler-cranelift", "wasmer-compiler-llvm", "wasmer-compiler-singlepass", - "wasmer-engine-jit", "wasmer-engine-native", + "wasmer-engine-universal", "wasmer-middlewares", "wasmprinter", ] @@ -2483,9 +2483,9 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-emscripten", "wasmer-engine", - "wasmer-engine-jit", "wasmer-engine-native", "wasmer-engine-object-file", + "wasmer-engine-universal", "wasmer-middlewares", "wasmer-types", "wasmer-wasi", @@ -2503,8 +2503,8 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler-singlepass", - "wasmer-engine-jit", "wasmer-engine-native", + "wasmer-engine-universal", ] [[package]] @@ -2529,9 +2529,9 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-emscripten", "wasmer-engine", - "wasmer-engine-jit", "wasmer-engine-native", "wasmer-engine-object-file", + "wasmer-engine-universal", "wasmer-types", "wasmer-vm", "wasmer-wasi", @@ -2679,30 +2679,34 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-jit" +name = "wasmer-engine-native" version = "1.0.2" dependencies = [ "cfg-if 0.1.10", "leb128", + "libloading", "loupe", - "region", "rkyv", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which 4.1.0", ] [[package]] -name = "wasmer-engine-native" +name = "wasmer-engine-object-file" version = "1.0.2" dependencies = [ + "bincode", "cfg-if 0.1.10", "leb128", "libloading", "loupe", - "rkyv", "serde", "tempfile", "tracing", @@ -2711,26 +2715,22 @@ dependencies = [ "wasmer-object", "wasmer-types", "wasmer-vm", - "which 4.1.0", ] [[package]] -name = "wasmer-engine-object-file" +name = "wasmer-engine-universal" version = "1.0.2" dependencies = [ - "bincode", "cfg-if 0.1.10", "leb128", - "libloading", "loupe", - "serde", - "tempfile", - "tracing", + "region", + "rkyv", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", + "winapi", ] [[package]] @@ -2862,9 +2862,9 @@ dependencies = [ "wasmer-emscripten", "wasmer-engine", "wasmer-engine-dummy", - "wasmer-engine-jit", "wasmer-engine-native", "wasmer-engine-object-file", + "wasmer-engine-universal", "wasmer-middlewares", "wasmer-types", "wasmer-wasi", diff --git a/Cargo.toml b/Cargo.toml index c4f554e7aec..9f3d0ce98af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ wasmer-compiler-singlepass = { version = "1.0.2", path = "lib/compiler-singlepas wasmer-compiler-llvm = { version = "1.0.2", path = "lib/compiler-llvm", optional = true } wasmer-emscripten = { version = "1.0.2", path = "lib/emscripten", optional = true } wasmer-engine = { version = "1.0.2", path = "lib/engine" } -wasmer-engine-jit = { version = "1.0.2", path = "lib/engine-jit", optional = true } +wasmer-engine-universal = { version = "1.0.2", path = "lib/engine-universal", optional = true } wasmer-engine-native = { version = "1.0.2", path = "lib/engine-native", optional = true } wasmer-engine-object-file = { version = "1.0.2", path = "lib/engine-object-file", optional = true } wasmer-wasi = { version = "1.0.2", path = "lib/wasi", optional = true } @@ -40,7 +40,7 @@ members = [ "lib/derive", "lib/emscripten", "lib/engine", - "lib/engine-jit", + "lib/engine-universal", "lib/engine-native", "lib/engine-object-file", "lib/object", @@ -81,7 +81,7 @@ loupe = "0.1" default = [ "wat", "wast", - "jit", + "universal", "native", "object-file", "cache", @@ -90,8 +90,8 @@ default = [ "middlewares", ] engine = [] -jit = [ - "wasmer-engine-jit", +universal = [ + "wasmer-engine-universal", "engine", ] native = [ @@ -110,7 +110,7 @@ wat = ["wasmer/wat"] compiler = [ "wasmer/compiler", "wasmer-compiler/translator", - "wasmer-engine-jit/compiler", + "wasmer-engine-universal/compiler", "wasmer-engine-native/compiler", "wasmer-engine-object-file/compiler", ] @@ -143,9 +143,9 @@ test-native = [ "native", "test-generator/test-native", ] -test-jit = [ - "jit", - "test-generator/test-jit", +test-universal = [ + "universal", + "test-generator/test-universal", ] # Specifies that we're running in coverage testing mode. This disables tests @@ -165,8 +165,8 @@ path = "examples/early_exit.rs" required-features = ["cranelift"] [[example]] -name = "engine-jit" -path = "examples/engine_jit.rs" +name = "engine-universal" +path = "examples/engine_universal.rs" required-features = ["cranelift"] [[example]] diff --git a/Makefile b/Makefile index 199360b9543..b3ce39880c9 100644 --- a/Makefile +++ b/Makefile @@ -9,28 +9,28 @@ SHELL=/bin/bash # The matrix is the product of the following columns: # -# |------------|--------|----------|--------------|-------| -# | Compiler ⨯ Engine ⨯ Platform ⨯ Architecture ⨯ libc | -# |------------|--------|----------|--------------|-------| -# | Cranelift | JIT | Linux | amd64 | glibc | -# | LLVM | Native | Darwin | aarch64 | musl | -# | Singlepass | | Windows | | | -# |------------|--------|----------|--------------|-------| +# |------------|-----------|----------|--------------|-------| +# | Compiler ⨯ Engine ⨯ Platform ⨯ Architecture ⨯ libc | +# |------------|-----------|----------|--------------|-------| +# | Cranelift | Universal | Linux | amd64 | glibc | +# | LLVM | Native | Darwin | aarch64 | musl | +# | Singlepass | | Windows | | | +# |------------|-----------|----------|--------------|-------| # # Here is what works and what doesn't: # -# * Cranelift with the JIT engine works everywhere, +# * Cranelift with the Universal engine works everywhere, # # * Cranelift with the Native engine works on Linux+Darwin/`amd64`, # but it doesn't work on */`aarch64` or Windows/*. # -# * LLVM with the JIT engine works on Linux+Darwin/`amd64`, +# * LLVM with the Universal engine works on Linux+Darwin/`amd64`, # but it doesn't work on */`aarch64` or Windows/*. # # * LLVM with the Native engine works on # Linux+Darwin/`amd64`+`aarch64`, but it doesn't work on Windows/*. # -# * Singlepass with the JIT engine works on Linux+Darwin/`amd64`, but +# * Singlepass with the Universal engine works on Linux+Darwin/`amd64`, but # it doesn't work on */`aarch64` or Windows/*. # # * Singlepass with the Native engine doesn't work because it doesn't @@ -205,7 +205,7 @@ compilers_engines := ## ifeq ($(ENABLE_CRANELIFT), 1) - compilers_engines += cranelift-jit + compilers_engines += cranelift-universal ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX))) ifeq ($(IS_AMD64), 1) @@ -228,7 +228,7 @@ endif ifeq ($(ENABLE_LLVM), 1) ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX))) ifeq ($(IS_AMD64), 1) - compilers_engines += llvm-jit + compilers_engines += llvm-universal compilers_engines += llvm-native else ifeq ($(IS_AARCH64), 1) compilers_engines += llvm-native @@ -243,7 +243,7 @@ endif ifeq ($(ENABLE_SINGLEPASS), 1) ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX))) ifeq ($(IS_AMD64), 1) - compilers_engines += singlepass-jit + compilers_engines += singlepass-universal endif endif endif @@ -300,10 +300,10 @@ capi_compilers_engines_exclude := # LLVM for the moment because it causes the linker to fail since llvm is not statically linked. # TODO: Reenable llvm in C-API capi_compiler_features := --features $(subst $(space),$(comma),$(filter-out llvm, $(compilers))) -capi_compilers_engines_exclude += llvm-jit llvm-native +capi_compilers_engines_exclude += llvm-universal llvm-native -# We exclude singlepass jit because it doesn't support multivalue (required in wasm-c-api tests) -capi_compilers_engines_exclude += singlepass-jit +# We exclude singlepass-universal because it doesn't support multivalue (required in wasm-c-api tests) +capi_compilers_engines_exclude += singlepass-universal capi_compilers_engines := $(filter-out $(capi_compilers_engines_exclude),$(compilers_engines)) @@ -423,19 +423,19 @@ endif build-docs-capi: capi-setup cd lib/c-api/doc/deprecated/ && doxygen doxyfile - RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,jit,object-file,native,cranelift,wasi $(capi_default_features) + RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,object-file,native,cranelift,wasi $(capi_default_features) build-capi: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) + --no-default-features --features deprecated,wat,universal,native,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) build-capi-singlepass: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,singlepass,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,native,object-file,singlepass,wasi,middlewares $(capi_default_features) -build-capi-singlepass-jit: capi-setup +build-capi-singlepass-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,singlepass,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,singlepass,wasi,middlewares $(capi_default_features) build-capi-singlepass-native: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ @@ -447,15 +447,15 @@ build-capi-singlepass-object-file: capi-setup build-capi-cranelift: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,cranelift,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,native,object-file,cranelift,wasi,middlewares $(capi_default_features) build-capi-cranelift-system-libffi: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,cranelift,wasi,middlewares,system-libffi $(capi_default_features) + --no-default-features --features deprecated,wat,universal,native,object-file,cranelift,wasi,middlewares,system-libffi $(capi_default_features) -build-capi-cranelift-jit: capi-setup +build-capi-cranelift-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,cranelift,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,cranelift,wasi,middlewares $(capi_default_features) build-capi-cranelift-native: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ @@ -467,11 +467,11 @@ build-capi-cranelift-object-file: capi-setup build-capi-llvm: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,llvm,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,native,object-file,llvm,wasi,middlewares $(capi_default_features) -build-capi-llvm-jit: capi-setup +build-capi-llvm-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,llvm,wasi,middlewares $(capi_default_features) + --no-default-features --features deprecated,wat,universal,llvm,wasi,middlewares $(capi_default_features) build-capi-llvm-native: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ @@ -483,9 +483,9 @@ build-capi-llvm-object-file: capi-setup # Headless (we include the minimal to be able to run) -build-capi-headless-jit: capi-setup +build-capi-headless-universal: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features jit,wasi + --no-default-features --features universal,wasi build-capi-headless-native: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ @@ -497,7 +497,7 @@ build-capi-headless-object-file: capi-setup build-capi-headless-all: capi-setup RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features jit,native,object-file,wasi + --no-default-features --features universal,native,object-file,wasi ########### # Testing # @@ -523,20 +523,20 @@ test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler)) test-singlepass-native: cargo test --release --tests $(compiler_features) -- singlepass::native -test-singlepass-jit: - cargo test --release --tests $(compiler_features) -- singlepass::jit +test-singlepass-universal: + cargo test --release --tests $(compiler_features) -- singlepass::universal test-cranelift-native: cargo test --release --tests $(compiler_features) -- cranelift::native -test-cranelift-jit: - cargo test --release --tests $(compiler_features) -- cranelift::jit +test-cranelift-universal: + cargo test --release --tests $(compiler_features) -- cranelift::universal test-llvm-native: cargo test --release --tests $(compiler_features) -- llvm::native -test-llvm-jit: - cargo test --release --tests $(compiler_features) -- llvm::jit +test-llvm-universal: + cargo test --release --tests $(compiler_features) -- llvm::universal test-singlepass: $(foreach singlepass_engine,$(filter singlepass-%,$(compilers_engines)),test-$(singlepass_engine)) @@ -550,7 +550,7 @@ test-capi: build-capi package-capi $(foreach compiler_engine,$(capi_compilers_en test-capi-crate-%: WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) cargo test --manifest-path lib/c-api/Cargo.toml --release \ - --no-default-features --features deprecated,wat,jit,native,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) -- --nocapture + --no-default-features --features deprecated,wat,universal,native,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) -- --nocapture test-capi-integration-%: # Test the Wasmer C API tests for C diff --git a/benches/static_and_dynamic_functions.rs b/benches/static_and_dynamic_functions.rs index fc27b32402e..462bac6d5ed 100644 --- a/benches/static_and_dynamic_functions.rs +++ b/benches/static_and_dynamic_functions.rs @@ -149,19 +149,21 @@ pub fn run_basic_dynamic_function(store: &Store, compiler_name: &str, c: &mut Cr fn run_static_benchmarks(_c: &mut Criterion) { #[cfg(feature = "llvm")] { - let store = Store::new(&JIT::new(wasmer_compiler_llvm::LLVM::new()).engine()); + let store = Store::new(&Universal::new(wasmer_compiler_llvm::LLVM::new()).engine()); run_basic_static_function(&store, "llvm", c); } #[cfg(feature = "cranelift")] { - let store = Store::new(&JIT::new(wasmer_compiler_cranelift::Cranelift::new()).engine()); + let store = + Store::new(&Universal::new(wasmer_compiler_cranelift::Cranelift::new()).engine()); run_basic_static_function(&store, "cranelift", c); } #[cfg(feature = "singlepass")] { - let store = Store::new(&JIT::new(wasmer_compiler_singlepass::Singlepass::new()).engine()); + let store = + Store::new(&Universal::new(wasmer_compiler_singlepass::Singlepass::new()).engine()); run_basic_static_function(&store, "singlepass", c); } } @@ -169,19 +171,21 @@ fn run_static_benchmarks(_c: &mut Criterion) { fn run_dynamic_benchmarks(_c: &mut Criterion) { #[cfg(feature = "llvm")] { - let store = Store::new(&JIT::new(wasmer_compiler_llvm::LLVM::new()).engine()); + let store = Store::new(&Universal::new(wasmer_compiler_llvm::LLVM::new()).engine()); run_basic_dynamic_function(&store, "llvm", c); } #[cfg(feature = "cranelift")] { - let store = Store::new(&JIT::new(wasmer_compiler_cranelift::Cranelift::new()).engine()); + let store = + Store::new(&Universal::new(wasmer_compiler_cranelift::Cranelift::new()).engine()); run_basic_dynamic_function(&store, "cranelift", c); } #[cfg(feature = "singlepass")] { - let store = Store::new(&JIT::new(wasmer_compiler_singlepass::Singlepass::new()).engine()); + let store = + Store::new(&Universal::new(wasmer_compiler_singlepass::Singlepass::new()).engine()); run_basic_dynamic_function(&store, "singlepass", c); } } diff --git a/docs/deps_dedup.dot b/docs/deps_dedup.dot index d4ae34a7709..2e561800a8c 100644 --- a/docs/deps_dedup.dot +++ b/docs/deps_dedup.dot @@ -4,7 +4,7 @@ digraph dependencies { n0 [label="wasmer", color=orange]; n1 [label="wasmer-compiler", color=orange]; n5 [label="wasmer-engine", color=orange]; - n6 [label="wasmer-engine-jit", color=orange]; + n6 [label="wasmer-engine-universal", color=orange]; n7 [label="wasmer-engine-native", color=orange]; n8 [label="wasmer-types", color=orange]; n9 [label="wasmer-vm", color=orange]; @@ -28,7 +28,7 @@ digraph dependencies { label="Engines"; color=brown; - n6 [label="wasmer-engine-jit", color=orange]; + n6 [label="wasmer-engine-universal", color=orange]; n7 [label="wasmer-engine-native", color=orange]; } diff --git a/docs/deps_dedup.svg b/docs/deps_dedup.svg index 384e010a431..1e810aae96f 100644 --- a/docs/deps_dedup.svg +++ b/docs/deps_dedup.svg @@ -1,46 +1,46 @@ - - + dependencies - + cluster_compiler - -Compilers + +Compilers cluster_engine - -Engines + +Engines cluster_abi - -Provided ABIs + +Provided ABIs n0 - -wasmer + +wasmer n6 - -wasmer-engine-jit + +wasmer-engine-universal n0->n6 - - + + @@ -51,194 +51,194 @@ n0->n7 - - + + n2 - -wasmer-compiler-cranelift + +wasmer-compiler-cranelift n0->n2 - - + + n3 - -wasmer-compiler-llvm + +wasmer-compiler-llvm n0->n3 - - + + n4 - -wasmer-compiler-singlepass + +wasmer-compiler-singlepass n0->n4 - - + + n1 - -wasmer-compiler + +wasmer-compiler n9 - -wasmer-vm + +wasmer-vm n1->n9 - - + + n5 - -wasmer-engine + +wasmer-engine n5->n1 - - + + n6->n5 - - + + n7->n5 - - + + n8 - -wasmer-types + +wasmer-types n9->n8 - - + + n10 - -wasmer-c-api + +wasmer-c-api n11 - -wasmer-emscripten + +wasmer-emscripten n10->n11 - - + + n12 - -wasmer-wasi + +wasmer-wasi n10->n12 - - + + n11->n0 - - + + n12->n0 - - + + n13 - -wasmer-cache + +wasmer-cache n13->n0 - - + + n14 - -wasmer-cli + +wasmer-cli n14->n11 - - + + n14->n12 - - + + n14->n13 - - + + n2->n1 - - + + n3->n1 - - + + n4->n1 - - + + diff --git a/examples/README.md b/examples/README.md index cc44759c992..c14e2035957 100644 --- a/examples/README.md +++ b/examples/README.md @@ -220,18 +220,18 @@ example. ### Engines -1. [**JIT engine**][engine-jit], explains what an engine is, what the - JIT engine is, and how to set it up. The example completes itself +1. [**Universal engine**][engine-universal], explains what an engine is, what the + Universal engine is, and how to set it up. The example completes itself with the compilation of the Wasm module, its instantiation, and finally, by calling an exported function. - _Keywords_: JIT, engine, in-memory, executable code. + _Keywords_: Universal, engine, in-memory, executable code.
Execute the example ```shell - $ cargo run --example engine-jit --release --features "cranelift" + $ cargo run --example engine-universal --release --features "cranelift" ``` @@ -375,7 +375,7 @@ example. [hello-world]: ./hello_world.rs -[engine-jit]: ./engine_jit.rs +[engine-universal]: ./engine_universal.rs [engine-native]: ./engine_native.rs [engine-headless]: ./engine_headless.rs [compiler-singlepass]: ./compiler_singlepass.rs diff --git a/examples/compiler_cranelift.rs b/examples/compiler_cranelift.rs index db39dc09be7..2d7e446c8e4 100644 --- a/examples/compiler_cranelift.rs +++ b/examples/compiler_cranelift.rs @@ -12,7 +12,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -33,7 +33,7 @@ fn main() -> Result<(), Box> { let compiler = Cranelift::default(); // Create the store - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/compiler_llvm.rs b/examples/compiler_llvm.rs index 0b451cf32ee..f062a1c0bc6 100644 --- a/examples/compiler_llvm.rs +++ b/examples/compiler_llvm.rs @@ -12,7 +12,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_llvm::LLVM; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -33,7 +33,7 @@ fn main() -> Result<(), Box> { let compiler = LLVM::default(); // Create the store - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/compiler_singlepass.rs b/examples/compiler_singlepass.rs index 1dc5c08939f..845b9db302c 100644 --- a/examples/compiler_singlepass.rs +++ b/examples/compiler_singlepass.rs @@ -12,7 +12,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -33,7 +33,7 @@ fn main() -> Result<(), Box> { let compiler = Singlepass::default(); // Create the store - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/early_exit.rs b/examples/early_exit.rs index 334cae38422..71d7ef82cb0 100644 --- a/examples/early_exit.rs +++ b/examples/early_exit.rs @@ -18,7 +18,7 @@ use anyhow::bail; use std::fmt; use wasmer::{imports, wat2wasm, Function, Instance, Module, NativeFunc, RuntimeError, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; // First we need to create an error type that we'll use to signal the end of execution. #[derive(Debug, Clone, Copy)] @@ -55,7 +55,7 @@ fn main() -> anyhow::Result<()> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/engine_headless.rs b/examples/engine_headless.rs index 1f1170af3d0..b3172cf5a57 100644 --- a/examples/engine_headless.rs +++ b/examples/engine_headless.rs @@ -8,7 +8,7 @@ //! What problem does it solve, and what does it mean? //! //! Once a Wasm module is compiled into executable code and stored -//! somewhere (e.g. in memory with the JIT engine, or in a native +//! somewhere (e.g. in memory with the Universal engine, or in a native //! object with the native engine), the module can be instantiated and //! executed. But imagine for a second the following scenario: //! diff --git a/examples/engine_jit.rs b/examples/engine_universal.rs similarity index 80% rename from examples/engine_jit.rs rename to examples/engine_universal.rs index e68336d9db3..0d51244f9ec 100644 --- a/examples/engine_jit.rs +++ b/examples/engine_universal.rs @@ -1,26 +1,26 @@ //! Defining an engine in Wasmer is one of the fundamental steps. //! -//! This example illustrates how to use the `wasmer_engine_jit`, aka -//! the JIT engine. An engine applies roughly 2 steps: +//! This example illustrates how to use the `wasmer_engine_universal`, +//! aka the Universal engine. An engine applies roughly 2 steps: //! //! 1. It compiles the Wasm module bytes to executable code, through //! the intervention of a compiler, //! 2. It stores the executable code somewhere. //! -//! In the particular context of the JIT engine, the executable code -//! is stored in memory. +//! In the particular context of the Universal engine, the executable +//! code is stored in memory. //! //! You can run the example directly by executing in Wasmer root: //! //! ```shell -//! cargo run --example engine-jit --release --features "cranelift" +//! cargo run --example engine-universal --release --features "cranelift" //! ``` //! //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -44,12 +44,12 @@ fn main() -> Result<(), Box> { // compile the Wasm module into executable code. let compiler_config = Cranelift::default(); - println!("Creating JIT engine..."); + println!("Creating Universal engine..."); // Define the engine that will drive everything. // - // In this case, the engine is `wasmer_engine_jit` which roughly + // In this case, the engine is `wasmer_engine_universal` which roughly // means that the executable code will live in memory. - let engine = JIT::new(compiler_config).engine(); + let engine = Universal::new(compiler_config).engine(); // Create a store, that holds the engine. let store = Store::new(&engine); @@ -86,6 +86,6 @@ fn main() -> Result<(), Box> { } #[test] -fn test_engine_jit() -> Result<(), Box> { +fn test_engine_universal() -> Result<(), Box> { main() } diff --git a/examples/errors.rs b/examples/errors.rs index 6823a2e904a..d145fd776e1 100644 --- a/examples/errors.rs +++ b/examples/errors.rs @@ -15,7 +15,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -39,7 +39,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/exports_function.rs b/examples/exports_function.rs index 7e04a597fc5..07ce4a0d673 100644 --- a/examples/exports_function.rs +++ b/examples/exports_function.rs @@ -19,7 +19,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -40,7 +40,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/exports_global.rs b/examples/exports_global.rs index bf6f6c2346b..80aad13302a 100644 --- a/examples/exports_global.rs +++ b/examples/exports_global.rs @@ -17,7 +17,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Mutability, Store, Type, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/exports_memory.rs b/examples/exports_memory.rs index bfc25072282..66d25a23336 100644 --- a/examples/exports_memory.rs +++ b/examples/exports_memory.rs @@ -13,7 +13,7 @@ use wasmer::{imports, wat2wasm, Array, Instance, Module, Store, WasmPtr}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -37,7 +37,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/features.rs b/examples/features.rs index 20c8baed5ae..ef3574d6efd 100644 --- a/examples/features.rs +++ b/examples/features.rs @@ -12,7 +12,7 @@ use wasmer::{imports, wat2wasm, Features, Instance, Module, Store, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> anyhow::Result<()> { // Let's declare the Wasm module with the text representation. @@ -36,7 +36,7 @@ fn main() -> anyhow::Result<()> { features.multi_value(true); // Set up the engine. That's where we define the features! - let engine = JIT::new(compiler).features(features); + let engine = Universal::new(compiler).features(features); // Now, let's define the store, and compile the module. let store = Store::new(&engine.engine()); diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 55142db1c14..c2c34913b6f 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -8,7 +8,7 @@ use wasmer::{imports, wat2wasm, Function, Instance, Module, NativeFunc, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> anyhow::Result<()> { // First we create a simple Wasm program to use with Wasmer. @@ -42,9 +42,9 @@ fn main() -> anyhow::Result<()> { // You can use `Store::default()` for that. // // However for the purposes of showing what's happening, we create a compiler - // (`Cranelift`) and pass it to an engine (`JIT`). We then pass the engine to + // (`Cranelift`) and pass it to an engine (`Universal`). We then pass the engine to // the store and are now ready to compile and run WebAssembly! - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); // We then use our store and Wasm bytes to compile a `Module`. // A `Module` is a compiled WebAssembly module that isn't ready to execute yet. diff --git a/examples/imports_exports.rs b/examples/imports_exports.rs index 127c07abf9a..a832ed8b8d3 100644 --- a/examples/imports_exports.rs +++ b/examples/imports_exports.rs @@ -20,7 +20,7 @@ use wasmer::{ Type, Value, }; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module. @@ -44,7 +44,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_function.rs b/examples/imports_function.rs index c42b4d49742..767e0bdd57c 100644 --- a/examples/imports_function.rs +++ b/examples/imports_function.rs @@ -19,7 +19,7 @@ use wasmer::{imports, wat2wasm, Function, FunctionType, Instance, Module, Store, Type, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -42,7 +42,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_function_env.rs b/examples/imports_function_env.rs index 8aa35317005..0cb4b8ffec5 100644 --- a/examples/imports_function_env.rs +++ b/examples/imports_function_env.rs @@ -22,7 +22,7 @@ use std::sync::{Arc, Mutex}; use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, WasmerEnv}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -49,7 +49,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_global.rs b/examples/imports_global.rs index 59ce9da2d2c..6da88c1d8ce 100644 --- a/examples/imports_global.rs +++ b/examples/imports_global.rs @@ -17,7 +17,7 @@ use wasmer::{imports, wat2wasm, Global, Instance, Module, Store, Value}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/instance.rs b/examples/instance.rs index 0ecbaa88aee..1d0b16f945e 100644 --- a/examples/instance.rs +++ b/examples/instance.rs @@ -16,7 +16,7 @@ use wasmer::{imports, wat2wasm, Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; fn main() -> Result<(), Box> { // Let's declare the Wasm module. @@ -39,7 +39,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/memory.rs b/examples/memory.rs index ee04ab29cea..221ec41fb75 100644 --- a/examples/memory.rs +++ b/examples/memory.rs @@ -17,7 +17,7 @@ use std::mem; use wasmer::{imports, wat2wasm, Bytes, Instance, Module, NativeFunc, Pages, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; // this example is a work in progress: // TODO: clean it up and comment it https://github.com/wasmerio/wasmer/issues/1749 @@ -57,7 +57,7 @@ fn main() -> anyhow::Result<()> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/metering.rs b/examples/metering.rs index d98e30a114f..8e715c1f7f1 100644 --- a/examples/metering.rs +++ b/examples/metering.rs @@ -20,7 +20,7 @@ use wasmer::wasmparser::Operator; use wasmer::CompilerConfig; use wasmer::{imports, wat2wasm, Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; use wasmer_middlewares::{ metering::{get_remaining_points, set_remaining_points, MeteringPoints}, Metering, @@ -69,8 +69,8 @@ fn main() -> anyhow::Result<()> { // Create a Store. // // We use our previously create compiler configuration - // with the JIT engine. - let store = Store::new(&JIT::new(compiler_config).engine()); + // with the Universal engine. + let store = Store::new(&Universal::new(compiler_config).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/table.rs b/examples/table.rs index dc88f4ceafc..2ae33badf78 100644 --- a/examples/table.rs +++ b/examples/table.rs @@ -2,7 +2,7 @@ use wasmer::{ imports, wat2wasm, Function, Instance, Module, NativeFunc, Store, TableType, Type, Value, }; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; /// A function we'll call through a table. fn host_callback(arg1: i32, arg2: i32) -> i32 { @@ -51,7 +51,7 @@ fn main() -> anyhow::Result<()> { )?; // We set up our store with an engine and a compiler. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); // Then compile our Wasm. let module = Module::new(&store, wasm_bytes)?; let import_object = imports! {}; diff --git a/examples/tunables_limit_memory.rs b/examples/tunables_limit_memory.rs index 8d2f92d3b92..690d671613d 100644 --- a/examples/tunables_limit_memory.rs +++ b/examples/tunables_limit_memory.rs @@ -9,7 +9,7 @@ use wasmer::{ Tunables, }; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; /// A custom tunables that allows you to set a memory limit. /// @@ -144,7 +144,7 @@ fn main() -> Result<(), Box> { // Any compiler and any engine do the job here let compiler = Cranelift::default(); - let engine = JIT::new(compiler).engine(); + let engine = Universal::new(compiler).engine(); // Here is where the fun begins diff --git a/examples/wasi.rs b/examples/wasi.rs index 93d37a9dfc1..3d24c5af60b 100644 --- a/examples/wasi.rs +++ b/examples/wasi.rs @@ -17,7 +17,7 @@ use wasmer::{Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; use wasmer_wasi::WasiState; fn main() -> Result<(), Box> { @@ -32,7 +32,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/wasi_pipes.rs b/examples/wasi_pipes.rs index 4ab0fae0c8c..b1d44e119b4 100644 --- a/examples/wasi_pipes.rs +++ b/examples/wasi_pipes.rs @@ -13,7 +13,7 @@ use wasmer::{Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; use wasmer_wasi::{Pipe, WasiState}; fn main() -> Result<(), Box> { @@ -28,7 +28,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let store = Store::new(&JIT::new(Cranelift::default()).engine()); + let store = Store::new(&Universal::new(Cranelift::default()).engine()); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d7062362a99..b0c5a09450e 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -16,7 +16,7 @@ wasmer = { path = "../lib/api" } wasmer-compiler-cranelift = { path = "../lib/compiler-cranelift", optional = true } wasmer-compiler-llvm = { path = "../lib/compiler-llvm", optional = true } wasmer-compiler-singlepass = { path = "../lib/compiler-singlepass", optional = true } -wasmer-engine-jit = { path = "../lib/engine-jit", optional = true } +wasmer-engine-universal = { path = "../lib/engine-universal", optional = true } wasmer-engine-native = { path = "../lib/engine-native", optional = true } wasmer-middlewares = { path = "../lib/middlewares" } wasmprinter = "0.2" @@ -25,33 +25,33 @@ wasmprinter = "0.2" cranelift = [ "wasmer-compiler-cranelift" ] llvm = [ "wasmer-compiler-llvm" ] singlepass = [ "wasmer-compiler-singlepass" ] -jit = [ "wasmer-engine-jit" ] +universal = [ "wasmer-engine-universal" ] native = [ "wasmer-engine-native" ] [[bin]] -name = "equivalence_jit" -path = "fuzz_targets/equivalence_jit.rs" -required-features = ["jit"] +name = "equivalence_universal" +path = "fuzz_targets/equivalence_universal.rs" +required-features = ["universal"] [[bin]] -name = "jit_cranelift" -path = "fuzz_targets/jit_cranelift.rs" -required-features = ["jit", "cranelift"] +name = "universal_cranelift" +path = "fuzz_targets/universal_cranelift.rs" +required-features = ["universal", "cranelift"] [[bin]] -name = "jit_llvm" -path = "fuzz_targets/jit_llvm.rs" -required-features = ["jit", "llvm"] +name = "universal_llvm" +path = "fuzz_targets/universal_llvm.rs" +required-features = ["universal", "llvm"] [[bin]] -name = "jit_singlepass" -path = "fuzz_targets/jit_singlepass.rs" -required-features = ["jit", "singlepass"] +name = "universal_singlepass" +path = "fuzz_targets/universal_singlepass.rs" +required-features = ["universal", "singlepass"] [[bin]] name = "metering" path = "fuzz_targets/metering.rs" -required-features = ["jit", "cranelift"] +required-features = ["universal", "cranelift"] [[bin]] name = "native_cranelift" diff --git a/fuzz/README.md b/fuzz/README.md index 95c5beccb88..23ad4fddc0a 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -10,15 +10,15 @@ $ cargo install cargo-fuzz `cargo-fuzz` is documented in the [Rust Fuzz Book](https://rust-fuzz.github.io/book/cargo-fuzz.html). -## Running a fuzzer (validate, jit_llvm, native_cranelift, ...) +## Running a fuzzer (`validate`, `universal_llvm`, `native_cranelift`…) Once `cargo-fuzz` is installed, you can run the `validate` fuzzer with ```sh cargo fuzz run validate ``` -or the `jit_cranelift` fuzzer +or the `universal_cranelift` fuzzer ```sh -cargo fuzz run jit_cranelift +cargo fuzz run universal_cranelift ``` See the [fuzz/fuzz_targets](https://github.com/wasmerio/wasmer/tree/fuzz/fuzz_targets/) directory for the full list of targets. @@ -36,12 +36,12 @@ You should see output that looks something like this: #1409042 NEW cov: 115073 ft: 503951 corp: 4667/1814Kb lim: 4096 exec/s: 884 rss: 857Mb L: 174/4096 MS: 2 ChangeByte-ChangeASCIIInt- ``` -It will continue to generate random inputs forever, until it finds a bug or is terminated. The testcases for bugs it finds go into `fuzz/artifacts/jit_cranelift` and you can rerun the fuzzer on a single input by passing it on the command line `cargo fuzz run jit_cranelift /path/to/testcase`. +It will continue to generate random inputs forever, until it finds a bug or is terminated. The testcases for bugs it finds go into `fuzz/artifacts/universal_cranelift` and you can rerun the fuzzer on a single input by passing it on the command line `cargo fuzz run universal_cranelift /path/to/testcase`. ## The corpus Each fuzzer has an individual corpus under fuzz/corpus/test_name, created on first run if not already present. The fuzzers use `wasm-smith` which means that the testcase files are random number seeds input to the wasm generator, not `.wasm` files themselves. In order to debug a testcase, you may find that you need to convert it into a `.wasm` file. Using the standalone `wasm-smith` tool doesn't work for this purpose because we use a custom configuration to our `wasm_smith::Module`. Instead, our fuzzers use an environment variable `DUMP_TESTCASE=path`. For example: ``` -DUMP_TESTCASE=/tmp/crash.wasm cargo fuzz run --features=jit,singlepass jit_singlepass fuzz/artifacts/jit_singlepass/crash-0966412eab4f89c52ce5d681807c8030349470f6 +DUMP_TESTCASE=/tmp/crash.wasm cargo fuzz run --features=universal,singlepass universal_singlepass fuzz/artifacts/universal_singlepass/crash-0966412eab4f89c52ce5d681807c8030349470f6 ``` diff --git a/fuzz/fuzz_targets/equivalence_jit.rs b/fuzz/fuzz_targets/equivalence_universal.rs similarity index 96% rename from fuzz/fuzz_targets/equivalence_jit.rs rename to fuzz/fuzz_targets/equivalence_universal.rs index 66e74e9019d..09c4a0c718f 100644 --- a/fuzz/fuzz_targets/equivalence_jit.rs +++ b/fuzz/fuzz_targets/equivalence_universal.rs @@ -11,7 +11,7 @@ use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_llvm::LLVM; #[cfg(feature = "singlepass")] use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; #[derive(Arbitrary, Debug, Default, Copy, Clone)] struct ExportedFunctionConfig; @@ -48,7 +48,7 @@ impl std::fmt::Debug for WasmSmithModule { #[cfg(feature = "singlepass")] fn maybe_instantiate_singlepass(wasm_bytes: &[u8]) -> Result> { let compiler = Singlepass::default(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes); let module = match module { Ok(m) => m, @@ -69,7 +69,7 @@ fn maybe_instantiate_cranelift(wasm_bytes: &[u8]) -> Result> { let mut compiler = Cranelift::default(); compiler.canonicalize_nans(true); compiler.enable_verifier(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes)?; let instance = Instance::new(&module, &imports! {})?; Ok(Some(instance)) @@ -80,7 +80,7 @@ fn maybe_instantiate_llvm(wasm_bytes: &[u8]) -> Result> { let mut compiler = LLVM::default(); compiler.canonicalize_nans(true); compiler.enable_verifier(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes)?; let instance = Instance::new(&module, &imports! {})?; Ok(Some(instance)) diff --git a/fuzz/fuzz_targets/metering.rs b/fuzz/fuzz_targets/metering.rs index c320ddcd0ca..69d541967cf 100644 --- a/fuzz/fuzz_targets/metering.rs +++ b/fuzz/fuzz_targets/metering.rs @@ -6,7 +6,7 @@ use wasm_smith::{Config, ConfiguredModule}; use wasmer::wasmparser::Operator; use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; use wasmer_middlewares::Metering; #[derive(Arbitrary, Debug, Default, Copy, Clone)] @@ -56,7 +56,7 @@ fuzz_target!(|module: WasmSmithModule| { compiler.enable_verifier(); let metering = Arc::new(Metering::new(10, cost)); compiler.push_middleware(metering); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes).unwrap(); match Instance::new(&module, &imports! {}) { Ok(_) => {} diff --git a/fuzz/fuzz_targets/jit_cranelift.rs b/fuzz/fuzz_targets/universal_cranelift.rs similarity index 94% rename from fuzz/fuzz_targets/jit_cranelift.rs rename to fuzz/fuzz_targets/universal_cranelift.rs index ce7b60c5820..05133e44289 100644 --- a/fuzz/fuzz_targets/jit_cranelift.rs +++ b/fuzz/fuzz_targets/universal_cranelift.rs @@ -4,7 +4,7 @@ use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use wasm_smith::{Config, ConfiguredModule}; use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; #[derive(Arbitrary, Debug, Default, Copy, Clone)] struct NoImportsConfig; @@ -42,7 +42,7 @@ fuzz_target!(|module: WasmSmithModule| { let mut compiler = Cranelift::default(); compiler.canonicalize_nans(true); compiler.enable_verifier(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes).unwrap(); match Instance::new(&module, &imports! {}) { Ok(_) => {} diff --git a/fuzz/fuzz_targets/jit_llvm.rs b/fuzz/fuzz_targets/universal_llvm.rs similarity index 94% rename from fuzz/fuzz_targets/jit_llvm.rs rename to fuzz/fuzz_targets/universal_llvm.rs index 0bde001c11c..0d0044e0261 100644 --- a/fuzz/fuzz_targets/jit_llvm.rs +++ b/fuzz/fuzz_targets/universal_llvm.rs @@ -4,7 +4,7 @@ use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use wasm_smith::{Config, ConfiguredModule}; use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer_compiler_llvm::LLVM; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; #[derive(Arbitrary, Debug, Default, Copy, Clone)] struct NoImportsConfig; @@ -42,7 +42,7 @@ fuzz_target!(|module: WasmSmithModule| { let mut compiler = LLVM::default(); compiler.canonicalize_nans(true); compiler.enable_verifier(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes).unwrap(); match Instance::new(&module, &imports! {}) { Ok(_) => {} diff --git a/fuzz/fuzz_targets/jit_singlepass.rs b/fuzz/fuzz_targets/universal_singlepass.rs similarity index 95% rename from fuzz/fuzz_targets/jit_singlepass.rs rename to fuzz/fuzz_targets/universal_singlepass.rs index 0a150850882..5e99e15c505 100644 --- a/fuzz/fuzz_targets/jit_singlepass.rs +++ b/fuzz/fuzz_targets/universal_singlepass.rs @@ -4,7 +4,7 @@ use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use wasm_smith::{Config, ConfiguredModule}; use wasmer::{imports, Instance, Module, Store}; use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; +use wasmer_engine_universal::Universal; #[derive(Arbitrary, Debug, Default, Copy, Clone)] struct NoImportsConfig; @@ -40,7 +40,7 @@ fuzz_target!(|module: WasmSmithModule| { } let compiler = Singlepass::default(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new(&store, &wasm_bytes); let module = match module { Ok(m) => m, diff --git a/fuzzbuzz.yaml b/fuzzbuzz.yaml index 7a40bac3826..cbf6d4aef57 100644 --- a/fuzzbuzz.yaml +++ b/fuzzbuzz.yaml @@ -1,7 +1,7 @@ wasmer: language: rust features: - - jit + - universal - cranelift - singlepass deps: diff --git a/lib/api/Cargo.toml b/lib/api/Cargo.toml index 2b5f17bf54c..0845bf80df1 100644 --- a/lib/api/Cargo.toml +++ b/lib/api/Cargo.toml @@ -18,7 +18,7 @@ wasmer-compiler-llvm = { path = "../compiler-llvm", version = "1.0.2", optional wasmer-compiler = { path = "../compiler", version = "1.0.2" } wasmer-derive = { path = "../derive", version = "1.0.2" } wasmer-engine = { path = "../engine", version = "1.0.2" } -wasmer-engine-jit = { path = "../engine-jit", version = "1.0.2", optional = true } +wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2", optional = true } wasmer-engine-native = { path = "../engine-native", version = "1.0.2", optional = true } wasmer-types = { path = "../types", version = "1.0.2" } indexmap = { version = "1.4", features = ["serde-1"] } @@ -43,15 +43,15 @@ anyhow = "1.0" maintenance = { status = "actively-developed" } [features] -default = ["wat", "default-cranelift", "default-jit"] +default = ["wat", "default-cranelift", "default-universal"] compiler = [ "wasmer-compiler/translator", - "wasmer-engine-jit/compiler", + "wasmer-engine-universal/compiler", "wasmer-engine-native/compiler", ] engine = [] -jit = [ - "wasmer-engine-jit", +universal = [ + "wasmer-engine-universal", "engine" ] native = [ @@ -87,8 +87,8 @@ default-llvm = [ "llvm", "default-compiler" ] -default-jit = [ - "jit", +default-universal = [ + "universal", "default-engine" ] default-native = [ diff --git a/lib/api/README.md b/lib/api/README.md index 737bc7c3f97..7ef67360b74 100644 --- a/lib/api/README.md +++ b/lib/api/README.md @@ -1,7 +1,8 @@ # `wasmer` [![Build Status](https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square)](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [![Join Wasmer Slack](https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square)](https://slack.wasmer.io) [![MIT License](https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square)](https://github.com/wasmerio/wasmer/blob/master/LICENSE) [![crates.io](https://img.shields.io/crates/v/wasmer.svg)](https://crates.io/crates/wasmer) -[`Wasmer`](https://wasmer.io/) is the most popular [WebAssembly](https://webassembly.org/) -runtime for Rust (...and also the fastest). It supports JIT (Just in Time) and AOT (Ahead of time) +[`Wasmer`](https://wasmer.io/) is the most popular +[WebAssembly](https://webassembly.org/) runtime for Rust (...and also +the fastest). It supports JIT (Just in Time) and AOT (Ahead of time) compilation as well as pluggable compilers suited to your needs. It's designed to be safe and secure, and runnable in any kind of environment. diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index cb178282f81..0d6a8195663 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -215,7 +215,7 @@ //! enable new functionality and features that set defaults. //! //! The features that enable new functionality are: -//! - `jit` - enable the JIT engine. (See [wasmer-jit][]) +//! - `universal` - enable the Universal engine. (See [wasmer-universal][]) //! - `native` - enable the native engine. (See [wasmer-native][]) //! - `cranelift` - enable Wasmer's Cranelift compiler. (See [wasmer-cranelift][]) //! - `llvm` - enable Wasmer's LLVM compiler. (See [wasmer-llvm][]) @@ -230,12 +230,12 @@ //! - `default-singlepass` - set Wasmer's Singlepass compiler as the default. //! //! The next set is the default engine set: -//! - `default-jit` - set the JIT engine as the default. +//! - `default-universal` - set the Universal engine as the default. //! - `default-native` - set the native engine as the default. //! //! -------- //! -//! By default the `wat`, `default-cranelift`, and `default-jit` features +//! By default the `wat`, `default-cranelift`, and `default-universal` features //! are enabled. //! //! @@ -247,7 +247,7 @@ //! [wasmer-cranelift]: https://docs.rs/wasmer-compiler-cranelift/*/wasmer_compiler_cranelift/ //! [wasmer-emscripten]: https://docs.rs/wasmer-emscripten/*/wasmer_emscripten/ //! [wasmer-engine]: https://docs.rs/wasmer-engine/*/wasmer_engine/ -//! [wasmer-jit]: https://docs.rs/wasmer-engine-jit/*/wasmer_engine_jit/ +//! [wasmer-universal]: https://docs.rs/wasmer-engine-universal/*/wasmer_engine_universal/ //! [wasmer-native]: https://docs.rs/wasmer-engine-native/*/wasmer_engine_native/ //! [wasmer-singlepass]: https://docs.rs/wasmer-compiler-singlepass/*/wasmer_compiler_singlepass/ //! [wasmer-llvm]: https://docs.rs/wasmer-compiler-llvm/*/wasmer_compiler_llvm/ @@ -348,9 +348,9 @@ compile_error!( If you wish to use more than one compiler, you can simply create the own store. Eg.: ``` -use wasmer::{Store, JIT, Singlepass}; +use wasmer::{Store, Universal, Singlepass}; -let engine = JIT::new(Singlepass::default()).engine(); +let engine = Universal::new(Singlepass::default()).engine(); let store = Store::new(&engine); ```"# ); @@ -364,8 +364,8 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel}; #[cfg(feature = "llvm")] pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM}; -#[cfg(feature = "jit")] -pub use wasmer_engine_jit::{JITArtifact, JITEngine, JIT}; +#[cfg(feature = "universal")] +pub use wasmer_engine_universal::{Universal, UniversalArtifact, UniversalEngine}; #[cfg(feature = "native")] pub use wasmer_engine_native::{Native, NativeArtifact, NativeEngine}; diff --git a/lib/api/src/module.rs b/lib/api/src/module.rs index 1832849be39..6d936a5f3d8 100644 --- a/lib/api/src/module.rs +++ b/lib/api/src/module.rs @@ -55,7 +55,7 @@ impl Module { /// /// Creating a WebAssembly module from bytecode can result in a /// [`CompileError`] since this operation requires to transorm the Wasm - /// bytecode into code the machine can easily execute (normally through a JIT). + /// bytecode into code the machine can easily execute. /// /// ## Example /// diff --git a/lib/api/src/store.rs b/lib/api/src/store.rs index 4bee9e996b6..7578b20e929 100644 --- a/lib/api/src/store.rs +++ b/lib/api/src/store.rs @@ -126,8 +126,8 @@ impl Default for Store { #[allow(unreachable_code, unused_mut)] fn get_engine(mut config: impl CompilerConfig + 'static) -> impl Engine + Send + Sync { cfg_if::cfg_if! { - if #[cfg(feature = "default-jit")] { - wasmer_engine_jit::JIT::new(config) + if #[cfg(feature = "default-universal")] { + wasmer_engine_universal::Universal::new(config) .engine() } else if #[cfg(feature = "default-native")] { wasmer_engine_native::Native::new(config) diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index 0bd8455c152..3b22fb5a93c 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -21,7 +21,7 @@ wasmer-compiler-singlepass = { version = "1.0.2", path = "../compiler-singlepass wasmer-compiler-llvm = { version = "1.0.2", path = "../compiler-llvm", optional = true } wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true } wasmer-engine = { version = "1.0.2", path = "../engine" } -wasmer-engine-jit = { version = "1.0.2", path = "../engine-jit", optional = true } +wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true } wasmer-engine-native = { version = "1.0.2", path = "../engine-native", optional = true } wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true } wasmer-middlewares = { version = "1.0.2", path = "../middlewares", optional = true } @@ -46,7 +46,7 @@ default = [ "deprecated", "wat", "cranelift", - "jit", + "universal", "wasi", "middlewares", ] @@ -55,8 +55,8 @@ wasi = ["wasmer-wasi", "typetag", "serde"] engine = [] middlewares = ["wasmer-middlewares"] deprecated = ["libffi", "wasmer/experimental-reference-types-extern-ref"] -jit = [ - "wasmer-engine-jit", +universal = [ + "wasmer-engine-universal", "engine", ] native = [ @@ -69,7 +69,7 @@ object-file = [ ] compiler = [ "wasmer/compiler", - "wasmer-engine-jit/compiler", + "wasmer-engine-universal/compiler", "wasmer-engine-native/compiler", "wasmer-engine-object-file/compiler" ] diff --git a/lib/c-api/build.rs b/lib/c-api/build.rs index 57b781d29ab..8d72e5d4777 100644 --- a/lib/c-api/build.rs +++ b/lib/c-api/build.rs @@ -36,7 +36,7 @@ const PRE_HEADER: &'static str = r#" "#; #[allow(unused)] -const JIT_FEATURE_AS_C_DEFINE: &'static str = "WASMER_JIT_ENABLED"; +const UNIVERSAL_FEATURE_AS_C_DEFINE: &'static str = "WASMER_UNIVERSAL_ENABLED"; #[allow(unused)] const COMPILER_FEATURE_AS_C_DEFINE: &'static str = "WASMER_COMPILER_ENABLED"; @@ -138,7 +138,7 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) { pre_header = PRE_HEADER ); - map_feature_as_c_define!("jit", JIT_FEATURE_AS_C_DEFINE, pre_header); + map_feature_as_c_define!("universal", UNIVERSAL_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("compiler", COMPILER_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("wasi", WASI_FEATURE_AS_C_DEFINE, pre_header); map_feature_as_c_define!("middlewares", MIDDLEWARES_FEATURE_AS_C_DEFINE, pre_header); @@ -294,7 +294,7 @@ fn new_builder(language: Language, crate_dir: &str, include_guard: &str, header: .with_documentation(false) .with_define("target_family", "windows", "_WIN32") .with_define("target_arch", "x86_64", "ARCH_X86_64") - .with_define("feature", "jit", JIT_FEATURE_AS_C_DEFINE) + .with_define("feature", "universal", UNIVERSAL_FEATURE_AS_C_DEFINE) .with_define("feature", "compiler", COMPILER_FEATURE_AS_C_DEFINE) .with_define("feature", "wasi", WASI_FEATURE_AS_C_DEFINE) .with_define("feature", "emscripten", EMSCRIPTEN_FEATURE_AS_C_DEFINE); diff --git a/lib/c-api/src/wasm_c_api/engine.rs b/lib/c-api/src/wasm_c_api/engine.rs index e9014320292..2ed473de69f 100644 --- a/lib/c-api/src/wasm_c_api/engine.rs +++ b/lib/c-api/src/wasm_c_api/engine.rs @@ -12,12 +12,12 @@ use crate::error::{update_last_error, CApiError}; use cfg_if::cfg_if; use std::sync::Arc; use wasmer::Engine; -#[cfg(feature = "jit")] -use wasmer_engine_jit::JIT; #[cfg(feature = "native")] use wasmer_engine_native::Native; #[cfg(feature = "object-file")] use wasmer_engine_object_file::ObjectFile; +#[cfg(feature = "universal")] +use wasmer_engine_universal::Universal; /// Kind of compilers that can be used by the engines. /// @@ -65,9 +65,9 @@ impl Default for wasmer_compiler_t { #[repr(C)] #[allow(non_camel_case_types)] pub enum wasmer_engine_t { - /// Variant to represent the JIT engine. See the - /// [`wasmer_engine_jit`] Rust crate. - JIT = 0, + /// Variant to represent the universal engine. See the + /// [`wasmer_engine_universal`] Rust crate. + UNIVERSAL = 0, /// Variant to represent the Native engine. See the /// [`wasmer_engine_native`] Rust crate. @@ -81,8 +81,8 @@ pub enum wasmer_engine_t { impl Default for wasmer_engine_t { fn default() -> Self { cfg_if! { - if #[cfg(feature = "jit")] { - Self::JIT + if #[cfg(feature = "universal")] { + Self::UNIVERSAL } else if #[cfg(feature = "native")] { Self::NATIVE } else if #[cfg(feature = "object-file")] { @@ -245,9 +245,9 @@ pub extern "C" fn wasm_config_set_compiler( /// // Create the configuration. /// wasm_config_t* config = wasm_config_new(); /// -/// // Use the JIT engine, if available. -/// if (wasmer_is_engine_available(JIT)) { -/// wasm_config_set_engine(config, JIT); +/// // Use the Universal engine, if available. +/// if (wasmer_is_engine_available(UNIVERSAL)) { +/// wasm_config_set_engine(config, UNIVERSAL); /// } /// // Or maybe the Native engine? /// else if (wasmer_is_engine_available(NATIVE)) { @@ -284,9 +284,9 @@ pub struct wasm_engine_t { pub(crate) inner: Arc, } -// Compiler JIT #[cfg(feature = "compiler")] use wasmer::CompilerConfig; + #[cfg(feature = "compiler")] fn get_default_compiler_config() -> Box { cfg_if! { @@ -303,8 +303,8 @@ fn get_default_compiler_config() -> Box { } cfg_if! { - if #[cfg(all(feature = "jit", feature = "compiler"))] { - /// Creates a new JIT engine with the default compiler. + if #[cfg(all(feature = "universal", feature = "compiler"))] { + /// Creates a new Universal engine with the default compiler. /// /// # Example /// @@ -314,11 +314,11 @@ cfg_if! { #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { let compiler_config: Box = get_default_compiler_config(); - let engine: Arc = Arc::new(JIT::new(compiler_config).engine()); + let engine: Arc = Arc::new(Universal::new(compiler_config).engine()); Box::new(wasm_engine_t { inner: engine }) } - } else if #[cfg(feature = "jit")] { - /// Creates a new headless JIT engine. + } else if #[cfg(feature = "universal")] { + /// Creates a new headless Universal engine. /// /// # Example /// @@ -327,7 +327,7 @@ cfg_if! { /// cbindgen:ignore #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { - let engine: Arc = Arc::new(JIT::headless().engine()); + let engine: Arc = Arc::new(Universal::headless().engine()); Box::new(wasm_engine_t { inner: engine }) } } else if #[cfg(all(feature = "native", feature = "compiler"))] { @@ -383,7 +383,7 @@ cfg_if! { /// cbindgen:ignore #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { - unimplemented!("No engine attached; You might want to recompile `wasmer_c_api` with for example `--feature jit`"); + unimplemented!("No engine attached; You might want to recompile `wasmer_c_api` with for example `--feature universal`"); } } } @@ -483,10 +483,10 @@ pub extern "C" fn wasm_engine_new_with_config( } let inner: Arc = match config.engine { - wasmer_engine_t::JIT => { + wasmer_engine_t::UNIVERSAL => { cfg_if! { - if #[cfg(feature = "jit")] { - let mut builder = JIT::new(compiler_config); + if #[cfg(feature = "universal")] { + let mut builder = Universal::new(compiler_config); if let Some(target) = config.target { builder = builder.target(target.inner); @@ -498,7 +498,7 @@ pub extern "C" fn wasm_engine_new_with_config( Arc::new(builder.engine()) } else { - return return_with_error("Wasmer has not been compiled with the `jit` feature."); + return return_with_error("Wasmer has not been compiled with the `universal` feature."); } } }, @@ -546,10 +546,10 @@ pub extern "C" fn wasm_engine_new_with_config( Some(Box::new(wasm_engine_t { inner })) } else { let inner: Arc = match config.engine { - wasmer_engine_t::JIT => { + wasmer_engine_t::UNIVERSAL => { cfg_if! { - if #[cfg(feature = "jit")] { - let mut builder = JIT::headless(); + if #[cfg(feature = "universal")] { + let mut builder = Universal::headless(); if let Some(target) = config.target { builder = builder.target(target.inner); @@ -561,7 +561,7 @@ pub extern "C" fn wasm_engine_new_with_config( Arc::new(builder.engine()) } else { - return return_with_error("Wasmer has not been compiled with the `jit` feature."); + return return_with_error("Wasmer has not been compiled with the `universal` feature."); } } }, diff --git a/lib/c-api/src/wasm_c_api/unstable/engine.rs b/lib/c-api/src/wasm_c_api/unstable/engine.rs index f20d00742b8..f07d9ec1795 100644 --- a/lib/c-api/src/wasm_c_api/unstable/engine.rs +++ b/lib/c-api/src/wasm_c_api/unstable/engine.rs @@ -119,7 +119,7 @@ pub extern "C" fn wasmer_is_headless() -> bool { #[no_mangle] pub extern "C" fn wasmer_is_engine_available(engine: wasmer_engine_t) -> bool { match engine { - wasmer_engine_t::JIT if cfg!(feature = "jit") => true, + wasmer_engine_t::UNIVERSAL if cfg!(feature = "universal") => true, wasmer_engine_t::NATIVE if cfg!(feature = "native") => true, wasmer_engine_t::OBJECT_FILE if cfg!(feature = "object-file") => true, _ => false, @@ -194,7 +194,14 @@ mod tests { #[test] fn test_wasmer_is_engine_available() { - set_var("JIT", if cfg!(feature = "jit") { "1" } else { "0" }); + set_var( + "UNIVERSAL", + if cfg!(feature = "universal") { + "1" + } else { + "0" + }, + ); set_var("NATIVE", if cfg!(feature = "native") { "1" } else { "0" }); set_var( "OBJECT_FILE", @@ -210,7 +217,7 @@ mod tests { #include int main() { - assert(wasmer_is_engine_available(JIT) == (getenv("JIT")[0] == '1')); + assert(wasmer_is_engine_available(UNIVERSAL) == (getenv("UNIVERSAL")[0] == '1')); assert(wasmer_is_engine_available(NATIVE) == (getenv("NATIVE")[0] == '1')); assert(wasmer_is_engine_available(OBJECT_FILE) == (getenv("OBJECT_FILE")[0] == '1')); @@ -219,7 +226,7 @@ mod tests { }) .success(); - remove_var("JIT"); + remove_var("UNIVERSAL"); remove_var("NATIVE"); remove_var("OBJECT_FILE"); } diff --git a/lib/c-api/tests/wasm.h b/lib/c-api/tests/wasm.h index 6e3d90d4351..9fe5591cc19 100644 --- a/lib/c-api/tests/wasm.h +++ b/lib/c-api/tests/wasm.h @@ -32,8 +32,8 @@ wasm_engine_t *wasm_engine_new() { abort(); } if (strcmp(wasmer_test_engine, "jit") == 0) { - assert(wasmer_is_engine_available(JIT)); - wasm_config_set_engine(config, JIT); + assert(wasmer_is_engine_available(UNIVERSAL)); + wasm_config_set_engine(config, UNIVERSAL); } else if (strcmp(wasmer_test_engine, "native") == 0) { assert(wasmer_is_engine_available(NATIVE)); wasm_config_set_engine(config, NATIVE); diff --git a/lib/c-api/wasmer_wasm.h b/lib/c-api/wasmer_wasm.h index 0d013ebf8b3..8cfc242d058 100644 --- a/lib/c-api/wasmer_wasm.h +++ b/lib/c-api/wasmer_wasm.h @@ -62,8 +62,8 @@ # define DEPRECATED(message) __declspec(deprecated(message)) #endif -// The `jit` feature has been enabled for this build. -#define WASMER_JIT_ENABLED +// The `universal` feature has been enabled for this build. +#define WASMER_UNIVERSAL_ENABLED // The `compiler` feature has been enabled for this build. #define WASMER_COMPILER_ENABLED @@ -124,7 +124,7 @@ typedef enum wasmer_compiler_t { #endif typedef enum wasmer_engine_t { - JIT = 0, + UNIVERSAL = 0, NATIVE = 1, OBJECT_FILE = 2, } wasmer_engine_t; diff --git a/lib/cache/Cargo.toml b/lib/cache/Cargo.toml index e37541399e1..82d769ab9da 100644 --- a/lib/cache/Cargo.toml +++ b/lib/cache/Cargo.toml @@ -21,7 +21,7 @@ criterion = "0.3" tempfile = "3" rand = "0.8.3" wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "1.0.2" } -wasmer-engine-jit = { path = "../engine-jit", version = "1.0.2" } +wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2" } wasmer-engine-native = { path = "../engine-native", version = "1.0.2" } [[bench]] diff --git a/lib/cache/benches/bench_filesystem_cache.rs b/lib/cache/benches/bench_filesystem_cache.rs index 8a9650ef86f..98cab045396 100644 --- a/lib/cache/benches/bench_filesystem_cache.rs +++ b/lib/cache/benches/bench_filesystem_cache.rs @@ -6,25 +6,25 @@ use wasmer::{Module, Store}; use wasmer_cache::Cache; use wasmer_cache::{FileSystemCache, Hash}; use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; use wasmer_engine_native::Native; +use wasmer_engine_universal::Universal; fn random_key() -> Hash { Hash::new(rand::thread_rng().gen::<[u8; 32]>()) } -pub fn store_cache_jit(c: &mut Criterion) { +pub fn store_cache_universal(c: &mut Criterion) { let tmp_dir = TempDir::new().unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let compiler = Singlepass::default(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new( &store, std::fs::read("../../lib/c-api/tests/assets/qjs.wasm").unwrap(), ) .unwrap(); - c.bench_function("store jit module in filesystem cache", |b| { + c.bench_function("store universal module in filesystem cache", |b| { b.iter(|| { let key = random_key(); fs_cache.store(key, &module).unwrap() @@ -32,11 +32,11 @@ pub fn store_cache_jit(c: &mut Criterion) { }); } -pub fn load_cache_jit(c: &mut Criterion) { +pub fn load_cache_universal(c: &mut Criterion) { let tmp_dir = TempDir::new().unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let compiler = Singlepass::default(); - let store = Store::new(&JIT::new(compiler).engine()); + let store = Store::new(&Universal::new(compiler).engine()); let module = Module::new( &store, std::fs::read("../../lib/c-api/tests/assets/qjs.wasm").unwrap(), @@ -45,7 +45,7 @@ pub fn load_cache_jit(c: &mut Criterion) { let key = Hash::new([0u8; 32]); fs_cache.store(key, &module).unwrap(); - c.bench_function("load jit module in filesystem cache", |b| { + c.bench_function("load universal module in filesystem cache", |b| { b.iter(|| unsafe { fs_cache.load(&store, key.clone()).unwrap() }) }); } @@ -90,6 +90,6 @@ pub fn load_cache_native(c: &mut Criterion) { criterion_group! { name = benches; config = Criterion::default().sample_size(300); - targets = store_cache_jit, load_cache_jit, store_cache_native, load_cache_native + targets = store_cache_universal, load_cache_universal, store_cache_native, load_cache_native } criterion_main!(benches); diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 0d65764a77c..c38fdbc06e1 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -31,7 +31,7 @@ wasmer-compiler-singlepass = { version = "1.0.2", path = "../compiler-singlepass wasmer-compiler-llvm = { version = "1.0.2", path = "../compiler-llvm", optional = true } wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true } wasmer-engine = { version = "1.0.2", path = "../engine" } -wasmer-engine-jit = { version = "1.0.2", path = "../engine-jit", optional = true } +wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true } wasmer-engine-native = { version = "1.0.2", path = "../engine-native", optional = true } wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true } wasmer-vm = { version = "1.0.2", path = "../vm" } @@ -60,7 +60,7 @@ tempfile = "3" default = [ "wat", "wast", - "jit", + "universal", "native", "object-file", "cache", @@ -68,8 +68,8 @@ default = [ "emscripten", ] engine = [] -jit = [ - "wasmer-engine-jit", +universal = [ + "wasmer-engine-universal", "engine", ] native = [ @@ -87,7 +87,7 @@ emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] compiler = [ "wasmer-compiler/translator", - "wasmer-engine-jit/compiler", + "wasmer-engine-universal/compiler", "wasmer-engine-native/compiler", "wasmer-engine-object-file/compiler", ] @@ -110,4 +110,4 @@ llvm = [ debug = ["fern", "log", "wasmer-wasi/logging"] disable-all-logging = ["wasmer-wasi/disable-all-logging"] headless = [] -headless-minimal = ["headless", "disable-all-logging", "wasi", "native", "jit"] +headless-minimal = ["headless", "disable-all-logging", "wasi", "native", "universal"] diff --git a/lib/cli/README.md b/lib/cli/README.md index 1c68af6f03f..6b93954b1c9 100644 --- a/lib/cli/README.md +++ b/lib/cli/README.md @@ -25,7 +25,7 @@ cargo build --release --features "singlepass,cranelift" The Wasmer supports the following features: * `wat` (default): support for executing WebAssembly text files. * `wast`(default): support for running wast test files. -* `jit` (default): support for the [JIT engine]. +* `universal` (default): support for the [Universal engine]. * `native` (default): support for the [Native engine]. * `cache` (default): support or automatically caching compiled artifacts. * `wasi` (default): support for [WASI]. @@ -35,7 +35,7 @@ The Wasmer supports the following features: * `cranelift`: support for the [Cranelift compiler]. * `llvm`: support for the [LLVM compiler]. -[JIT Engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-jit/ +[Universal Engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal/ [Native Engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-native/ [WASI]: https://github.com/wasmerio/wasmer/tree/master/lib/wasi/ [Emscripten]: https://github.com/wasmerio/wasmer/tree/master/lib/emscripten/ diff --git a/lib/cli/src/commands/compile.rs b/lib/cli/src/commands/compile.rs index 56bc69b8c86..499a2d108fd 100644 --- a/lib/cli/src/commands/compile.rs +++ b/lib/cli/src/commands/compile.rs @@ -47,13 +47,15 @@ impl Compile { EngineType::Native => { wasmer_engine_native::NativeArtifact::get_default_extension(target_triple) } - #[cfg(feature = "jit")] - EngineType::JIT => wasmer_engine_jit::JITArtifact::get_default_extension(target_triple), + #[cfg(feature = "universal")] + EngineType::Universal => { + wasmer_engine_universal::UniversalArtifact::get_default_extension(target_triple) + } #[cfg(feature = "object-file")] EngineType::ObjectFile => { wasmer_engine_object_file::ObjectFileArtifact::get_default_extension(target_triple) } - #[cfg(not(all(feature = "native", feature = "jit", feature = "object-file")))] + #[cfg(not(all(feature = "native", feature = "universal", feature = "object-file")))] _ => bail!("selected engine type is not compiled in"), }) } diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index a6c2dfefe62..f73f1397e96 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -214,10 +214,10 @@ impl Run { return Ok(module); } } - #[cfg(feature = "jit")] + #[cfg(feature = "universal")] { - if wasmer_engine_jit::JITArtifact::is_deserializable(&contents) { - let engine = wasmer_engine_jit::JIT::headless().engine(); + if wasmer_engine_universal::UniversalArtifact::is_deserializable(&contents) { + let engine = wasmer_engine_universal::Universal::headless().engine(); let store = Store::new(&engine); let module = unsafe { Module::deserialize_from_file(&store, &self.path)? }; return Ok(module); @@ -305,9 +305,10 @@ impl Run { wasmer_engine_native::NativeArtifact::get_default_extension(&Triple::host()) .to_string() } - #[cfg(feature = "jit")] - EngineType::JIT => { - wasmer_engine_jit::JITArtifact::get_default_extension(&Triple::host()).to_string() + #[cfg(feature = "universal")] + EngineType::Universal => { + wasmer_engine_universal::UniversalArtifact::get_default_extension(&Triple::host()) + .to_string() } // We use the compiler type as the default extension _ => compiler_type.to_string(), diff --git a/lib/cli/src/store.rs b/lib/cli/src/store.rs index 2a8095c3c38..bf61f55e3d0 100644 --- a/lib/cli/src/store.rs +++ b/lib/cli/src/store.rs @@ -19,16 +19,16 @@ pub struct StoreOptions { #[clap(flatten)] compiler: CompilerOptions, - /// Use JIT Engine. + /// Use Universal Engine. #[clap(long, conflicts_with_all = &["native", "object-file"])] - jit: bool, + universal: bool, /// Use Native Engine. - #[clap(long, conflicts_with_all = &["jit", "object-file"])] + #[clap(long, conflicts_with_all = &["universal", "object-file"])] native: bool, /// Use ObjectFile Engine. - #[clap(long, conflicts_with_all = &["jit", "native"])] + #[clap(long, conflicts_with_all = &["universal", "native"])] object_file: bool, } @@ -136,9 +136,9 @@ impl CompilerOptions { ) -> Result> { let features = self.get_features(compiler_config.default_features_for_target(&target))?; let engine: Box = match engine_type { - #[cfg(feature = "jit")] - EngineType::JIT => Box::new( - wasmer_engine_jit::JIT::new(compiler_config) + #[cfg(feature = "universal")] + EngineType::Universal => Box::new( + wasmer_engine_universal::Universal::new(compiler_config) .features(features) .target(target) .engine(), @@ -157,7 +157,7 @@ impl CompilerOptions { .features(features) .engine(), ), - #[cfg(not(all(feature = "jit", feature = "native", feature = "object-file")))] + #[cfg(not(all(feature = "universal", feature = "native", feature = "object-file")))] engine => bail!( "The `{}` engine is not included in this binary.", engine.to_string() @@ -360,8 +360,8 @@ impl FromStr for CompilerType { /// The engine used for the store #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum EngineType { - /// JIT Engine - JIT, + /// Universal Engine + Universal, /// Native Engine Native, /// Object File Engine @@ -371,7 +371,7 @@ pub enum EngineType { impl ToString for EngineType { fn to_string(&self) -> String { match self { - Self::JIT => "jit".to_string(), + Self::Universal => "universal".to_string(), Self::Native => "native".to_string(), Self::ObjectFile => "objectfile".to_string(), } @@ -414,16 +414,16 @@ impl StoreOptions { #[cfg(feature = "engine")] impl StoreOptions { fn get_engine(&self) -> Result { - if self.jit { - Ok(EngineType::JIT) + if self.universal { + Ok(EngineType::Universal) } else if self.native { Ok(EngineType::Native) } else if self.object_file { Ok(EngineType::ObjectFile) } else { // Auto mode, we choose the best engine for that platform - if cfg!(feature = "jit") { - Ok(EngineType::JIT) + if cfg!(feature = "universal") { + Ok(EngineType::Universal) } else if cfg!(feature = "native") { Ok(EngineType::Native) } else if cfg!(feature = "object-file") { @@ -441,15 +441,17 @@ impl StoreOptions { fn get_engine_headless(&self) -> Result<(Arc, EngineType)> { let engine_type = self.get_engine()?; let engine: Arc = match engine_type { - #[cfg(feature = "jit")] - EngineType::JIT => Arc::new(wasmer_engine_jit::JIT::headless().engine()), + #[cfg(feature = "universal")] + EngineType::Universal => { + Arc::new(wasmer_engine_universal::Universal::headless().engine()) + } #[cfg(feature = "native")] EngineType::Native => Arc::new(wasmer_engine_native::Native::headless().engine()), #[cfg(feature = "object-file")] EngineType::ObjectFile => { Arc::new(wasmer_engine_object_file::ObjectFile::headless().engine()) } - #[cfg(not(all(feature = "jit", feature = "native", feature = "object-file")))] + #[cfg(not(all(feature = "universal", feature = "native", feature = "object-file")))] engine => bail!( "The `{}` engine is not included in this binary.", engine.to_string() diff --git a/lib/compiler-cranelift/README.md b/lib/compiler-cranelift/README.md index 476d9718f75..f10abbe30ba 100644 --- a/lib/compiler-cranelift/README.md +++ b/lib/compiler-cranelift/README.md @@ -5,12 +5,12 @@ This crate contains a compiler implementation based on Cranelift. ## Usage ```rust -use wasmer::{Store, JIT}; +use wasmer::{Store, Universal}; use wasmer_compiler_cranelift::Cranelift; let compiler = Cranelift::new(); // Put it into an engine and add it to the store -let store = Store::new(&JIT::new(compiler).engine()); +let store = Store::new(&Universal::new(compiler).engine()); ``` *Note: you can find a [full working example using Cranelift compiler diff --git a/lib/compiler-llvm/README.md b/lib/compiler-llvm/README.md index 18391c7c7e6..524ebd3e7c4 100644 --- a/lib/compiler-llvm/README.md +++ b/lib/compiler-llvm/README.md @@ -5,12 +5,12 @@ This crate contains a compiler implementation based on [the LLVM Compiler Infras ## Usage ```rust -use wasmer::{Store, JIT}; +use wasmer::{Store, Universal}; use wasmer_compiler_llvm::LLVM; let compiler = LLVM::new(); // Put it into an engine and add it to the store -let store = Store::new(&JIT::new(compiler).engine()); +let store = Store::new(&Universal::new(compiler).engine()); ``` *Note: you can find a [full working example using LLVM compiler here][example].* diff --git a/lib/compiler-singlepass/README.md b/lib/compiler-singlepass/README.md index b8589f4bb7f..4265359f378 100644 --- a/lib/compiler-singlepass/README.md +++ b/lib/compiler-singlepass/README.md @@ -5,12 +5,12 @@ This crate contains a compiler implementation based on the Singlepass linear com ## Usage ```rust -use wasmer::{Store, JIT}; +use wasmer::{Store, Universal}; use wasmer_compiler_singlepass::Singlepass; let compiler = Singlepass::new(); // Put it into an engine and add it to the store -let store = Store::new(&JIT::new(compiler).engine()); +let store = Store::new(&Universal::new(compiler).engine()); ``` *Note: you can find a [full working example using Singlepass compiler diff --git a/lib/compiler/src/function.rs b/lib/compiler/src/function.rs index 98be7a63255..c649ae0e3dd 100644 --- a/lib/compiler/src/function.rs +++ b/lib/compiler/src/function.rs @@ -3,10 +3,6 @@ //! A `Compilation` contains the compiled function bodies for a WebAssembly //! module (`CompiledFunction`). -//! -//! The `CompiledFunction` will be used mainly by different frontends: -//! * `jit`: to generate a JIT -//! * `obj`: to generate a native object use crate::lib::std::vec::Vec; use crate::section::{CustomSection, SectionIndex}; diff --git a/lib/deprecated/runtime-core/Cargo.lock b/lib/deprecated/runtime-core/Cargo.lock index 9e6a99fb787..b5aef7dfee1 100644 --- a/lib/deprecated/runtime-core/Cargo.lock +++ b/lib/deprecated/runtime-core/Cargo.lock @@ -1182,7 +1182,7 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-jit", + "wasmer-engine-universal", "wasmer-engine-native", "wasmer-types", "wasmer-vm", @@ -1305,7 +1305,7 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-jit" +name = "wasmer-engine-universal" version = "1.0.2" dependencies = [ "cfg-if 0.1.10", @@ -1363,7 +1363,7 @@ dependencies = [ "wasmer-compiler-llvm", "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", + "wasmer-engine-universal", "wasmer-types", "wasmer-vm", ] diff --git a/lib/deprecated/runtime-core/Cargo.toml b/lib/deprecated/runtime-core/Cargo.toml index 08c1b58b964..cd44b8ac498 100644 --- a/lib/deprecated/runtime-core/Cargo.toml +++ b/lib/deprecated/runtime-core/Cargo.toml @@ -22,7 +22,7 @@ wasmer-compiler-llvm = { path = "../../compiler-llvm", version = "1.0.2", option wasmer-compiler-cranelift = { path = "../../compiler-cranelift", version = "1.0.2", optional = true } wasmer-compiler-singlepass = { path = "../../compiler-singlepass", version = "1.0.2", optional = true } wasmer-engine = { path = "../../engine", version = "1.0.2" } -wasmer-engine-jit = { path = "../../engine-jit", version = "1.0.2" } +wasmer-engine-universal = { path = "../../engine-universal", version = "1.0.2" } wasmer-vm = { path = "../../vm", version = "1.0.2" } lazy_static = "1.4" diff --git a/lib/deprecated/runtime/Cargo.lock b/lib/deprecated/runtime/Cargo.lock index f01518060b1..67c4b1943e1 100644 --- a/lib/deprecated/runtime/Cargo.lock +++ b/lib/deprecated/runtime/Cargo.lock @@ -1182,7 +1182,7 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-jit", + "wasmer-engine-universal", "wasmer-engine-native", "wasmer-types", "wasmer-vm", @@ -1305,7 +1305,7 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-jit" +name = "wasmer-engine-universal" version = "1.0.2" dependencies = [ "cfg-if 0.1.10", @@ -1370,7 +1370,7 @@ dependencies = [ "wasmer-compiler-llvm", "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", + "wasmer-engine-universal", "wasmer-types", "wasmer-vm", ] diff --git a/lib/engine-native/README.md b/lib/engine-native/README.md index 2bd5e7d542e..497014edadf 100644 --- a/lib/engine-native/README.md +++ b/lib/engine-native/README.md @@ -13,9 +13,9 @@ This allows Wasmer to achieve *blazing fast* **native startup times**. *Note: you can find a [full working example using the Native engine here][example].* -### Difference with `wasmer-engine-jit` +### Difference with `wasmer-engine-universal` -The Native Engine and JIT engine mainly differ on how the Modules are loaded/stored. +The Native Engine and Universal Engine mainly differ on how the Modules are loaded/stored. Using the same compilers, both will have the same runtime speed. However, the Native engine uses the Operating System shared library loader (via `dlopen`) diff --git a/lib/engine-jit/Cargo.toml b/lib/engine-universal/Cargo.toml similarity index 89% rename from lib/engine-jit/Cargo.toml rename to lib/engine-universal/Cargo.toml index 3caeebfecf0..c4f79bca9c1 100644 --- a/lib/engine-jit/Cargo.toml +++ b/lib/engine-universal/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-engine-jit" +name = "wasmer-engine-universal" version = "1.0.2" -description = "Wasmer JIT Engine" +description = "Wasmer Universal Engine" categories = ["wasm"] -keywords = ["wasm", "webassembly", "engine", "jit"] +keywords = ["wasm", "webassembly", "engine", "universal"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT OR Apache-2.0 WITH LLVM-exception " diff --git a/lib/engine-jit/README.md b/lib/engine-universal/README.md similarity index 54% rename from lib/engine-jit/README.md rename to lib/engine-universal/README.md index 2b16bfe0feb..93d9ac321f5 100644 --- a/lib/engine-jit/README.md +++ b/lib/engine-universal/README.md @@ -1,11 +1,11 @@ -# `wasmer-engine-jit` [![Build Status](https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square)](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [![Join Wasmer Slack](https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square)](https://slack.wasmer.io) [![MIT License](https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square)](https://github.com/wasmerio/wasmer/blob/master/LICENSE) +# `wasmer-engine-universal` [![Build Status](https://github.com/wasmerio/wasmer/workflows/build/badge.svg?style=flat-square)](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [![Join Wasmer Slack](https://img.shields.io/static/v1?label=Slack&message=join%20chat&color=brighgreen&style=flat-square)](https://slack.wasmer.io) [![MIT License](https://img.shields.io/github/license/wasmerio/wasmer.svg?style=flat-square)](https://github.com/wasmerio/wasmer/blob/master/LICENSE) -The Wasmer JIT engine is usable with any compiler implementation based -on [`wasmer-compiler`]. After the compiler process the result, the JIT +The Wasmer Universal engine is usable with any compiler implementation based +on [`wasmer-compiler`]. After the compiler process the result, the Universal pushes it into memory and links its contents so it can be usable by the [`wasmer`] API. -*Note: you can find a [full working example using the JIT engine +*Note: you can find a [full working example using the Universal engine here][example].* ### Acknowledgments @@ -20,6 +20,6 @@ attributions of the project. [`wasmer-compiler`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler [`wasmer`]: https://github.com/wasmerio/wasmer/tree/master/lib/api -[example]: https://github.com/wasmerio/wasmer/blob/master/examples/engine_jit.rs +[example]: https://github.com/wasmerio/wasmer/blob/master/examples/engine_universal.rs [`wasmtime-jit`]: https://crates.io/crates/wasmtime-jit [Wasmer `ATTRIBUTIONS`]: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md diff --git a/lib/engine-jit/src/artifact.rs b/lib/engine-universal/src/artifact.rs similarity index 87% rename from lib/engine-jit/src/artifact.rs rename to lib/engine-universal/src/artifact.rs index 1bc1c5e005f..451aa8d9fdb 100644 --- a/lib/engine-jit/src/artifact.rs +++ b/lib/engine-universal/src/artifact.rs @@ -1,7 +1,7 @@ -//! Define `JITArtifact` to allow compiling and instantiating to be +//! Define `UniversalArtifact` to allow compiling and instantiating to be //! done as separate steps. -use crate::engine::{JITEngine, JITEngineInner}; +use crate::engine::{UniversalEngine, UniversalEngineInner}; use crate::link::link_module; #[cfg(feature = "compiler")] use crate::serialize::SerializableCompilation; @@ -27,12 +27,12 @@ use wasmer_vm::{ VMTrampoline, }; -const SERIALIZED_METADATA_LENGTH_OFFSET: usize = 16; +const SERIALIZED_METADATA_LENGTH_OFFSET: usize = 22; const SERIALIZED_METADATA_CONTENT_OFFSET: usize = 32; /// A compiled wasm module, ready to be instantiated. #[derive(MemoryUsage)] -pub struct JITArtifact { +pub struct UniversalArtifact { serializable: SerializableModule, finished_functions: BoxedSlice, #[loupe(skip)] @@ -44,28 +44,28 @@ pub struct JITArtifact { finished_function_lengths: BoxedSlice, } -impl JITArtifact { - const MAGIC_HEADER: &'static [u8; 16] = b"\0wasmer-jit\0\0\0\0\0"; +impl UniversalArtifact { + const MAGIC_HEADER: &'static [u8; 22] = b"\0wasmer-universal\0\0\0\0\0"; - /// Check if the provided bytes look like a serialized `JITArtifact`. + /// Check if the provided bytes look like a serialized `UniversalArtifact`. pub fn is_deserializable(bytes: &[u8]) -> bool { bytes.starts_with(Self::MAGIC_HEADER) } - /// Compile a data buffer into a `JITArtifact`, which may then be instantiated. + /// Compile a data buffer into a `UniversalArtifact`, which may then be instantiated. #[cfg(feature = "compiler")] pub fn new( - jit: &JITEngine, + engine: &UniversalEngine, data: &[u8], tunables: &dyn Tunables, ) -> Result { let environ = ModuleEnvironment::new(); - let mut inner_jit = jit.inner_mut(); - let features = inner_jit.features(); + let mut inner_engine = engine.inner_mut(); + let features = inner_engine.features(); let translation = environ.translate(data).map_err(CompileError::Wasm)?; - let compiler = inner_jit.compiler()?; + let compiler = inner_engine.compiler()?; // We try to apply the middleware first let mut module = translation.module; @@ -92,7 +92,7 @@ impl JITArtifact { // Compile the Module let compilation = compiler.compile_module( - &jit.target(), + &engine.target(), &compile_info, // SAFETY: Calling `unwrap` is correct since // `environ.translate()` above will write some data into @@ -128,26 +128,29 @@ impl JITArtifact { compile_info, data_initializers, }; - Self::from_parts(&mut inner_jit, serializable) + Self::from_parts(&mut inner_engine, serializable) } - /// Compile a data buffer into a `JITArtifact`, which may then be instantiated. + /// Compile a data buffer into a `UniversalArtifact`, which may then be instantiated. #[cfg(not(feature = "compiler"))] - pub fn new(_jit: &JITEngine, _data: &[u8]) -> Result { + pub fn new(_engine: &UniversalEngine, _data: &[u8]) -> Result { Err(CompileError::Codegen( "Compilation is not enabled in the engine".to_string(), )) } - /// Deserialize a JITArtifact + /// Deserialize a UniversalArtifact /// /// # Safety /// This function is unsafe because rkyv reads directly without validating /// the data. - pub unsafe fn deserialize(jit: &JITEngine, bytes: &[u8]) -> Result { + pub unsafe fn deserialize( + universal: &UniversalEngine, + bytes: &[u8], + ) -> Result { if !Self::is_deserializable(bytes) { return Err(DeserializeError::Incompatible( - "The provided bytes are not wasmer-jit".to_string(), + "The provided bytes are not wasmer-universal".to_string(), )); } @@ -162,12 +165,13 @@ impl JITArtifact { ); let serializable = SerializableModule::deserialize(metadata_slice)?; - Self::from_parts(&mut jit.inner_mut(), serializable).map_err(DeserializeError::Compiler) + Self::from_parts(&mut universal.inner_mut(), serializable) + .map_err(DeserializeError::Compiler) } - /// Construct a `JITArtifact` from component parts. + /// Construct a `UniversalArtifact` from component parts. pub fn from_parts( - inner_jit: &mut JITEngineInner, + inner_engine: &mut UniversalEngineInner, serializable: SerializableModule, ) -> Result { let ( @@ -175,7 +179,7 @@ impl JITArtifact { finished_function_call_trampolines, finished_dynamic_function_trampolines, custom_sections, - ) = inner_jit.allocate( + ) = inner_engine.allocate( &serializable.compile_info.module, &serializable.compilation.function_bodies, &serializable.compilation.function_call_trampolines, @@ -194,7 +198,7 @@ impl JITArtifact { // Compute indices into the shared signature table. let signatures = { - let signature_registry = inner_jit.signatures(); + let signature_registry = inner_engine.signatures(); serializable .compile_info .module @@ -218,9 +222,9 @@ impl JITArtifact { None => None, }; // Make all code compiled thus far executable. - inner_jit.publish_compiled_code(); + inner_engine.publish_compiled_code(); - inner_jit.publish_eh_frame(eh_frame)?; + inner_engine.publish_eh_frame(eh_frame)?; let finished_function_lengths = finished_functions .values() @@ -237,7 +241,7 @@ impl JITArtifact { let finished_dynamic_function_trampolines = finished_dynamic_function_trampolines.into_boxed_slice(); let signatures = signatures.into_boxed_slice(); - let func_data_registry = inner_jit.func_data().clone(); + let func_data_registry = inner_engine.func_data().clone(); Ok(Self { serializable, @@ -253,12 +257,12 @@ impl JITArtifact { /// Get the default extension when serializing this artifact pub fn get_default_extension(_triple: &Triple) -> &'static str { - // `.wjit` is the default extension for all the triples - "wjit" + // `.wuniversal` is the default extension for all the triples + "wuniversal" } } -impl Artifact for JITArtifact { +impl Artifact for UniversalArtifact { fn module(&self) -> Arc { self.serializable.compile_info.module.clone() } diff --git a/lib/engine-jit/src/builder.rs b/lib/engine-universal/src/builder.rs similarity index 71% rename from lib/engine-jit/src/builder.rs rename to lib/engine-universal/src/builder.rs index 254f9d8bf61..0dd9fc0ef87 100644 --- a/lib/engine-jit/src/builder.rs +++ b/lib/engine-universal/src/builder.rs @@ -1,16 +1,16 @@ -use crate::JITEngine; +use crate::UniversalEngine; use wasmer_compiler::{CompilerConfig, Features, Target}; -/// The JIT builder -pub struct JIT { +/// The Universal builder +pub struct Universal { #[allow(dead_code)] compiler_config: Option>, target: Option, features: Option, } -impl JIT { - /// Create a new JIT +impl Universal { + /// Create a new Universal pub fn new(compiler_config: T) -> Self where T: Into>, @@ -22,7 +22,7 @@ impl JIT { } } - /// Create a new headless JIT + /// Create a new headless Universal pub fn headless() -> Self { Self { compiler_config: None, @@ -43,24 +43,24 @@ impl JIT { self } - /// Build the `JITEngine` for this configuration + /// Build the `UniversalEngine` for this configuration #[cfg(feature = "compiler")] - pub fn engine(self) -> JITEngine { + pub fn engine(self) -> UniversalEngine { let target = self.target.unwrap_or_default(); if let Some(compiler_config) = self.compiler_config { let features = self .features .unwrap_or_else(|| compiler_config.default_features_for_target(&target)); let compiler = compiler_config.compiler(); - JITEngine::new(compiler, target, features) + UniversalEngine::new(compiler, target, features) } else { - JITEngine::headless() + UniversalEngine::headless() } } - /// Build the `JITEngine` for this configuration + /// Build the `UniversalEngine` for this configuration #[cfg(not(feature = "compiler"))] - pub fn engine(self) -> JITEngine { - JITEngine::headless() + pub fn engine(self) -> UniversalEngine { + UniversalEngine::headless() } } diff --git a/lib/engine-jit/src/code_memory.rs b/lib/engine-universal/src/code_memory.rs similarity index 100% rename from lib/engine-jit/src/code_memory.rs rename to lib/engine-universal/src/code_memory.rs diff --git a/lib/engine-jit/src/engine.rs b/lib/engine-universal/src/engine.rs similarity index 89% rename from lib/engine-jit/src/engine.rs rename to lib/engine-universal/src/engine.rs index b089bb1ffc1..205f833ce1a 100644 --- a/lib/engine-jit/src/engine.rs +++ b/lib/engine-universal/src/engine.rs @@ -1,6 +1,6 @@ -//! JIT compilation. +//! Universal compilation. -use crate::{CodeMemory, JITArtifact}; +use crate::{CodeMemory, UniversalArtifact}; use loupe::MemoryUsage; use std::sync::{Arc, Mutex}; #[cfg(feature = "compiler")] @@ -17,21 +17,21 @@ use wasmer_vm::{ VMCallerCheckedAnyfunc, VMFuncRef, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline, }; -/// A WebAssembly `JIT` Engine. +/// A WebAssembly `Universal` Engine. #[derive(Clone, MemoryUsage)] -pub struct JITEngine { - inner: Arc>, +pub struct UniversalEngine { + inner: Arc>, /// The target for the compiler target: Arc, engine_id: EngineId, } -impl JITEngine { - /// Create a new `JITEngine` with the given config +impl UniversalEngine { + /// Create a new `UniversalEngine` with the given config #[cfg(feature = "compiler")] pub fn new(compiler: Box, target: Target, features: Features) -> Self { Self { - inner: Arc::new(Mutex::new(JITEngineInner { + inner: Arc::new(Mutex::new(UniversalEngineInner { compiler: Some(compiler), code_memory: vec![], signatures: SignatureRegistry::new(), @@ -43,7 +43,7 @@ impl JITEngine { } } - /// Create a headless `JITEngine` + /// Create a headless `UniversalEngine` /// /// A headless engine is an engine without any compiler attached. /// This is useful for assuring a minimal runtime for running @@ -58,7 +58,7 @@ impl JITEngine { /// they just take already processed Modules (via `Module::serialize`). pub fn headless() -> Self { Self { - inner: Arc::new(Mutex::new(JITEngineInner { + inner: Arc::new(Mutex::new(UniversalEngineInner { #[cfg(feature = "compiler")] compiler: None, code_memory: vec![], @@ -71,16 +71,16 @@ impl JITEngine { } } - pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, JITEngineInner> { + pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, UniversalEngineInner> { self.inner.lock().unwrap() } - pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, JITEngineInner> { + pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, UniversalEngineInner> { self.inner.lock().unwrap() } } -impl Engine for JITEngine { +impl Engine for UniversalEngine { /// The target fn target(&self) -> &Target { &self.target @@ -115,7 +115,7 @@ impl Engine for JITEngine { binary: &[u8], tunables: &dyn Tunables, ) -> Result, CompileError> { - Ok(Arc::new(JITArtifact::new(&self, binary, tunables)?)) + Ok(Arc::new(UniversalArtifact::new(&self, binary, tunables)?)) } /// Compile a WebAssembly binary @@ -126,14 +126,14 @@ impl Engine for JITEngine { _tunables: &dyn Tunables, ) -> Result, CompileError> { Err(CompileError::Codegen( - "The JITEngine is operating in headless mode, so it can not compile Modules." + "The UniversalEngine is operating in headless mode, so it can not compile Modules." .to_string(), )) } /// Deserializes a WebAssembly module unsafe fn deserialize(&self, bytes: &[u8]) -> Result, DeserializeError> { - Ok(Arc::new(JITArtifact::deserialize(&self, &bytes)?)) + Ok(Arc::new(UniversalArtifact::deserialize(&self, &bytes)?)) } fn id(&self) -> &EngineId { @@ -145,9 +145,9 @@ impl Engine for JITEngine { } } -/// The inner contents of `JITEngine` +/// The inner contents of `UniversalEngine` #[derive(MemoryUsage)] -pub struct JITEngineInner { +pub struct UniversalEngineInner { /// The compiler #[cfg(feature = "compiler")] compiler: Option>, @@ -165,12 +165,12 @@ pub struct JITEngineInner { func_data: Arc, } -impl JITEngineInner { +impl UniversalEngineInner { /// Gets the compiler associated to this engine. #[cfg(feature = "compiler")] pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> { if self.compiler.is_none() { - return Err(CompileError::Codegen("The JITEngine is operating in headless mode, so it can only execute already compiled Modules.".to_string())); + return Err(CompileError::Codegen("The UniversalEngine is operating in headless mode, so it can only execute already compiled Modules.".to_string())); } Ok(&**self.compiler.as_ref().unwrap()) } @@ -185,7 +185,7 @@ impl JITEngineInner { #[cfg(not(feature = "compiler"))] pub fn validate<'data>(&self, _data: &'data [u8]) -> Result<(), CompileError> { Err(CompileError::Validate( - "The JITEngine is not compiled with compiler support, which is required for validating" + "The UniversalEngine is not compiled with compiler support, which is required for validating" .to_string(), )) } diff --git a/lib/engine-jit/src/lib.rs b/lib/engine-universal/src/lib.rs similarity index 85% rename from lib/engine-jit/src/lib.rs rename to lib/engine-universal/src/lib.rs index 71ac727f87d..2bbafadd4db 100644 --- a/lib/engine-jit/src/lib.rs +++ b/lib/engine-universal/src/lib.rs @@ -1,4 +1,4 @@ -//! JIT backend for Wasmer compilers. +//! Universal backend for Wasmer compilers. //! //! Given a compiler (such as `CraneliftCompiler` or `LLVMCompiler`) //! it generates the compiled machine code, and publishes it into @@ -32,10 +32,10 @@ mod link; mod serialize; mod unwind; -pub use crate::artifact::JITArtifact; -pub use crate::builder::JIT; +pub use crate::artifact::UniversalArtifact; +pub use crate::builder::Universal; pub use crate::code_memory::CodeMemory; -pub use crate::engine::JITEngine; +pub use crate::engine::UniversalEngine; pub use crate::link::link_module; /// Version number of this crate. diff --git a/lib/engine-jit/src/link.rs b/lib/engine-universal/src/link.rs similarity index 98% rename from lib/engine-jit/src/link.rs rename to lib/engine-universal/src/link.rs index bd1348a0641..94447f88da9 100644 --- a/lib/engine-jit/src/link.rs +++ b/lib/engine-universal/src/link.rs @@ -1,4 +1,4 @@ -//! Linking for JIT-compiled code. +//! Linking for Universal-compiled code. use std::ptr::write_unaligned; use wasmer_compiler::{ diff --git a/lib/engine-jit/src/serialize.rs b/lib/engine-universal/src/serialize.rs similarity index 99% rename from lib/engine-jit/src/serialize.rs rename to lib/engine-universal/src/serialize.rs index 3514bade518..a9694049e66 100644 --- a/lib/engine-jit/src/serialize.rs +++ b/lib/engine-universal/src/serialize.rs @@ -30,7 +30,7 @@ pub struct SerializableCompilation { } /// Serializable struct that is able to serialize from and to -/// a `JITArtifactInfo`. +/// a `UniversalArtifactInfo`. #[derive(MemoryUsage, Archive, RkyvDeserialize, RkyvSerialize)] pub struct SerializableModule { pub compilation: SerializableCompilation, diff --git a/lib/engine-jit/src/unwind/dummy.rs b/lib/engine-universal/src/unwind/dummy.rs similarity index 100% rename from lib/engine-jit/src/unwind/dummy.rs rename to lib/engine-universal/src/unwind/dummy.rs diff --git a/lib/engine-jit/src/unwind/mod.rs b/lib/engine-universal/src/unwind/mod.rs similarity index 100% rename from lib/engine-jit/src/unwind/mod.rs rename to lib/engine-universal/src/unwind/mod.rs diff --git a/lib/engine-jit/src/unwind/systemv.rs b/lib/engine-universal/src/unwind/systemv.rs similarity index 100% rename from lib/engine-jit/src/unwind/systemv.rs rename to lib/engine-universal/src/unwind/systemv.rs diff --git a/lib/engine-jit/src/unwind/windows_x64.rs b/lib/engine-universal/src/unwind/windows_x64.rs similarity index 100% rename from lib/engine-jit/src/unwind/windows_x64.rs rename to lib/engine-universal/src/unwind/windows_x64.rs diff --git a/lib/engine/README.md b/lib/engine/README.md index a67bc8d075b..7d19e75d6f3 100644 --- a/lib/engine/README.md +++ b/lib/engine/README.md @@ -8,9 +8,11 @@ Wasmer Engines are mainly responsible for two things: * **Load** an`Artifact` so it can be used by the user (normally, pushing the code into executable memory and so on). -It currently has two implementations: -1. JIT with [`wasmer-engine-jit`], -2. Native with [`wasmer-engine-native`]. +It currently has three implementations: + +1. Universal with [`wasmer-engine-universal`], +2. Native with [`wasmer-engine-native`], +3. Object with [`wasmer-engine-object-file`]. ## Example Implementation @@ -26,8 +28,9 @@ Please check [Wasmer `ATTRIBUTIONS`] to further see licenses and other attributions of the project. -[`wasmer-engine-jit`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-jit +[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal [`wasmer-engine-native`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-native +[`wasmer-engine-object-file`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-object-file [`wasmer-engine-dummy`]: https://github.com/wasmerio/wasmer/tree/master/tests/lib/engine-dummy [`wasmtime-api`]: https://crates.io/crates/wasmtime [Wasmer `ATTRIBUTIONS`]: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index b321c5c4bc9..fb79e235f57 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -1,4 +1,4 @@ -//! JIT compilation. +//! Engine trait and associated types. use crate::tunables::Tunables; use crate::{Artifact, DeserializeError}; @@ -14,7 +14,7 @@ use wasmer_vm::{VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex}; /// A unimplemented Wasmer `Engine`. /// /// This trait is used by implementors to implement custom engines -/// such as: JIT or Native. +/// such as: Universal or Native. /// /// The product that an `Engine` produces and consumes is the [`Artifact`]. pub trait Engine: MemoryUsage { diff --git a/lib/middlewares/src/metering.rs b/lib/middlewares/src/metering.rs index faea363e073..4856c250d80 100644 --- a/lib/middlewares/src/metering.rs +++ b/lib/middlewares/src/metering.rs @@ -288,7 +288,7 @@ mod tests { use super::*; use std::sync::Arc; - use wasmer::{imports, wat2wasm, CompilerConfig, Cranelift, Module, Store, JIT}; + use wasmer::{imports, wat2wasm, CompilerConfig, Cranelift, Module, Store, Universal}; fn cost_function(operator: &Operator) -> u64 { match operator { @@ -319,7 +319,7 @@ mod tests { let metering = Arc::new(Metering::new(10, cost_function)); let mut compiler_config = Cranelift::default(); compiler_config.push_middleware(metering.clone()); - let store = Store::new(&JIT::new(compiler_config).engine()); + let store = Store::new(&Universal::new(compiler_config).engine()); let module = Module::new(&store, bytecode()).unwrap(); // Instantiate @@ -364,7 +364,7 @@ mod tests { let metering = Arc::new(Metering::new(10, cost_function)); let mut compiler_config = Cranelift::default(); compiler_config.push_middleware(metering.clone()); - let store = Store::new(&JIT::new(compiler_config).engine()); + let store = Store::new(&Universal::new(compiler_config).engine()); let module = Module::new(&store, bytecode()).unwrap(); // Instantiate diff --git a/scripts/publish.py b/scripts/publish.py index 895f358aa93..2831936306a 100644 --- a/scripts/publish.py +++ b/scripts/publish.py @@ -34,20 +34,20 @@ "wasmer-compiler-singlepass": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]), "wasmer-compiler-cranelift": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]), "wasmer-compiler-llvm": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]), - "wasmer-engine-jit": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine"]), + "wasmer-engine-universal": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine"]), "wasmer-engine-native": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine", "wasmer-object"]), "wasmer-engine-object-file": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine", "wasmer-object"]), "wasmer": set(["wasmer-vm", "wasmer-compiler-singlepass", "wasmer-compiler-cranelift", - "wasmer-compiler-llvm", "wasmer-compiler", "wasmer-engine", "wasmer-engine-jit", + "wasmer-compiler-llvm", "wasmer-compiler", "wasmer-engine", "wasmer-engine-universal", "wasmer-engine-native", "wasmer-engine-object-file", "wasmer-types", "wasmer-derive"]), "wasmer-cache": set(["wasmer"]), "wasmer-wasi": set(["wasmer"]), "wasmer-wasi-experimental-io-devices": set(["wasmer-wasi"]), "wasmer-emscripten": set(["wasmer"]), "wasmer-c-api": set(["wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", - "wasmer-compiler-llvm", "wasmer-emscripten", "wasmer-engine", "wasmer-engine-jit", + "wasmer-compiler-llvm", "wasmer-emscripten", "wasmer-engine", "wasmer-engine-universal", "wasmer-engine-native", "wasmer-engine-object-file", "wasmer-wasi", "wasmer-types"]), "wasmer-middlewares": set(["wasmer", "wasmer-types", "wasmer-vm"]), } @@ -65,7 +65,7 @@ "wasmer-compiler-cranelift": "compiler-cranelift", "wasmer-compiler-llvm": "compiler-llvm", "wasmer-engine": "engine", - "wasmer-engine-jit": "engine-jit", + "wasmer-engine-universal": "engine-universal", "wasmer-engine-native": "engine-native", "wasmer-engine-object-file": "engine-object-file", "wasmer-cache": "cache", diff --git a/tests/compilers/config.rs b/tests/compilers/config.rs index 9c5e1a98df5..f3dbe2c0d3d 100644 --- a/tests/compilers/config.rs +++ b/tests/compilers/config.rs @@ -11,7 +11,7 @@ pub enum Compiler { #[derive(Clone, Debug, PartialEq)] pub enum Engine { Native, - JIT, + Universal, } #[derive(Clone)] @@ -69,9 +69,9 @@ impl Config { } Box::new(engine.engine()) } - #[cfg(feature = "jit")] - Engine::JIT => { - let mut engine = wasmer_engine_jit::JIT::new(compiler_config); + #[cfg(feature = "universal")] + Engine::Universal => { + let mut engine = wasmer_engine_universal::Universal::new(compiler_config); if let Some(ref features) = self.features { engine = engine.features(features.clone()) } @@ -89,8 +89,8 @@ impl Config { match &self.engine { #[cfg(feature = "native")] Engine::Native => Box::new(wasmer_engine_native::Native::headless().engine()), - #[cfg(feature = "jit")] - Engine::JIT => Box::new(wasmer_engine_jit::JIT::headless().engine()), + #[cfg(feature = "universal")] + Engine::Universal => Box::new(wasmer_engine_universal::Universal::headless().engine()), #[allow(dead_code)] engine => panic!( "The {:?} Engine is not enabled. Please enable it using the features", diff --git a/tests/ignores.txt b/tests/ignores.txt index 817d7c25855..49f590ae3c7 100644 --- a/tests/ignores.txt +++ b/tests/ignores.txt @@ -36,8 +36,8 @@ singlepass multi_value_imports::native singlepass multi_value_imports::dynamic -# LLVM/JIT doesn't work in macOS M1. Skip all tests -llvm+jit+macos+aarch64 * +# LLVM/Universal doesn't work in macOS M1. Skip all tests +llvm+universal+macos+aarch64 * # TODO: We need to fix this. The issue happens only in Cranelift/LLVM and macOS, # is caused by libunwind overflowing the stack while creating the stacktrace. diff --git a/tests/integration/cli/src/util.rs b/tests/integration/cli/src/util.rs index 30006732798..15cedee4bb4 100644 --- a/tests/integration/cli/src/util.rs +++ b/tests/integration/cli/src/util.rs @@ -21,7 +21,7 @@ impl Compiler { #[derive(Debug, Copy, Clone)] pub enum Engine { - Jit, + Universal, Native, ObjectFile, } @@ -29,7 +29,7 @@ pub enum Engine { impl Engine { pub const fn to_flag(self) -> &'static str { match self { - Engine::Jit => "--jit", + Engine::Universal => "--universal", Engine::Native => "--native", Engine::ObjectFile => "--object-file", } diff --git a/tests/lib/compiler-test-derive/src/ignores.rs b/tests/lib/compiler-test-derive/src/ignores.rs index 94fb3086bfe..c2c0474126a 100644 --- a/tests/lib/compiler-test-derive/src/ignores.rs +++ b/tests/lib/compiler-test-derive/src/ignores.rs @@ -115,7 +115,7 @@ impl Ignores { arch = Some(alias.to_string()); } // Engines - "jit" | "native" => { + "universal" | "native" => { engine = Some(alias.to_string()); } // Compilers @@ -212,7 +212,7 @@ mod tests { os: Some("macos".to_string()), arch: None, target_env: None, - engine: Some("jit".to_string()), + engine: Some("universal".to_string()), compiler: None, pattern_to_ignore: "other".to_string() } @@ -220,7 +220,7 @@ mod tests { "macos", "unknown", "", - "jit", + "universal", "compiler", "some::random::text" )); diff --git a/tests/lib/compiler-test-derive/src/lib.rs b/tests/lib/compiler-test-derive/src/lib.rs index a32b484a823..a30473e6129 100644 --- a/tests/lib/compiler-test-derive/src/lib.rs +++ b/tests/lib/compiler-test-derive/src/lib.rs @@ -110,7 +110,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream { let construct_compiler_test = |func: &::syn::ItemFn, compiler_name: &str| -> ::proc_macro2::TokenStream { let mod_name = ::quote::format_ident!("{}", compiler_name.to_lowercase()); - let jit_engine_test = construct_engine_test(func, compiler_name, "JIT"); + let universal_engine_test = construct_engine_test(func, compiler_name, "Universal"); let native_engine_test = construct_engine_test(func, compiler_name, "Native"); let compiler_name_lowercase = compiler_name.to_lowercase(); @@ -119,7 +119,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream { mod #mod_name { use super::*; - #jit_engine_test + #universal_engine_test #native_engine_test } } diff --git a/tests/lib/compiler-test-derive/src/tests.rs b/tests/lib/compiler-test-derive/src/tests.rs index 2c3eb90ab17..6d16ebe25b2 100644 --- a/tests/lib/compiler-test-derive/src/tests.rs +++ b/tests/lib/compiler-test-derive/src/tests.rs @@ -62,10 +62,10 @@ gen_tests! { use super::*; #[test] #[cold] - #[cfg(feature = "jit")] - fn jit() { + #[cfg(feature = "universal")] + fn universal() { add(crate::Config::new( - crate::Engine::JIT, + crate::Engine::Universal, crate::Compiler::Singlepass )) } @@ -85,10 +85,10 @@ gen_tests! { use super::*; #[test] #[cold] - #[cfg(feature = "jit")] - fn jit() { + #[cfg(feature = "universal")] + fn universal() { add(crate::Config::new( - crate::Engine::JIT, + crate::Engine::Universal, crate::Compiler::Cranelift )) } @@ -108,10 +108,10 @@ gen_tests! { use super::*; #[test] #[cold] - #[cfg(feature = "jit")] - fn jit() { + #[cfg(feature = "universal")] + fn universal() { add(crate::Config::new( - crate::Engine::JIT, + crate::Engine::Universal, crate::Compiler::LLVM )) } @@ -127,10 +127,4 @@ gen_tests! { } } }; - - // basic_expansion: - // stringify! { - // ... - // }; - } diff --git a/tests/lib/test-generator/Cargo.toml b/tests/lib/test-generator/Cargo.toml index f2425545d7e..495f2e7d6e4 100644 --- a/tests/lib/test-generator/Cargo.toml +++ b/tests/lib/test-generator/Cargo.toml @@ -11,4 +11,4 @@ target-lexicon = "0.12" [features] test-native = [] -test-jit = [] +test-universal = [] From 720cae7f791d528f33de065934a8d84eb23472c2 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 25 May 2021 19:25:35 +0200 Subject: [PATCH 2/3] !fixup --- lib/deprecated/runtime-core/Cargo.lock | 77 ++++++++++++-------------- lib/deprecated/runtime-core/src/lib.rs | 13 +++-- 2 files changed, 42 insertions(+), 48 deletions(-) diff --git a/lib/deprecated/runtime-core/Cargo.lock b/lib/deprecated/runtime-core/Cargo.lock index b5aef7dfee1..b9e2af5268f 100644 --- a/lib/deprecated/runtime-core/Cargo.lock +++ b/lib/deprecated/runtime-core/Cargo.lock @@ -124,37 +124,35 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841476ab6d3530136b5162b64a2c6969d68141843ad2fd59126e5ea84fd9b5fe" +checksum = "c8ca3560686e7c9c7ed7e0fe77469f2410ba5d7781b1acaa9adc8d8deea28e3e" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5619cef8d19530298301f91e9a0390d369260799a3d8dd01e28fc88e53637a" +checksum = "baf9bf1ffffb6ce3d2e5ebc83549bd2436426c99b31cc550d521364cbe35d276" dependencies = [ - "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.23.0", + "gimli 0.24.0", "log", "regalloc", "smallvec", "target-lexicon", - "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a319709b8267939155924114ea83f2a5b5af65ece3ac6f703d4735f3c66bb0d" +checksum = "4cc21936a5a6d07e23849ffe83e5c1f6f50305c074f4b2970ca50c13bf55b821" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -162,21 +160,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15925b23cd3a448443f289d85a8f53f3cf7a80f0137aa53c8e3b01ae8aefaef7" +checksum = "ca5b6ffaa87560bebe69a5446449da18090b126037920b0c1c6d5945f72faf6b" [[package]] name = "cranelift-entity" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610cf464396c89af0f9f7c64b5aa90aa9e8812ac84084098f1565b40051bc415" +checksum = "7d6b4a8bef04f82e4296782646f733c641d09497df2fabf791323fefaa44c64c" [[package]] name = "cranelift-frontend" -version = "0.72.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d20c8bd4a1c41ded051734f0e33ad1d843a0adc98b9bd975ee6657e2c70cdc9" +checksum = "c31b783b351f966fce33e3c03498cb116d16d97a8f9978164a60920bd0d3a99c" dependencies = [ "cranelift-codegen", "log", @@ -388,9 +386,9 @@ checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" [[package]] name = "gimli" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" dependencies = [ "fallible-iterator", "indexmap", @@ -644,13 +642,12 @@ checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" [[package]] name = "object" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" dependencies = [ "crc32fast", "indexmap", - "wasmparser 0.57.0", ] [[package]] @@ -1058,9 +1055,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" +checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" [[package]] name = "tempfile" @@ -1182,8 +1179,8 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-universal", "wasmer-engine-native", + "wasmer-engine-universal", "wasmer-types", "wasmer-vm", "wat", @@ -1214,7 +1211,7 @@ dependencies = [ "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser 0.78.0", + "wasmparser", ] [[package]] @@ -1224,7 +1221,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "gimli 0.23.0", + "gimli 0.24.0", "loupe", "more-asserts", "rayon", @@ -1246,7 +1243,7 @@ dependencies = [ "lazy_static", "libc", "loupe", - "object 0.23.0", + "object 0.24.0", "rayon", "regex", "rustc_version", @@ -1305,46 +1302,46 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-universal" +name = "wasmer-engine-native" version = "1.0.2" dependencies = [ "cfg-if 0.1.10", "leb128", + "libloading", "loupe", - "region", "rkyv", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] -name = "wasmer-engine-native" +name = "wasmer-engine-universal" version = "1.0.2" dependencies = [ "cfg-if 0.1.10", "leb128", - "libloading", "loupe", + "region", "rkyv", - "serde", - "tempfile", - "tracing", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] name = "wasmer-object" version = "1.0.2" dependencies = [ - "object 0.23.0", + "object 0.24.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1399,12 +1396,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "wasmparser" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" - [[package]] name = "wasmparser" version = "0.78.0" diff --git a/lib/deprecated/runtime-core/src/lib.rs b/lib/deprecated/runtime-core/src/lib.rs index d30e5ba2fa8..85513d83ab7 100644 --- a/lib/deprecated/runtime-core/src/lib.rs +++ b/lib/deprecated/runtime-core/src/lib.rs @@ -50,7 +50,7 @@ pub(crate) mod new { #[cfg(feature = "singlepass")] pub use wasmer_compiler_singlepass; pub use wasmer_engine; - pub use wasmer_engine_jit; + pub use wasmer_engine_universal; pub use wasmer_types; pub use wasmer_vm; } @@ -115,7 +115,8 @@ impl GlobalStore { } #[allow(unused_variables)] - let update = |engine: new::wasmer_engine_jit::JIT, global_store: &GlobalStore| { + let update = |engine: new::wasmer_engine_universal::Universal, + global_store: &GlobalStore| { let engine = engine.engine(); *self.store.lock().unwrap() = Arc::new(new::wasmer::Store::new(&engine)); }; @@ -123,7 +124,7 @@ impl GlobalStore { match compiler { #[cfg(feature = "singlepass")] Backend::Singlepass => update( - new::wasmer_engine_jit::JIT::new( + new::wasmer_engine_universal::Universal::new( new::wasmer_compiler_singlepass::Singlepass::default(), ), &self, @@ -131,7 +132,7 @@ impl GlobalStore { #[cfg(feature = "cranelift")] Backend::Cranelift => update( - new::wasmer_engine_jit::JIT::new( + new::wasmer_engine_universal::Universal::new( new::wasmer_compiler_cranelift::Cranelift::default(), ), &self, @@ -139,7 +140,9 @@ impl GlobalStore { #[cfg(feature = "llvm")] Backend::LLVM => update( - new::wasmer_engine_jit::JIT::new(new::wasmer_compiler_llvm::LLVM::default()), + new::wasmer_engine_universal::Universal::new( + new::wasmer_compiler_llvm::LLVM::default(), + ), &self, ), From 23e52b7c1d958eb71114b65a905a9a453506389d Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 27 May 2021 13:05:21 +0200 Subject: [PATCH 3/3] !fixup --- lib/c-api/tests/wasm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/c-api/tests/wasm.h b/lib/c-api/tests/wasm.h index 9fe5591cc19..01a546b8041 100644 --- a/lib/c-api/tests/wasm.h +++ b/lib/c-api/tests/wasm.h @@ -31,7 +31,7 @@ wasm_engine_t *wasm_engine_new() { printf("Compiler %s not recognized\n", wasmer_test_compiler); abort(); } - if (strcmp(wasmer_test_engine, "jit") == 0) { + if (strcmp(wasmer_test_engine, "universal") == 0) { assert(wasmer_is_engine_available(UNIVERSAL)); wasm_config_set_engine(config, UNIVERSAL); } else if (strcmp(wasmer_test_engine, "native") == 0) {