mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-22 16:35:33 +00:00
Remove wasmer_engine_universal{,_artifact} and merge into wasmer_compiler
This commit is contained in:
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -2794,7 +2794,6 @@ dependencies = [
|
||||
"wasmer-compiler-llvm",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-derive",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"wasmparser 0.83.0",
|
||||
@ -2810,10 +2809,10 @@ dependencies = [
|
||||
"libfuzzer-sys",
|
||||
"wasm-smith",
|
||||
"wasmer",
|
||||
"wasmer-compiler",
|
||||
"wasmer-compiler-cranelift",
|
||||
"wasmer-compiler-llvm",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-middlewares",
|
||||
"wasmprinter",
|
||||
]
|
||||
@ -2839,7 +2838,6 @@ dependencies = [
|
||||
"wasmer-compiler-llvm",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-middlewares",
|
||||
"wasmer-types",
|
||||
"wasmer-wasi",
|
||||
@ -2856,8 +2854,8 @@ dependencies = [
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"wasmer",
|
||||
"wasmer-compiler",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-engine-universal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2882,7 +2880,6 @@ dependencies = [
|
||||
"wasmer-compiler-llvm",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-types",
|
||||
"wasmer-vfs",
|
||||
"wasmer-vm",
|
||||
@ -2896,11 +2893,15 @@ name = "wasmer-compiler"
|
||||
version = "2.3.0"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"cfg-if 1.0.0",
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"hashbrown 0.11.2",
|
||||
"lazy_static",
|
||||
"leb128",
|
||||
"memmap2",
|
||||
"more-asserts",
|
||||
"region",
|
||||
"rkyv",
|
||||
"rustc-demangle",
|
||||
"serde",
|
||||
@ -2911,6 +2912,7 @@ dependencies = [
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"wasmparser 0.83.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2931,7 +2933,6 @@ dependencies = [
|
||||
"wasmer-compiler",
|
||||
"wasmer-compiler-cranelift",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-engine-universal-artifact",
|
||||
"wasmer-types",
|
||||
]
|
||||
|
||||
@ -3019,34 +3020,6 @@ dependencies = [
|
||||
"wasmer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine-universal"
|
||||
version = "2.3.0"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"enumset",
|
||||
"leb128",
|
||||
"region",
|
||||
"rkyv",
|
||||
"wasmer-compiler",
|
||||
"wasmer-engine-universal-artifact",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine-universal-artifact"
|
||||
version = "2.3.0"
|
||||
dependencies = [
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"rkyv",
|
||||
"thiserror",
|
||||
"wasmer-compiler",
|
||||
"wasmer-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-integration-tests-cli"
|
||||
version = "2.3.0"
|
||||
@ -3256,7 +3229,6 @@ dependencies = [
|
||||
"wasmer-compiler-llvm",
|
||||
"wasmer-compiler-singlepass",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-middlewares",
|
||||
"wasmer-types",
|
||||
"wasmer-wasi",
|
||||
|
14
Cargo.toml
14
Cargo.toml
@ -11,12 +11,11 @@ autoexamples = false
|
||||
|
||||
[dependencies]
|
||||
wasmer = { version = "=2.3.0", path = "lib/api", default-features = false }
|
||||
wasmer-compiler = { version = "=2.3.0", path = "lib/compiler" }
|
||||
wasmer-compiler = { version = "=2.3.0", path = "lib/compiler", features = ["universal_engine"] }
|
||||
wasmer-compiler-cranelift = { version = "=2.3.0", path = "lib/compiler-cranelift", optional = true }
|
||||
wasmer-compiler-singlepass = { version = "=2.3.0", path = "lib/compiler-singlepass", optional = true }
|
||||
wasmer-compiler-llvm = { version = "=2.3.0", path = "lib/compiler-llvm", optional = true }
|
||||
wasmer-emscripten = { version = "=2.3.0", path = "lib/emscripten", optional = true }
|
||||
wasmer-engine-universal = { version = "=2.3.0", path = "lib/engine-universal", optional = true }
|
||||
wasmer-wasi = { version = "=2.3.0", path = "lib/wasi", optional = true }
|
||||
wasmer-wast = { version = "=2.3.0", path = "tests/lib/wast", optional = true }
|
||||
wasi-test-generator = { version = "=2.3.0", path = "tests/wasi-wast", optional = true }
|
||||
@ -38,7 +37,6 @@ members = [
|
||||
"lib/compiler-llvm",
|
||||
"lib/derive",
|
||||
"lib/emscripten",
|
||||
"lib/engine-universal",
|
||||
"lib/object",
|
||||
"lib/vfs",
|
||||
"lib/vnet",
|
||||
@ -83,16 +81,14 @@ tracing-subscriber = { version = "0.3", default-features = false, features = ["e
|
||||
default = [
|
||||
"wat",
|
||||
"wast",
|
||||
"universal",
|
||||
"cache",
|
||||
"wasi",
|
||||
"engine",
|
||||
"emscripten",
|
||||
"middlewares",
|
||||
]
|
||||
engine = []
|
||||
universal = [
|
||||
"wasmer-engine-universal",
|
||||
]
|
||||
engine = ["universal"]
|
||||
universal = []
|
||||
cache = ["wasmer-cache"]
|
||||
wast = ["wasmer-wast"]
|
||||
wasi = ["wasmer-wasi"]
|
||||
@ -101,7 +97,6 @@ wat = ["wasmer/wat"]
|
||||
compiler = [
|
||||
"wasmer/compiler",
|
||||
"wasmer-compiler/translator",
|
||||
"wasmer-engine-universal/compiler",
|
||||
]
|
||||
singlepass = [
|
||||
"wasmer-compiler-singlepass",
|
||||
@ -129,7 +124,6 @@ test-llvm = [
|
||||
]
|
||||
|
||||
test-universal = [
|
||||
"universal",
|
||||
"test-generator/test-universal",
|
||||
]
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -11,8 +11,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_llvm::LLVM;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -11,8 +11,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -17,8 +17,8 @@
|
||||
use anyhow::bail;
|
||||
use std::fmt;
|
||||
use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, TypedFunction};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
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)]
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
use std::str::FromStr;
|
||||
use wasmer::{wat2wasm, Module, RuntimeError, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler::{CpuFeature, Target, Triple};
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -51,8 +51,8 @@ use wasmer::Instance;
|
||||
use wasmer::Module;
|
||||
use wasmer::Store;
|
||||
use wasmer::Value;
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// First step, let's compile the Wasm module and serialize it.
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Defining an engine in Wasmer is one of the fundamental steps.
|
||||
//!
|
||||
//! This example illustrates how to use the `wasmer_engine_universal`,
|
||||
//! This example illustrates how to use the `wasmer_compiler`,
|
||||
//! aka the Universal engine. An engine applies roughly 2 steps:
|
||||
//!
|
||||
//! 1. It compiles the Wasm module bytes to executable code, through
|
||||
@ -19,8 +19,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
@ -47,7 +47,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Creating Universal engine...");
|
||||
// Define the engine that will drive everything.
|
||||
//
|
||||
// In this case, the engine is `wasmer_engine_universal` which roughly
|
||||
// In this case, the engine is `wasmer_compiler` which roughly
|
||||
// means that the executable code will live in memory.
|
||||
let engine = Universal::new(compiler_config).engine();
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -18,8 +18,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -16,8 +16,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Mutability, Store, Type, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -12,8 +12,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, WasmPtr};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -11,8 +11,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Features, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -7,8 +7,8 @@
|
||||
//! ```
|
||||
|
||||
use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, TypedFunction};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
// First we create a simple Wasm program to use with Wasmer.
|
||||
|
@ -19,8 +19,8 @@ use wasmer::{
|
||||
imports, wat2wasm, Function, FunctionType, Global, Instance, Memory, Module, Store, Table,
|
||||
Type, Value,
|
||||
};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module.
|
||||
|
@ -18,8 +18,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Function, FunctionType, Instance, Module, Store, Type, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, WasmerEnv};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -16,8 +16,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Global, Instance, Module, Store, Value};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module with the text representation.
|
||||
|
@ -15,8 +15,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Let's declare the Wasm module.
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
use std::mem;
|
||||
use wasmer::{imports, wat2wasm, Bytes, Instance, Module, Pages, Store, TypedFunction};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
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
|
||||
|
@ -19,8 +19,8 @@ use std::sync::Arc;
|
||||
use wasmer::wasmparser::Operator;
|
||||
use wasmer::CompilerConfig;
|
||||
use wasmer::{imports, wat2wasm, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
use wasmer_middlewares::{
|
||||
metering::{get_remaining_points, set_remaining_points, MeteringPoints},
|
||||
Metering,
|
||||
|
@ -1,8 +1,8 @@
|
||||
use wasmer::{
|
||||
imports, wat2wasm, Function, Instance, Module, Store, TableType, Type, TypedFunction, Value,
|
||||
};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
/// A function we'll call through a table.
|
||||
fn host_callback(arg1: i32, arg2: i32) -> i32 {
|
||||
|
@ -7,8 +7,8 @@ use wasmer::{
|
||||
wat2wasm, BaseTunables, Instance, Memory, MemoryType, Module, Pages, Store, TableType, Target,
|
||||
Tunables,
|
||||
};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
/// A custom tunables that allows you to set a memory limit.
|
||||
///
|
||||
|
@ -16,8 +16,8 @@
|
||||
//! Ready?
|
||||
|
||||
use wasmer::{Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
use wasmer_wasi::WasiState;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
use std::io::{Read, Write};
|
||||
use wasmer::{Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
use wasmer_wasi::{Pipe, WasiState};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -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-universal = { path = "../lib/engine-universal", optional = true }
|
||||
wasmer-compiler = { path = "../lib/compiler", optional = true }
|
||||
wasmer-middlewares = { path = "../lib/middlewares" }
|
||||
wasmprinter = "0.2"
|
||||
|
||||
@ -24,7 +24,7 @@ wasmprinter = "0.2"
|
||||
cranelift = [ "wasmer-compiler-cranelift" ]
|
||||
llvm = [ "wasmer-compiler-llvm" ]
|
||||
singlepass = [ "wasmer-compiler-singlepass" ]
|
||||
universal = [ "wasmer-engine-universal" ]
|
||||
universal = [ "wasmer-compiler" ]
|
||||
|
||||
[[bin]]
|
||||
name = "equivalence_universal"
|
||||
|
@ -3,10 +3,10 @@
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{CompilerConfig, Engine, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_compiler_llvm::LLVM;
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
struct NoImportsConfig;
|
||||
|
@ -5,13 +5,13 @@ use anyhow::Result;
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{imports, CompilerConfig, Instance, Module, Store, Val};
|
||||
use wasmer_compiler::Universal;
|
||||
#[cfg(feature = "cranelift")]
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
#[cfg(feature = "llvm")]
|
||||
use wasmer_compiler_llvm::LLVM;
|
||||
#[cfg(feature = "singlepass")]
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
struct ExportedFunctionConfig;
|
||||
|
@ -5,8 +5,8 @@ use std::sync::Arc;
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::wasmparser::Operator;
|
||||
use wasmer::{imports, CompilerConfig, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
use wasmer_middlewares::Metering;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
|
@ -3,8 +3,8 @@
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{imports, CompilerConfig, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
struct NoImportsConfig;
|
||||
|
@ -3,8 +3,8 @@
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{imports, CompilerConfig, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_llvm::LLVM;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
struct NoImportsConfig;
|
||||
|
@ -3,8 +3,8 @@
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{imports, Instance, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||
struct NoImportsConfig;
|
||||
|
@ -41,7 +41,6 @@ target-lexicon = { version = "0.12.2", default-features = false }
|
||||
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "=2.3.0", optional = true }
|
||||
wasmer-compiler-cranelift = { path = "../compiler-cranelift", version = "=2.3.0", optional = true }
|
||||
wasmer-compiler-llvm = { path = "../compiler-llvm", version = "=2.3.0", optional = true }
|
||||
wasmer-engine-universal = { path = "../engine-universal", version = "=2.3.0", optional = true }
|
||||
# - Mandatory dependencies for `sys` on Windows.
|
||||
[target.'cfg(all(not(target_arch = "wasm32"), target_os = "windows"))'.dependencies]
|
||||
winapi = "0.3"
|
||||
@ -89,7 +88,6 @@ sys-default = ["sys", "wat", "default-cranelift", "default-universal"]
|
||||
compiler = [
|
||||
"sys",
|
||||
"wasmer-compiler/translator",
|
||||
"wasmer-engine-universal/compiler",
|
||||
]
|
||||
singlepass = [
|
||||
"compiler",
|
||||
@ -118,15 +116,14 @@ default-compiler = []
|
||||
]
|
||||
# - Engines.
|
||||
engine = ["sys"]
|
||||
universal = [
|
||||
"engine",
|
||||
"wasmer-engine-universal",
|
||||
]
|
||||
universal = [
|
||||
"engine",
|
||||
]
|
||||
default-engine = []
|
||||
default-universal = [
|
||||
"default-engine",
|
||||
"universal",
|
||||
]
|
||||
default-universal = [
|
||||
"default-engine",
|
||||
"universal",
|
||||
]
|
||||
# - Experimental / in-development features
|
||||
experimental-reference-types-extern-ref = [
|
||||
"sys",
|
||||
|
@ -107,7 +107,7 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
|
||||
pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
|
||||
|
||||
#[cfg(feature = "universal")]
|
||||
pub use wasmer_engine_universal::{Universal, UniversalArtifact, UniversalEngine};
|
||||
pub use wasmer_compiler::{Universal, UniversalArtifact, UniversalEngine};
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
@ -119,7 +119,7 @@ impl Default for Store {
|
||||
fn get_engine(mut config: impl CompilerConfig + 'static) -> impl Engine + Send + Sync {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "default-universal")] {
|
||||
wasmer_engine_universal::Universal::new(config)
|
||||
wasmer_compiler::Universal::new(config)
|
||||
.engine()
|
||||
} else {
|
||||
compile_error!("No default engine chosen")
|
||||
|
@ -28,7 +28,6 @@ wasmer-compiler-singlepass = { version = "=2.3.0", path = "../compiler-singlepas
|
||||
wasmer-compiler-llvm = { version = "=2.3.0", path = "../compiler-llvm", optional = true }
|
||||
wasmer-emscripten = { version = "=2.3.0", path = "../emscripten", optional = true }
|
||||
wasmer-compiler = { version = "=2.3.0", path = "../compiler" }
|
||||
wasmer-engine-universal = { version = "=2.3.0", path = "../engine-universal", optional = true }
|
||||
wasmer-middlewares = { version = "=2.3.0", path = "../middlewares", optional = true }
|
||||
wasmer-wasi = { version = "=2.3.0", path = "../wasi", default-features = false, features = ["host-fs", "sys"], optional = true }
|
||||
wasmer-types = { version = "=2.3.0", path = "../types" }
|
||||
@ -60,11 +59,11 @@ middlewares = [
|
||||
"wasmer-middlewares",
|
||||
]
|
||||
universal = [
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-compiler/universal_engine",
|
||||
"compiler",
|
||||
]
|
||||
compiler = [
|
||||
"wasmer-api/compiler",
|
||||
"wasmer-engine-universal/compiler",
|
||||
]
|
||||
singlepass = [
|
||||
"wasmer-compiler-singlepass",
|
||||
|
@ -14,7 +14,7 @@ use cfg_if::cfg_if;
|
||||
use std::sync::Arc;
|
||||
use wasmer_api::Engine;
|
||||
#[cfg(feature = "universal")]
|
||||
use wasmer_engine_universal::Universal;
|
||||
use wasmer_compiler::Universal;
|
||||
|
||||
/// Kind of compilers that can be used by the engines.
|
||||
///
|
||||
|
2
lib/cache/Cargo.toml
vendored
2
lib/cache/Cargo.toml
vendored
@ -21,7 +21,7 @@ criterion = "0.3"
|
||||
tempfile = "3"
|
||||
rand = "0.8.3"
|
||||
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "=2.3.0" }
|
||||
wasmer-engine-universal = { path = "../engine-universal", version = "=2.3.0" }
|
||||
wasmer-compiler = { path = "../compiler", version = "=2.3.0" }
|
||||
|
||||
[features]
|
||||
default = ["wasmer/js-serializable-module", "filesystem"]
|
||||
|
2
lib/cache/benches/bench_filesystem_cache.rs
vendored
2
lib/cache/benches/bench_filesystem_cache.rs
vendored
@ -6,8 +6,8 @@ use tempfile::TempDir;
|
||||
use wasmer::{Module, Store};
|
||||
use wasmer_cache::Cache;
|
||||
use wasmer_cache::{FileSystemCache, Hash};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_engine_universal::Universal;
|
||||
|
||||
fn random_key() -> Hash {
|
||||
Hash::new(rand::thread_rng().gen::<[u8; 32]>())
|
||||
|
@ -18,8 +18,7 @@ path = "src/bin/wasmer_compiler.rs"
|
||||
doc = false
|
||||
|
||||
[dependencies]
|
||||
wasmer-engine-universal-artifact = { version = "=2.3.0", path = "../universal-artifact", features = ["compiler"] }
|
||||
wasmer-compiler = { version = "=2.3.0", path = "../compiler" }
|
||||
wasmer-compiler = { version = "=2.3.0", path = "../compiler", features = ["universal_engine"] }
|
||||
wasmer-types = { version = "=2.3.0", path = "../types" }
|
||||
atty = "0.2"
|
||||
colored = "2.0"
|
||||
|
@ -3,8 +3,8 @@ use crate::warning;
|
||||
use anyhow::{Context, Result};
|
||||
use std::path::{Path, PathBuf};
|
||||
use structopt::StructOpt;
|
||||
use wasmer_compiler::{ArtifactCreate, UniversalArtifactBuild};
|
||||
use wasmer_compiler::{CpuFeature, ModuleEnvironment, Target, Triple};
|
||||
use wasmer_engine_universal_artifact::{ArtifactCreate, UniversalArtifactBuild};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
use wasmer_types::{CompileError, MemoryIndex, MemoryStyle, TableIndex, TableStyle};
|
||||
|
||||
@ -43,9 +43,7 @@ impl Compile {
|
||||
) -> Result<&'static str> {
|
||||
Ok(match engine_type {
|
||||
EngineType::Universal => {
|
||||
wasmer_engine_universal_artifact::UniversalArtifactBuild::get_default_extension(
|
||||
target_triple,
|
||||
)
|
||||
wasmer_compiler::UniversalArtifactBuild::get_default_extension(target_triple)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ use std::string::ToString;
|
||||
#[allow(unused_imports)]
|
||||
use std::sync::Arc;
|
||||
use structopt::StructOpt;
|
||||
use wasmer_compiler::UniversalEngineBuilder;
|
||||
use wasmer_compiler::{CompilerConfig, Features, PointerWidth, Target};
|
||||
use wasmer_engine_universal_artifact::UniversalEngineBuilder;
|
||||
use wasmer_types::{MemoryStyle, MemoryType, Pages, TableStyle, TableType};
|
||||
|
||||
/// Minimul Subset of Tunable parameters for WebAssembly compilation.
|
||||
|
@ -31,7 +31,6 @@ wasmer-compiler-cranelift = { version = "=2.3.0", path = "../compiler-cranelift"
|
||||
wasmer-compiler-singlepass = { version = "=2.3.0", path = "../compiler-singlepass", optional = true }
|
||||
wasmer-compiler-llvm = { version = "=2.3.0", path = "../compiler-llvm", optional = true }
|
||||
wasmer-emscripten = { version = "=2.3.0", path = "../emscripten", optional = true }
|
||||
wasmer-engine-universal = { version = "=2.3.0", path = "../engine-universal", optional = true }
|
||||
wasmer-vm = { version = "=2.3.0", path = "../vm" }
|
||||
wasmer-wasi = { version = "=2.3.0", path = "../wasi", optional = true }
|
||||
wasmer-wasi-experimental-io-devices = { version = "=2.3.0", path = "../wasi-experimental-io-devices", optional = true }
|
||||
@ -69,7 +68,6 @@ default = [
|
||||
]
|
||||
engine = []
|
||||
universal = [
|
||||
"wasmer-engine-universal",
|
||||
"engine",
|
||||
]
|
||||
cache = ["wasmer-cache"]
|
||||
@ -80,7 +78,6 @@ emscripten = ["wasmer-emscripten"]
|
||||
wat = ["wasmer/wat"]
|
||||
compiler = [
|
||||
"wasmer-compiler/translator",
|
||||
"wasmer-engine-universal/compiler",
|
||||
]
|
||||
experimental-io-devices = [
|
||||
"wasmer-wasi-experimental-io-devices",
|
||||
|
@ -41,7 +41,7 @@ impl Compile {
|
||||
Ok(match engine_type {
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => {
|
||||
wasmer_engine_universal::UniversalArtifact::get_default_extension(target_triple)
|
||||
wasmer_compiler::UniversalArtifact::get_default_extension(target_triple)
|
||||
}
|
||||
#[cfg(not(all(feature = "universal")))]
|
||||
_ => bail!("selected engine type is not compiled in"),
|
||||
|
@ -225,8 +225,8 @@ impl Run {
|
||||
let contents = std::fs::read(self.path.clone())?;
|
||||
#[cfg(feature = "universal")]
|
||||
{
|
||||
if wasmer_engine_universal::UniversalArtifact::is_deserializable(&contents) {
|
||||
let engine = wasmer_engine_universal::Universal::headless().engine();
|
||||
if wasmer_compiler::UniversalArtifact::is_deserializable(&contents) {
|
||||
let engine = wasmer_compiler::Universal::headless().engine();
|
||||
let store = Store::new(&engine);
|
||||
let module = unsafe { Module::deserialize_from_file(&store, &self.path)? };
|
||||
return Ok(module);
|
||||
@ -309,7 +309,7 @@ impl Run {
|
||||
let extension = match *engine_type {
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => {
|
||||
wasmer_engine_universal::UniversalArtifact::get_default_extension(&Triple::host())
|
||||
wasmer_compiler::UniversalArtifact::get_default_extension(&Triple::host())
|
||||
.to_string()
|
||||
}
|
||||
// We use the compiler type as the default extension
|
||||
|
@ -129,7 +129,7 @@ impl CompilerOptions {
|
||||
let engine: Box<dyn Engine + Send + Sync> = match engine_type {
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => Box::new(
|
||||
wasmer_engine_universal::Universal::new(compiler_config)
|
||||
wasmer_compiler::Universal::new(compiler_config)
|
||||
.features(features)
|
||||
.target(target)
|
||||
.engine(),
|
||||
@ -392,9 +392,7 @@ impl StoreOptions {
|
||||
let engine_type = self.get_engine()?;
|
||||
let engine: Arc<dyn Engine + Send + Sync> = match engine_type {
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => {
|
||||
Arc::new(wasmer_engine_universal::Universal::headless().engine())
|
||||
}
|
||||
EngineType::Universal => Arc::new(wasmer_compiler::Universal::headless().engine()),
|
||||
#[cfg(not(all(feature = "universal")))]
|
||||
engine => bail!(
|
||||
"The `{}` engine is not included in this binary.",
|
||||
|
@ -28,8 +28,16 @@ memmap2 = "0.5"
|
||||
more-asserts = "0.2"
|
||||
lazy_static = "1.4"
|
||||
|
||||
cfg-if = "1.0"
|
||||
leb128 = "0.2"
|
||||
enum-iterator = "0.7.0"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
wasmer-vm = { path = "../vm", version = "=2.3.0" }
|
||||
region = { version = "3.0" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winnt", "impl-default"] }
|
||||
|
||||
[features]
|
||||
default = ["std", "enable-serde" ]
|
||||
@ -37,6 +45,7 @@ default = ["std", "enable-serde" ]
|
||||
# `CompilerConfig`, as well as the included wasmparser.
|
||||
# Disable this feature if you just want a headless engine.
|
||||
translator = ["wasmparser"]
|
||||
universal_engine = []
|
||||
std = ["wasmer-types/std"]
|
||||
core = ["hashbrown", "wasmer-types/core"]
|
||||
enable-serde = ["serde", "serde_bytes", "wasmer-types/enable-serde"]
|
||||
|
@ -8,6 +8,9 @@ mod resolver;
|
||||
mod trap;
|
||||
mod tunables;
|
||||
|
||||
#[cfg(feature = "translator")]
|
||||
mod universal;
|
||||
|
||||
pub use self::artifact::Artifact;
|
||||
pub use self::error::{InstantiationError, LinkError};
|
||||
pub use self::export::{Export, ExportFunction, ExportFunctionMetadata};
|
||||
@ -15,3 +18,6 @@ pub use self::inner::{Engine, EngineId};
|
||||
pub use self::resolver::resolve_imports;
|
||||
pub use self::trap::*;
|
||||
pub use self::tunables::Tunables;
|
||||
|
||||
#[cfg(feature = "translator")]
|
||||
pub use self::universal::*;
|
||||
|
@ -50,7 +50,7 @@ impl RuntimeError {
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// let trap = wasmer_engine::RuntimeError::new("unexpected error");
|
||||
/// let trap = wasmer_compiler::RuntimeError::new("unexpected error");
|
||||
/// assert_eq!("unexpected error", trap.message());
|
||||
/// ```
|
||||
pub fn new<I: Into<String>>(message: I) -> Self {
|
||||
|
@ -1,20 +1,18 @@
|
||||
//! Define `UniversalArtifact`, based on `UniversalArtifactBuild`
|
||||
//! to allow compiling and instantiating to be done as separate steps.
|
||||
|
||||
use crate::engine::{UniversalEngine, UniversalEngineInner};
|
||||
use crate::link::link_module;
|
||||
use enumset::EnumSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::ModuleEnvironment;
|
||||
use wasmer_compiler::{
|
||||
use super::engine::{UniversalEngine, UniversalEngineInner};
|
||||
use crate::engine::universal::link::link_module;
|
||||
use crate::ArtifactCreate;
|
||||
use crate::{
|
||||
register_frame_info, Artifact, FunctionExtent, GlobalFrameInfoRegistration, MetadataHeader,
|
||||
};
|
||||
use wasmer_compiler::{CpuFeature, Features, Triple};
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::{Engine, Tunables};
|
||||
use wasmer_engine_universal_artifact::ArtifactCreate;
|
||||
use wasmer_engine_universal_artifact::{SerializableModule, UniversalArtifactBuild};
|
||||
use crate::{CpuFeature, Features, Triple};
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use crate::{Engine, ModuleEnvironment, Tunables};
|
||||
use crate::{SerializableModule, UniversalArtifactBuild};
|
||||
use enumset::EnumSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use wasmer_types::entity::{BoxedSlice, PrimaryMap};
|
||||
use wasmer_types::{
|
||||
CompileError, DeserializeError, FunctionIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo,
|
||||
@ -39,7 +37,7 @@ pub struct UniversalArtifact {
|
||||
|
||||
impl UniversalArtifact {
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(
|
||||
engine: &UniversalEngine,
|
||||
data: &[u8],
|
||||
@ -72,7 +70,7 @@ impl UniversalArtifact {
|
||||
}
|
||||
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn new(_engine: &UniversalEngine, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
Err(CompileError::Codegen(
|
||||
"Compilation is not enabled in the engine".to_string(),
|
@ -1,5 +1,5 @@
|
||||
use crate::UniversalEngine;
|
||||
use wasmer_compiler::{CompilerConfig, Features, Target};
|
||||
use super::UniversalEngine;
|
||||
use crate::{CompilerConfig, Features, Target};
|
||||
|
||||
/// The Universal builder
|
||||
pub struct Universal {
|
||||
@ -44,7 +44,7 @@ impl Universal {
|
||||
}
|
||||
|
||||
/// Build the `UniversalEngine` for this configuration
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn engine(self) -> UniversalEngine {
|
||||
let target = self.target.unwrap_or_default();
|
||||
if let Some(compiler_config) = self.compiler_config {
|
||||
@ -59,7 +59,7 @@ impl Universal {
|
||||
}
|
||||
|
||||
/// Build the `UniversalEngine` for this configuration
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn engine(self) -> UniversalEngine {
|
||||
UniversalEngine::headless()
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
||||
|
||||
//! Memory management for executable code.
|
||||
use crate::unwind::UnwindRegistry;
|
||||
use super::unwind::UnwindRegistry;
|
||||
use wasmer_types::{CompiledFunctionUnwindInfo, CustomSection, FunctionBody};
|
||||
use wasmer_vm::{Mmap, VMFunctionBody};
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Universal compilation.
|
||||
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use crate::Compiler;
|
||||
use crate::Target;
|
||||
use crate::UniversalEngineBuilder;
|
||||
use crate::{Artifact, Engine, EngineId, FunctionExtent, Tunables};
|
||||
use crate::{CodeMemory, UniversalArtifact};
|
||||
use std::sync::{Arc, Mutex};
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::Compiler;
|
||||
use wasmer_compiler::Target;
|
||||
use wasmer_compiler::{Artifact, Engine, EngineId, FunctionExtent, Tunables};
|
||||
use wasmer_engine_universal_artifact::UniversalEngineBuilder;
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
use wasmer_types::FunctionBody;
|
||||
use wasmer_types::{
|
||||
@ -30,7 +30,7 @@ pub struct UniversalEngine {
|
||||
|
||||
impl UniversalEngine {
|
||||
/// Create a new `UniversalEngine` with the given config
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
|
||||
Self {
|
||||
inner: Arc::new(Mutex::new(UniversalEngineInner {
|
||||
@ -108,7 +108,7 @@ impl Engine for UniversalEngine {
|
||||
}
|
||||
|
||||
/// Compile a WebAssembly binary
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
fn compile(
|
||||
&self,
|
||||
binary: &[u8],
|
||||
@ -118,7 +118,7 @@ impl Engine for UniversalEngine {
|
||||
}
|
||||
|
||||
/// Compile a WebAssembly binary
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
fn compile(
|
||||
&self,
|
||||
_binary: &[u8],
|
||||
@ -162,7 +162,7 @@ pub struct UniversalEngineInner {
|
||||
|
||||
impl UniversalEngineInner {
|
||||
/// Gets the compiler associated to this engine.
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
||||
self.builder.compiler()
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
//! Linking for Universal-compiled code.
|
||||
|
||||
use crate::get_libcall_trampoline;
|
||||
use crate::FunctionExtent;
|
||||
use std::ptr::{read_unaligned, write_unaligned};
|
||||
use wasmer_compiler::FunctionExtent;
|
||||
use wasmer_engine_universal_artifact::get_libcall_trampoline;
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
use wasmer_types::{LocalFunctionIndex, ModuleInfo};
|
||||
use wasmer_types::{Relocation, RelocationKind, RelocationTarget, Relocations, SectionIndex};
|
18
lib/compiler/src/engine/universal/mod.rs
Normal file
18
lib/compiler/src/engine/universal/mod.rs
Normal file
@ -0,0 +1,18 @@
|
||||
//! Universal backend for Wasmer compilers.
|
||||
//!
|
||||
//! Given a compiler (such as `CraneliftCompiler` or `LLVMCompiler`)
|
||||
//! it generates the compiled machine code, and publishes it into
|
||||
//! memory so it can be used externally.
|
||||
|
||||
mod artifact;
|
||||
mod builder;
|
||||
mod code_memory;
|
||||
mod engine;
|
||||
mod link;
|
||||
mod unwind;
|
||||
|
||||
pub use self::artifact::UniversalArtifact;
|
||||
pub use self::builder::Universal;
|
||||
pub use self::code_memory::CodeMemory;
|
||||
pub use self::engine::UniversalEngine;
|
||||
pub use self::link::link_module;
|
@ -1,13 +1,13 @@
|
||||
use crate::{
|
||||
CompileModuleInfo, CompiledFunctionFrameInfo, CustomSection, Dwarf, FunctionBody, Relocation,
|
||||
SectionIndex,
|
||||
};
|
||||
use crate::{DeserializeError, SerializeError};
|
||||
use rkyv::{
|
||||
archived_value, de::deserializers::SharedDeserializeMap, ser::serializers::AllocSerializer,
|
||||
ser::Serializer as RkyvSerializer, Archive, Deserialize as RkyvDeserialize,
|
||||
Serialize as RkyvSerialize,
|
||||
};
|
||||
use wasmer_compiler::{
|
||||
CompileModuleInfo, CompiledFunctionFrameInfo, CustomSection, Dwarf, FunctionBody, Relocation,
|
||||
SectionIndex,
|
||||
};
|
||||
use wasmer_engine::{DeserializeError, SerializeError};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
use wasmer_types::{FunctionIndex, LocalFunctionIndex, OwnedDataInitializer, SignatureIndex};
|
||||
|
@ -59,6 +59,12 @@ pub use crate::artifact::*;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use crate::engine::*;
|
||||
|
||||
#[cfg(feature = "translator")]
|
||||
mod universal_artifact;
|
||||
|
||||
#[cfg(feature = "translator")]
|
||||
pub use self::universal_artifact::*;
|
||||
|
||||
#[cfg(feature = "translator")]
|
||||
mod compiler;
|
||||
mod target;
|
||||
|
@ -1,26 +1,29 @@
|
||||
//! Define `UniversalArtifactBuild` to allow compiling and instantiating to be
|
||||
//! done as separate steps.
|
||||
|
||||
use crate::serialize::SerializableCompilation;
|
||||
use crate::serialize::SerializableModule;
|
||||
#[cfg(feature = "compiler")]
|
||||
use crate::trampoline::{libcall_trampoline_len, make_libcall_trampolines};
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use super::serialize::SerializableCompilation;
|
||||
use super::serialize::SerializableModule;
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use super::trampoline::{libcall_trampoline_len, make_libcall_trampolines};
|
||||
use crate::MetadataHeader;
|
||||
use crate::{ArtifactCreate, UniversalEngineBuilder};
|
||||
use crate::{CpuFeature, Features, Triple};
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use crate::{ModuleEnvironment, ModuleMiddlewareChain, Target};
|
||||
use enumset::EnumSet;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use wasmer_compiler::MetadataHeader;
|
||||
use wasmer_compiler::{
|
||||
CpuFeature, Features, ModuleEnvironment, ModuleMiddlewareChain, Target, Triple,
|
||||
};
|
||||
use wasmer_types::entity::PrimaryMap;
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use wasmer_types::CompileModuleInfo;
|
||||
use wasmer_types::SerializeError;
|
||||
use wasmer_types::{
|
||||
CompileError, CustomSection, Dwarf, FunctionIndex, LocalFunctionIndex, MemoryIndex,
|
||||
MemoryStyle, ModuleInfo, OwnedDataInitializer, Relocation, SectionIndex, SignatureIndex,
|
||||
TableIndex, TableStyle,
|
||||
};
|
||||
use wasmer_types::{CompileModuleInfo, CompiledFunctionFrameInfo, FunctionBody};
|
||||
use wasmer_types::{CompiledFunctionFrameInfo, FunctionBody};
|
||||
|
||||
/// A compiled wasm module, ready to be instantiated.
|
||||
pub struct UniversalArtifactBuild {
|
||||
@ -37,7 +40,7 @@ impl UniversalArtifactBuild {
|
||||
}
|
||||
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(feature = "compiler")]
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(
|
||||
inner_engine: &mut UniversalEngineBuilder,
|
||||
data: &[u8],
|
||||
@ -116,7 +119,7 @@ impl UniversalArtifactBuild {
|
||||
}
|
||||
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn new(_engine: &UniversalEngineBuilder, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
Err(CompileError::Codegen(
|
||||
"Compilation is not enabled in the engine".to_string(),
|
@ -1,13 +1,11 @@
|
||||
//! Universal compilation.
|
||||
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::Compiler;
|
||||
use crate::Compiler;
|
||||
use wasmer_types::{CompileError, Features};
|
||||
|
||||
/// The Builder contents of `UniversalEngine`
|
||||
pub struct UniversalEngineBuilder {
|
||||
/// The compiler
|
||||
#[cfg(feature = "compiler")]
|
||||
compiler: Option<Box<dyn Compiler>>,
|
||||
/// The features to compile the Wasm module with
|
||||
features: Features,
|
||||
@ -15,13 +13,11 @@ pub struct UniversalEngineBuilder {
|
||||
|
||||
impl UniversalEngineBuilder {
|
||||
/// Create a new builder with pre-made components
|
||||
#[cfg(feature = "compiler")]
|
||||
pub fn new(compiler: Option<Box<dyn Compiler>>, features: Features) -> Self {
|
||||
Self { compiler, features }
|
||||
}
|
||||
|
||||
/// 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(
|
||||
@ -31,29 +27,11 @@ impl UniversalEngineBuilder {
|
||||
Ok(&**self.compiler.as_ref().unwrap())
|
||||
}
|
||||
|
||||
/// Gets the compiler associated to this engine.
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
||||
return Err(CompileError::Codegen(
|
||||
"The UniversalEngine is not compiled in.".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
/// Validate the module
|
||||
#[cfg(feature = "compiler")]
|
||||
pub fn validate(&self, data: &[u8]) -> Result<(), CompileError> {
|
||||
self.compiler()?.validate_module(self.features(), data)
|
||||
}
|
||||
|
||||
/// Validate the module
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
pub fn validate<'data>(&self, _data: &'data [u8]) -> Result<(), CompileError> {
|
||||
Err(CompileError::Validate(
|
||||
"The UniversalEngine is not compiled with compiler support, which is required for validating"
|
||||
.to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
/// The Wasm features
|
||||
pub fn features(&self) -> &Features {
|
||||
&self.features
|
11
lib/compiler/src/universal_artifact/mod.rs
Normal file
11
lib/compiler/src/universal_artifact/mod.rs
Normal file
@ -0,0 +1,11 @@
|
||||
//! Generic Artifact abstraction for Wasmer Engines.
|
||||
|
||||
mod artifact;
|
||||
mod engine;
|
||||
mod serialize;
|
||||
mod trampoline;
|
||||
|
||||
pub use self::artifact::UniversalArtifactBuild;
|
||||
pub use self::engine::UniversalEngineBuilder;
|
||||
pub use self::serialize::SerializableModule;
|
||||
pub use self::trampoline::*;
|
@ -3,8 +3,8 @@
|
||||
//! This is needed because the target of libcall relocations are not reachable
|
||||
//! through normal branch instructions.
|
||||
|
||||
use crate::{Architecture, Target};
|
||||
use enum_iterator::IntoEnumIterator;
|
||||
use wasmer_compiler::{Architecture, Target};
|
||||
use wasmer_types::{
|
||||
CustomSection, CustomSectionProtection, LibCall, Relocation, RelocationKind, RelocationTarget,
|
||||
SectionBody,
|
@ -1,40 +0,0 @@
|
||||
[package]
|
||||
name = "wasmer-engine-universal"
|
||||
version = "2.3.0"
|
||||
description = "Wasmer Universal Engine"
|
||||
categories = ["wasm"]
|
||||
keywords = ["wasm", "webassembly", "engine", "universal"]
|
||||
authors = ["Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
license = "MIT OR Apache-2.0 WITH LLVM-exception "
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-engine-universal-artifact = { path = "../universal-artifact", version = "=2.3.0", features = [
|
||||
"compiler",
|
||||
] }
|
||||
wasmer-types = { path = "../types", version = "=2.3.0" }
|
||||
wasmer-compiler = { path = "../compiler", version = "=2.3.0", features = [
|
||||
"translator",
|
||||
] }
|
||||
wasmer-vm = { path = "../vm", version = "=2.3.0" }
|
||||
# flexbuffers = { path = "../../../flatbuffers/rust/flexbuffers", version = "0.1.0" }
|
||||
cfg-if = "1.0"
|
||||
leb128 = "0.2"
|
||||
rkyv = { version = "0.7.38", features = ["indexmap"] }
|
||||
enumset = "1.0"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
region = { version = "3.0" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winnt", "impl-default"] }
|
||||
|
||||
[features]
|
||||
# Enable the `compiler` feature if you want the engine to compile
|
||||
# and not be only on headless mode.
|
||||
compiler = ["wasmer-compiler/translator"]
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
@ -1,25 +0,0 @@
|
||||
# `wasmer-engine-universal` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE)
|
||||
|
||||
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 Universal engine
|
||||
here][example].*
|
||||
|
||||
### Acknowledgments
|
||||
|
||||
This project borrowed some of the code of the code memory and unwind
|
||||
tables from the [`wasmtime-jit`], the code since then has evolved
|
||||
significantly.
|
||||
|
||||
Please check [Wasmer `ATTRIBUTIONS`] to further see licenses and other
|
||||
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_universal.rs
|
||||
[`wasmtime-jit`]: https://crates.io/crates/wasmtime-jit
|
||||
[Wasmer `ATTRIBUTIONS`]: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
@ -1,40 +0,0 @@
|
||||
//! Universal backend for Wasmer compilers.
|
||||
//!
|
||||
//! Given a compiler (such as `CraneliftCompiler` or `LLVMCompiler`)
|
||||
//! it generates the compiled machine code, and publishes it into
|
||||
//! memory so it can be used externally.
|
||||
|
||||
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
||||
#![warn(unused_import_braces)]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(clippy::new_without_default, clippy::new_without_default)
|
||||
)]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
warn(
|
||||
clippy::float_arithmetic,
|
||||
clippy::mut_mut,
|
||||
clippy::nonminimal_bool,
|
||||
clippy::map_unwrap_or,
|
||||
clippy::print_stdout,
|
||||
clippy::unicode_not_nfc,
|
||||
clippy::use_self
|
||||
)
|
||||
)]
|
||||
|
||||
mod artifact;
|
||||
mod builder;
|
||||
mod code_memory;
|
||||
mod engine;
|
||||
mod link;
|
||||
mod unwind;
|
||||
|
||||
pub use crate::artifact::UniversalArtifact;
|
||||
pub use crate::builder::Universal;
|
||||
pub use crate::code_memory::CodeMemory;
|
||||
pub use crate::engine::UniversalEngine;
|
||||
pub use crate::link::link_module;
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
@ -1,25 +0,0 @@
|
||||
[package]
|
||||
name = "wasmer-engine-universal-artifact"
|
||||
version = "2.3.0"
|
||||
description = "Wasmer Engine Universal Artifact abstraction"
|
||||
categories = ["wasm"]
|
||||
keywords = ["wasm", "webassembly", "engine"]
|
||||
authors = ["Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
license = "MIT OR Apache-2.0 WITH LLVM-exception "
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-types = { path = "../types", version = "=2.3.0" }
|
||||
wasmer-compiler = { path = "../compiler", version = "=2.3.0", features = ["translator", ] }
|
||||
thiserror = "1.0"
|
||||
enumset = "1.0"
|
||||
rkyv = "0.7.20"
|
||||
enum-iterator = "0.7.0"
|
||||
|
||||
[features]
|
||||
compiler = []
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
@ -1,18 +0,0 @@
|
||||
# `wasmer-engine-universal-artifact` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE)
|
||||
|
||||
|
||||
This crate is the general abstraction for generating Artifacts in Wasmer.
|
||||
|
||||
### Acknowledgments
|
||||
|
||||
This project borrowed some of the code of the trap implementation from
|
||||
the [`wasmtime-api`], the code since then has evolved significantly.
|
||||
|
||||
Please check [Wasmer `ATTRIBUTIONS`] to further see licenses and other
|
||||
attributions of the project.
|
||||
|
||||
|
||||
[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal
|
||||
[`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
|
@ -1,34 +0,0 @@
|
||||
//! Generic Artifact abstraction for Wasmer Engines.
|
||||
|
||||
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
||||
#![warn(unused_import_braces)]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(clippy::new_without_default, clippy::new_without_default)
|
||||
)]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
warn(
|
||||
clippy::float_arithmetic,
|
||||
clippy::mut_mut,
|
||||
clippy::nonminimal_bool,
|
||||
clippy::map_unwrap_or,
|
||||
clippy::print_stdout,
|
||||
clippy::unicode_not_nfc,
|
||||
clippy::use_self
|
||||
)
|
||||
)]
|
||||
|
||||
mod artifact;
|
||||
mod engine;
|
||||
mod serialize;
|
||||
mod trampoline;
|
||||
|
||||
pub use crate::artifact::UniversalArtifactBuild;
|
||||
pub use crate::engine::UniversalEngineBuilder;
|
||||
pub use crate::serialize::SerializableModule;
|
||||
pub use crate::trampoline::*;
|
||||
pub use wasmer_compiler::{ArtifactCreate, MetadataHeader, Upcastable};
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
@ -60,7 +60,7 @@ impl Config {
|
||||
match &self.engine {
|
||||
#[cfg(feature = "universal")]
|
||||
Engine::Universal => {
|
||||
let mut engine = wasmer_engine_universal::Universal::new(compiler_config);
|
||||
let mut engine = wasmer_compiler::Universal::new(compiler_config);
|
||||
if let Some(ref features) = self.features {
|
||||
engine = engine.features(features.clone())
|
||||
}
|
||||
@ -77,7 +77,7 @@ impl Config {
|
||||
pub fn engine_headless(&self) -> Box<dyn WasmerEngine> {
|
||||
match &self.engine {
|
||||
#[cfg(feature = "universal")]
|
||||
Engine::Universal => Box::new(wasmer_engine_universal::Universal::headless().engine()),
|
||||
Engine::Universal => Box::new(wasmer_compiler::Universal::headless().engine()),
|
||||
#[allow(unreachable_patterns)]
|
||||
engine => panic!(
|
||||
"The {:?} Engine is not enabled. Please enable it using the features",
|
||||
|
Reference in New Issue
Block a user