mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-22 16:35:33 +00:00
Rename UniversalEngine to Engine
This commit is contained in:
@ -133,8 +133,8 @@ path = "examples/early_exit.rs"
|
||||
required-features = ["cranelift"]
|
||||
|
||||
[[example]]
|
||||
name = "engine-universal"
|
||||
path = "examples/engine_universal.rs"
|
||||
name = "engine"
|
||||
path = "examples/engine.rs"
|
||||
required-features = ["cranelift"]
|
||||
|
||||
[[example]]
|
||||
|
@ -220,18 +220,17 @@ example.
|
||||
|
||||
### Engines
|
||||
|
||||
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.
|
||||
1. [**Engine**][engine], explains what an 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_: Universal, engine, in-memory, executable code.
|
||||
_Keywords_: engine, in-memory, executable code.
|
||||
|
||||
<details>
|
||||
<summary><em>Execute the example</em></summary>
|
||||
|
||||
```shell
|
||||
$ cargo run --example engine-universal --release --features "cranelift"
|
||||
$ cargo run --example engine --release --features "cranelift"
|
||||
```
|
||||
|
||||
</details>
|
||||
@ -358,7 +357,7 @@ example.
|
||||
</details>
|
||||
|
||||
[hello-world]: ./hello_world.rs
|
||||
[engine-universal]: ./engine_universal.rs
|
||||
[engine]: ./engine.rs
|
||||
[engine-headless]: ./engine_headless.rs
|
||||
[compiler-singlepass]: ./compiler_singlepass.rs
|
||||
[compiler-cranelift]: ./compiler_cranelift.rs
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
||||
use wasm_smith::{Config, ConfiguredModule};
|
||||
use wasmer::{CompilerConfig, Module, Store, UniversalEngine};
|
||||
use wasmer::{CompilerConfig, Engine, Module, Store};
|
||||
use wasmer_compiler::Universal;
|
||||
use wasmer_compiler_cranelift::Cranelift;
|
||||
use wasmer_compiler_llvm::LLVM;
|
||||
@ -23,7 +23,7 @@ impl Config for NoImportsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
fn compile_and_compare(name: &str, engine: UniversalEngine, wasm: &[u8]) {
|
||||
fn compile_and_compare(name: &str, engine: Engine, wasm: &[u8]) {
|
||||
let store = Store::new_with_engine(&engine);
|
||||
|
||||
// compile for first time
|
||||
|
@ -93,8 +93,8 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
|
||||
#[cfg(feature = "llvm")]
|
||||
pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
|
||||
|
||||
#[cfg(all(feature = "universal", feature = "compiler"))]
|
||||
pub use wasmer_compiler::{Universal, UniversalArtifact, UniversalEngine};
|
||||
#[cfg(feature = "universal")]
|
||||
pub use wasmer_compiler::{Engine, Universal, UniversalArtifact};
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
@ -4,7 +4,7 @@ use std::sync::{Arc, RwLock};
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::CompilerConfig;
|
||||
#[cfg(feature = "compiler")]
|
||||
use wasmer_compiler::{Tunables, Universal, UniversalEngine};
|
||||
use wasmer_compiler::{Engine, Tunables, Universal};
|
||||
use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn};
|
||||
|
||||
use wasmer_vm::StoreObjects;
|
||||
@ -14,7 +14,7 @@ use wasmer_vm::StoreObjects;
|
||||
/// wrap the actual context in a box.
|
||||
pub(crate) struct StoreInner {
|
||||
pub(crate) objects: StoreObjects,
|
||||
pub(crate) engine: Arc<UniversalEngine>,
|
||||
pub(crate) engine: Arc<Engine>,
|
||||
pub(crate) tunables: Box<dyn Tunables + Send + Sync>,
|
||||
pub(crate) trap_handler: Option<Box<TrapHandlerFn<'static>>>,
|
||||
}
|
||||
@ -31,7 +31,7 @@ pub(crate) struct StoreInner {
|
||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
|
||||
pub struct Store {
|
||||
pub(crate) inner: Box<StoreInner>,
|
||||
engine: Arc<UniversalEngine>,
|
||||
engine: Arc<Engine>,
|
||||
trap_handler: Arc<RwLock<Option<Box<TrapHandlerFn<'static>>>>>,
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ impl Store {
|
||||
}
|
||||
|
||||
/// Creates a new `Store` with a specific [`Engine`].
|
||||
pub fn new_with_engine(engine: &UniversalEngine) -> Self {
|
||||
pub fn new_with_engine(engine: &Engine) -> Self {
|
||||
Self::new_with_tunables(engine, BaseTunables::for_target(engine.target()))
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ impl Store {
|
||||
|
||||
/// Creates a new `Store` with a specific [`Engine`] and [`Tunables`].
|
||||
pub fn new_with_tunables(
|
||||
engine: &UniversalEngine,
|
||||
engine: &Engine,
|
||||
tunables: impl Tunables + Send + Sync + 'static,
|
||||
) -> Self {
|
||||
// Make sure the signal handlers are installed.
|
||||
@ -80,7 +80,7 @@ impl Store {
|
||||
}
|
||||
|
||||
/// Returns the [`Engine`].
|
||||
pub fn engine(&self) -> &Arc<UniversalEngine> {
|
||||
pub fn engine(&self) -> &Arc<Engine> {
|
||||
&self.engine
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ impl Default for Store {
|
||||
}
|
||||
|
||||
#[allow(unreachable_code, unused_mut)]
|
||||
fn get_engine(mut config: impl CompilerConfig + 'static) -> UniversalEngine {
|
||||
fn get_engine(mut config: impl CompilerConfig + 'static) -> Engine {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "default-universal")] {
|
||||
wasmer_compiler::Universal::new(config)
|
||||
@ -198,7 +198,7 @@ impl<'a> StoreRef<'a> {
|
||||
}
|
||||
|
||||
/// Returns the [`Engine`].
|
||||
pub fn engine(&self) -> &Arc<UniversalEngine> {
|
||||
pub fn engine(&self) -> &Arc<Engine> {
|
||||
&self.inner.engine
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ impl<'a> StoreMut<'a> {
|
||||
}
|
||||
|
||||
/// Returns the [`Engine`].
|
||||
pub fn engine(&self) -> &Arc<UniversalEngine> {
|
||||
pub fn engine(&self) -> &Arc<Engine> {
|
||||
&self.inner.engine
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use crate::error::update_last_error;
|
||||
use cfg_if::cfg_if;
|
||||
use std::sync::Arc;
|
||||
#[cfg(feature = "universal")]
|
||||
use wasmer_compiler::{Universal, UniversalEngine};
|
||||
use wasmer_compiler::{Engine, Universal};
|
||||
|
||||
/// Kind of compilers that can be used by the engines.
|
||||
///
|
||||
@ -262,7 +262,7 @@ pub extern "C" fn wasm_config_set_engine(config: &mut wasm_config_t, engine: was
|
||||
/// cbindgen:ignore
|
||||
#[repr(C)]
|
||||
pub struct wasm_engine_t {
|
||||
pub(crate) inner: Arc<UniversalEngine>,
|
||||
pub(crate) inner: Arc<Engine>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "compiler")]
|
||||
@ -295,7 +295,7 @@ cfg_if! {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
|
||||
let engine: Arc<UniversalEngine> = Arc::new(Universal::new(compiler_config).engine());
|
||||
let engine: Arc<Engine> = Arc::new(Universal::new(compiler_config).engine());
|
||||
Box::new(wasm_engine_t { inner: engine })
|
||||
}
|
||||
} else if #[cfg(feature = "universal")] {
|
||||
@ -308,7 +308,7 @@ cfg_if! {
|
||||
/// cbindgen:ignore
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||
let engine: Arc<UniversalEngine> = Arc::new(Universal::headless().engine());
|
||||
let engine: Arc<Engine> = Arc::new(Universal::headless().engine());
|
||||
Box::new(wasm_engine_t { inner: engine })
|
||||
}
|
||||
} else {
|
||||
@ -421,7 +421,7 @@ pub extern "C" fn wasm_engine_new_with_config(
|
||||
#[cfg(not(feature = "universal"))]
|
||||
return return_with_error("Wasmer has not been compiled with the `universal` feature.");
|
||||
#[cfg(feature = "universal")]
|
||||
let inner: Arc<UniversalEngine> =
|
||||
let inner: Arc<Engine> =
|
||||
{
|
||||
let mut builder = Universal::new(compiler_config);
|
||||
|
||||
@ -437,7 +437,7 @@ pub extern "C" fn wasm_engine_new_with_config(
|
||||
};
|
||||
Some(Box::new(wasm_engine_t { inner }))
|
||||
} else {
|
||||
let inner: Arc<UniversalEngine> =
|
||||
let inner: Arc<Engine> =
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "universal")] {
|
||||
let mut builder = Universal::headless();
|
||||
|
@ -7,7 +7,7 @@ use std::string::ToString;
|
||||
#[allow(unused_imports)]
|
||||
use std::sync::Arc;
|
||||
use structopt::StructOpt;
|
||||
use wasmer_compiler::UniversalEngineBuilder;
|
||||
use wasmer_compiler::EngineBuilder;
|
||||
use wasmer_compiler::{CompilerConfig, Features};
|
||||
use wasmer_types::{MemoryStyle, MemoryType, Pages, PointerWidth, TableStyle, TableType, Target};
|
||||
|
||||
@ -172,10 +172,9 @@ impl CompilerOptions {
|
||||
&self,
|
||||
target: Target,
|
||||
compiler_config: Box<dyn CompilerConfig>,
|
||||
) -> Result<UniversalEngineBuilder> {
|
||||
) -> Result<EngineBuilder> {
|
||||
let features = self.get_features(compiler_config.default_features_for_target(&target))?;
|
||||
let engine: UniversalEngineBuilder =
|
||||
UniversalEngineBuilder::new(Some(compiler_config.compiler()), features);
|
||||
let engine: EngineBuilder = EngineBuilder::new(Some(compiler_config.compiler()), features);
|
||||
|
||||
Ok(engine)
|
||||
}
|
||||
@ -358,11 +357,8 @@ impl ToString for CompilerType {
|
||||
}
|
||||
|
||||
impl StoreOptions {
|
||||
/// Get a UniversalEngineBulder for the Target
|
||||
pub fn get_engine_for_target(
|
||||
&self,
|
||||
target: Target,
|
||||
) -> Result<(UniversalEngineBuilder, CompilerType)> {
|
||||
/// Get a EngineBulder for the Target
|
||||
pub fn get_engine_for_target(&self, target: Target) -> Result<(EngineBuilder, CompilerType)> {
|
||||
let (compiler_config, compiler_type) = self.compiler.get_compiler_config()?;
|
||||
let engine = self.get_engine_with_compiler(target, compiler_config)?;
|
||||
Ok((engine, compiler_type))
|
||||
@ -372,7 +368,7 @@ impl StoreOptions {
|
||||
&self,
|
||||
target: Target,
|
||||
compiler_config: Box<dyn CompilerConfig>,
|
||||
) -> Result<UniversalEngineBuilder> {
|
||||
) -> Result<EngineBuilder> {
|
||||
self.compiler.get_engine_by_type(target, compiler_config)
|
||||
}
|
||||
|
||||
|
@ -112,9 +112,9 @@ impl CompilerOptions {
|
||||
&self,
|
||||
target: Target,
|
||||
compiler_config: Box<dyn CompilerConfig>,
|
||||
) -> Result<Box<UniversalEngine>> {
|
||||
) -> Result<Box<Engine>> {
|
||||
let features = self.get_features(compiler_config.default_features_for_target(&target))?;
|
||||
let engine: Box<UniversalEngine> = Box::new(
|
||||
let engine: Box<Engine> = Box::new(
|
||||
wasmer_compiler::Universal::new(compiler_config)
|
||||
.features(features)
|
||||
.target(target)
|
||||
@ -321,7 +321,7 @@ impl StoreOptions {
|
||||
&self,
|
||||
target: Target,
|
||||
compiler_config: Box<dyn CompilerConfig>,
|
||||
) -> Result<Box<UniversalEngine>> {
|
||||
) -> Result<Box<Engine>> {
|
||||
let engine = self.compiler.get_engine(target, compiler_config)?;
|
||||
|
||||
Ok(engine)
|
||||
@ -331,9 +331,8 @@ impl StoreOptions {
|
||||
// If we don't have a compiler, but we have an engine
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
impl StoreOptions {
|
||||
fn get_engine_headless(&self) -> Result<Arc<UniversalEngine>> {
|
||||
let engine: Arc<UniversalEngine> =
|
||||
Arc::new(wasmer_compiler::Universal::headless().engine());
|
||||
fn get_engine_headless(&self) -> Result<Arc<Engine>> {
|
||||
let engine: Arc<Engine> = Arc::new(wasmer_compiler::Universal::headless().engine());
|
||||
Ok(engine)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Define `UniversalArtifact`, based on `UniversalArtifactBuild`
|
||||
//! to allow compiling and instantiating to be done as separate steps.
|
||||
|
||||
use super::engine::{UniversalEngine, UniversalEngineInner};
|
||||
use super::engine::{Engine, EngineInner};
|
||||
use crate::engine::universal::link::link_module;
|
||||
use crate::ArtifactCreate;
|
||||
use crate::Features;
|
||||
@ -39,7 +39,7 @@ impl UniversalArtifact {
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(
|
||||
engine: &UniversalEngine,
|
||||
engine: &Engine,
|
||||
data: &[u8],
|
||||
tunables: &dyn Tunables,
|
||||
) -> Result<Self, CompileError> {
|
||||
@ -71,7 +71,7 @@ impl UniversalArtifact {
|
||||
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn new(_engine: &UniversalEngine, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
pub fn new(_engine: &Engine, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
Err(CompileError::Codegen(
|
||||
"Compilation is not enabled in the engine".to_string(),
|
||||
))
|
||||
@ -82,10 +82,7 @@ impl UniversalArtifact {
|
||||
/// # Safety
|
||||
/// This function is unsafe because rkyv reads directly without validating
|
||||
/// the data.
|
||||
pub unsafe fn deserialize(
|
||||
engine: &UniversalEngine,
|
||||
bytes: &[u8],
|
||||
) -> Result<Self, DeserializeError> {
|
||||
pub unsafe fn deserialize(engine: &Engine, bytes: &[u8]) -> Result<Self, DeserializeError> {
|
||||
if !UniversalArtifactBuild::is_deserializable(bytes) {
|
||||
return Err(DeserializeError::Incompatible(
|
||||
"The provided bytes are not wasmer-universal".to_string(),
|
||||
@ -102,7 +99,7 @@ impl UniversalArtifact {
|
||||
|
||||
/// Construct a `UniversalArtifactBuild` from component parts.
|
||||
pub fn from_parts(
|
||||
engine_inner: &mut UniversalEngineInner,
|
||||
engine_inner: &mut EngineInner,
|
||||
artifact: UniversalArtifactBuild,
|
||||
) -> Result<Self, CompileError> {
|
||||
let module_info = artifact.create_module_info();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::UniversalEngine;
|
||||
use super::Engine;
|
||||
use crate::{CompilerConfig, Features};
|
||||
use wasmer_types::Target;
|
||||
|
||||
@ -44,24 +44,24 @@ impl Universal {
|
||||
self
|
||||
}
|
||||
|
||||
/// Build the `UniversalEngine` for this configuration
|
||||
/// Build the `Engine` for this configuration
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn engine(self) -> UniversalEngine {
|
||||
pub fn engine(self) -> Engine {
|
||||
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();
|
||||
UniversalEngine::new(compiler, target, features)
|
||||
Engine::new(compiler, target, features)
|
||||
} else {
|
||||
UniversalEngine::headless()
|
||||
Engine::headless()
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the `UniversalEngine` for this configuration
|
||||
/// Build the `Engine` for this configuration
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn engine(self) -> UniversalEngine {
|
||||
UniversalEngine::headless()
|
||||
pub fn engine(self) -> Engine {
|
||||
Engine::headless()
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use crate::Compiler;
|
||||
use crate::UniversalEngineBuilder;
|
||||
use crate::EngineBuilder;
|
||||
use crate::{CodeMemory, UniversalArtifact};
|
||||
use crate::{FunctionExtent, Tunables};
|
||||
use memmap2::Mmap;
|
||||
@ -23,20 +23,20 @@ use wasmer_vm::{
|
||||
|
||||
/// A WebAssembly `Universal` Engine.
|
||||
#[derive(Clone)]
|
||||
pub struct UniversalEngine {
|
||||
inner: Arc<Mutex<UniversalEngineInner>>,
|
||||
pub struct Engine {
|
||||
inner: Arc<Mutex<EngineInner>>,
|
||||
/// The target for the compiler
|
||||
target: Arc<Target>,
|
||||
engine_id: EngineId,
|
||||
}
|
||||
|
||||
impl UniversalEngine {
|
||||
/// Create a new `UniversalEngine` with the given config
|
||||
impl Engine {
|
||||
/// Create a new `Engine` with the given config
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
|
||||
Self {
|
||||
inner: Arc::new(Mutex::new(UniversalEngineInner {
|
||||
builder: UniversalEngineBuilder::new(Some(compiler), features),
|
||||
inner: Arc::new(Mutex::new(EngineInner {
|
||||
builder: EngineBuilder::new(Some(compiler), features),
|
||||
code_memory: vec![],
|
||||
signatures: SignatureRegistry::new(),
|
||||
})),
|
||||
@ -45,7 +45,7 @@ impl UniversalEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a headless `UniversalEngine`
|
||||
/// Create a headless `Engine`
|
||||
///
|
||||
/// A headless engine is an engine without any compiler attached.
|
||||
/// This is useful for assuring a minimal runtime for running
|
||||
@ -60,8 +60,8 @@ impl UniversalEngine {
|
||||
/// they just take already processed Modules (via `Module::serialize`).
|
||||
pub fn headless() -> Self {
|
||||
Self {
|
||||
inner: Arc::new(Mutex::new(UniversalEngineInner {
|
||||
builder: UniversalEngineBuilder::new(None, Features::default()),
|
||||
inner: Arc::new(Mutex::new(EngineInner {
|
||||
builder: EngineBuilder::new(None, Features::default()),
|
||||
code_memory: vec![],
|
||||
signatures: SignatureRegistry::new(),
|
||||
})),
|
||||
@ -70,11 +70,11 @@ impl UniversalEngine {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, UniversalEngineInner> {
|
||||
pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, EngineInner> {
|
||||
self.inner.lock().unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, UniversalEngineInner> {
|
||||
pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, EngineInner> {
|
||||
self.inner.lock().unwrap()
|
||||
}
|
||||
|
||||
@ -118,8 +118,7 @@ impl UniversalEngine {
|
||||
_tunables: &dyn Tunables,
|
||||
) -> Result<Arc<UniversalArtifact>, CompileError> {
|
||||
Err(CompileError::Codegen(
|
||||
"The UniversalEngine is operating in headless mode, so it can not compile Modules."
|
||||
.to_string(),
|
||||
"The Engine is operating in headless mode, so it can not compile Modules.".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@ -164,10 +163,10 @@ impl UniversalEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/// The inner contents of `UniversalEngine`
|
||||
pub struct UniversalEngineInner {
|
||||
/// The inner contents of `Engine`
|
||||
pub struct EngineInner {
|
||||
/// The builder (include compiler and cpu features)
|
||||
builder: UniversalEngineBuilder,
|
||||
builder: EngineBuilder,
|
||||
/// The code memory is responsible of publishing the compiled
|
||||
/// functions to memory.
|
||||
code_memory: Vec<CodeMemory>,
|
||||
@ -176,7 +175,7 @@ pub struct UniversalEngineInner {
|
||||
signatures: SignatureRegistry,
|
||||
}
|
||||
|
||||
impl UniversalEngineInner {
|
||||
impl EngineInner {
|
||||
/// Gets the compiler associated to this engine.
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
||||
@ -193,7 +192,7 @@ impl UniversalEngineInner {
|
||||
self.builder.features()
|
||||
}
|
||||
|
||||
pub fn builder_mut(&mut self) -> &mut UniversalEngineBuilder {
|
||||
pub fn builder_mut(&mut self) -> &mut EngineBuilder {
|
||||
&mut self.builder
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,5 @@ 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::engine::Engine;
|
||||
pub use self::link::link_module;
|
||||
|
@ -5,7 +5,7 @@
|
||||
use super::trampoline::{libcall_trampoline_len, make_libcall_trampolines};
|
||||
use crate::Features;
|
||||
use crate::MetadataHeader;
|
||||
use crate::{ArtifactCreate, UniversalEngineBuilder};
|
||||
use crate::{ArtifactCreate, EngineBuilder};
|
||||
#[cfg(feature = "universal_engine")]
|
||||
use crate::{ModuleEnvironment, ModuleMiddlewareChain};
|
||||
use enumset::EnumSet;
|
||||
@ -40,7 +40,7 @@ impl UniversalArtifactBuild {
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(feature = "universal_engine")]
|
||||
pub fn new(
|
||||
inner_engine: &mut UniversalEngineBuilder,
|
||||
inner_engine: &mut EngineBuilder,
|
||||
data: &[u8],
|
||||
target: &Target,
|
||||
memory_styles: PrimaryMap<MemoryIndex, MemoryStyle>,
|
||||
@ -118,7 +118,7 @@ impl UniversalArtifactBuild {
|
||||
|
||||
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(not(feature = "universal_engine"))]
|
||||
pub fn new(_engine: &UniversalEngineBuilder, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
pub fn new(_engine: &EngineBuilder, _data: &[u8]) -> Result<Self, CompileError> {
|
||||
Err(CompileError::Codegen(
|
||||
"Compilation is not enabled in the engine".to_string(),
|
||||
))
|
||||
|
@ -3,15 +3,15 @@
|
||||
use crate::Compiler;
|
||||
use wasmer_types::{CompileError, Features};
|
||||
|
||||
/// The Builder contents of `UniversalEngine`
|
||||
pub struct UniversalEngineBuilder {
|
||||
/// The Builder contents of `Engine`
|
||||
pub struct EngineBuilder {
|
||||
/// The compiler
|
||||
compiler: Option<Box<dyn Compiler>>,
|
||||
/// The features to compile the Wasm module with
|
||||
features: Features,
|
||||
}
|
||||
|
||||
impl UniversalEngineBuilder {
|
||||
impl EngineBuilder {
|
||||
/// Create a new builder with pre-made components
|
||||
pub fn new(compiler: Option<Box<dyn Compiler>>, features: Features) -> Self {
|
||||
Self { compiler, features }
|
||||
@ -21,7 +21,7 @@ impl UniversalEngineBuilder {
|
||||
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
||||
if self.compiler.is_none() {
|
||||
return Err(CompileError::Codegen(
|
||||
"The UniversalEngine is not compiled in.".to_string(),
|
||||
"The Engine is not compiled in.".to_string(),
|
||||
));
|
||||
}
|
||||
Ok(&**self.compiler.as_ref().unwrap())
|
||||
|
@ -5,5 +5,5 @@ mod engine;
|
||||
mod trampoline;
|
||||
|
||||
pub use self::artifact::UniversalArtifactBuild;
|
||||
pub use self::engine::UniversalEngineBuilder;
|
||||
pub use self::engine::EngineBuilder;
|
||||
pub use self::trampoline::*;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
use wasmer::{CompilerConfig, Features, ModuleMiddleware, Store};
|
||||
use wasmer_compiler::UniversalEngine;
|
||||
use wasmer_compiler::Engine;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Compiler {
|
||||
@ -50,7 +50,7 @@ impl Config {
|
||||
Store::new_with_engine(&*engine)
|
||||
}
|
||||
|
||||
pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<UniversalEngine> {
|
||||
pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<Engine> {
|
||||
let mut engine = wasmer_compiler::Universal::new(compiler_config);
|
||||
if let Some(ref features) = self.features {
|
||||
engine = engine.features(features.clone())
|
||||
@ -58,7 +58,7 @@ impl Config {
|
||||
Box::new(engine.engine())
|
||||
}
|
||||
|
||||
pub fn engine_headless(&self) -> Box<UniversalEngine> {
|
||||
pub fn engine_headless(&self) -> Box<Engine> {
|
||||
Box::new(wasmer_compiler::Universal::headless().engine())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user