Skip to content

Commit 9147f76

Browse files
committed
Rename UniversalEngine to Engine
1 parent e463f92 commit 9147f76

File tree

17 files changed

+80
-90
lines changed

17 files changed

+80
-90
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ path = "examples/early_exit.rs"
132132
required-features = ["cranelift"]
133133

134134
[[example]]
135-
name = "engine-universal"
136-
path = "examples/engine_universal.rs"
135+
name = "engine"
136+
path = "examples/engine.rs"
137137
required-features = ["cranelift"]
138138

139139
[[example]]

examples/README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,17 @@ example.
220220

221221
### Engines
222222

223-
1. [**Universal engine**][engine-universal], explains what an engine is, what the
224-
Universal engine is, and how to set it up. The example completes itself
225-
with the compilation of the Wasm module, its instantiation, and
226-
finally, by calling an exported function.
223+
1. [**Engine**][engine], explains what an engine is and how to set it up. The
224+
example completes itself with the compilation of the Wasm module, its
225+
instantiation, and finally, by calling an exported function.
227226

228-
_Keywords_: Universal, engine, in-memory, executable code.
227+
_Keywords_: engine, in-memory, executable code.
229228

230229
<details>
231230
<summary><em>Execute the example</em></summary>
232231

233232
```shell
234-
$ cargo run --example engine-universal --release --features "cranelift"
233+
$ cargo run --example engine --release --features "cranelift"
235234
```
236235

237236
</details>
@@ -358,7 +357,7 @@ example.
358357
</details>
359358
360359
[hello-world]: ./hello_world.rs
361-
[engine-universal]: ./engine_universal.rs
360+
[engine]: ./engine.rs
362361
[engine-headless]: ./engine_headless.rs
363362
[compiler-singlepass]: ./compiler_singlepass.rs
364363
[compiler-cranelift]: ./compiler_cranelift.rs
File renamed without changes.

fuzz/fuzz_targets/deterministic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
44
use wasm_smith::{Config, ConfiguredModule};
5-
use wasmer::{CompilerConfig, Module, Store, UniversalEngine};
5+
use wasmer::{CompilerConfig, Engine, Module, Store};
66
use wasmer_compiler::Universal;
77
use wasmer_compiler_cranelift::Cranelift;
88
use wasmer_compiler_llvm::LLVM;
@@ -23,7 +23,7 @@ impl Config for NoImportsConfig {
2323
}
2424
}
2525

26-
fn compile_and_compare(name: &str, engine: UniversalEngine, wasm: &[u8]) {
26+
fn compile_and_compare(name: &str, engine: Engine, wasm: &[u8]) {
2727
let store = Store::new_with_engine(&engine);
2828

2929
// compile for first time

lib/api/src/sys/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
9494
pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
9595

9696
#[cfg(feature = "universal")]
97-
pub use wasmer_compiler::{Universal, UniversalArtifact, UniversalEngine};
97+
pub use wasmer_compiler::{Engine, Universal, UniversalArtifact};
9898

9999
/// Version number of this crate.
100100
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

lib/api/src/sys/store.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::sys::tunables::BaseTunables;
22
use std::fmt;
33
use std::sync::{Arc, RwLock};
44
use wasmer_compiler::CompilerConfig;
5-
use wasmer_compiler::{Tunables, Universal, UniversalEngine};
5+
use wasmer_compiler::{Engine, Tunables, Universal};
66
use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn};
77

88
use wasmer_vm::StoreObjects;
@@ -12,7 +12,7 @@ use wasmer_vm::StoreObjects;
1212
/// wrap the actual context in a box.
1313
pub(crate) struct StoreInner {
1414
pub(crate) objects: StoreObjects,
15-
pub(crate) engine: Arc<UniversalEngine>,
15+
pub(crate) engine: Arc<Engine>,
1616
pub(crate) tunables: Box<dyn Tunables + Send + Sync>,
1717
pub(crate) trap_handler: Option<Box<TrapHandlerFn<'static>>>,
1818
}
@@ -29,7 +29,7 @@ pub(crate) struct StoreInner {
2929
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
3030
pub struct Store {
3131
pub(crate) inner: Box<StoreInner>,
32-
engine: Arc<UniversalEngine>,
32+
engine: Arc<Engine>,
3333
trap_handler: Arc<RwLock<Option<Box<TrapHandlerFn<'static>>>>>,
3434
}
3535

@@ -41,7 +41,7 @@ impl Store {
4141
}
4242

4343
/// Creates a new `Store` with a specific [`Engine`].
44-
pub fn new_with_engine(engine: &UniversalEngine) -> Self {
44+
pub fn new_with_engine(engine: &Engine) -> Self {
4545
Self::new_with_tunables(engine, BaseTunables::for_target(engine.target()))
4646
}
4747

@@ -52,7 +52,7 @@ impl Store {
5252

5353
/// Creates a new `Store` with a specific [`Engine`] and [`Tunables`].
5454
pub fn new_with_tunables(
55-
engine: &UniversalEngine,
55+
engine: &Engine,
5656
tunables: impl Tunables + Send + Sync + 'static,
5757
) -> Self {
5858
// Make sure the signal handlers are installed.
@@ -77,7 +77,7 @@ impl Store {
7777
}
7878

7979
/// Returns the [`Engine`].
80-
pub fn engine(&self) -> &Arc<UniversalEngine> {
80+
pub fn engine(&self) -> &Arc<Engine> {
8181
&self.engine
8282
}
8383

@@ -139,7 +139,7 @@ impl Default for Store {
139139
}
140140

141141
#[allow(unreachable_code, unused_mut)]
142-
fn get_engine(mut config: impl CompilerConfig + 'static) -> UniversalEngine {
142+
fn get_engine(mut config: impl CompilerConfig + 'static) -> Engine {
143143
cfg_if::cfg_if! {
144144
if #[cfg(feature = "default-universal")] {
145145
wasmer_compiler::Universal::new(config)
@@ -195,7 +195,7 @@ impl<'a> StoreRef<'a> {
195195
}
196196

197197
/// Returns the [`Engine`].
198-
pub fn engine(&self) -> &Arc<UniversalEngine> {
198+
pub fn engine(&self) -> &Arc<Engine> {
199199
&self.inner.engine
200200
}
201201

@@ -228,7 +228,7 @@ impl<'a> StoreMut<'a> {
228228
}
229229

230230
/// Returns the [`Engine`].
231-
pub fn engine(&self) -> &Arc<UniversalEngine> {
231+
pub fn engine(&self) -> &Arc<Engine> {
232232
&self.inner.engine
233233
}
234234

lib/c-api/src/wasm_c_api/engine.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::error::update_last_error;
1313
use cfg_if::cfg_if;
1414
use std::sync::Arc;
1515
#[cfg(feature = "universal")]
16-
use wasmer_compiler::{Universal, UniversalEngine};
16+
use wasmer_compiler::{Engine, Universal};
1717

1818
/// Kind of compilers that can be used by the engines.
1919
///
@@ -262,7 +262,7 @@ pub extern "C" fn wasm_config_set_engine(config: &mut wasm_config_t, engine: was
262262
/// cbindgen:ignore
263263
#[repr(C)]
264264
pub struct wasm_engine_t {
265-
pub(crate) inner: Arc<UniversalEngine>,
265+
pub(crate) inner: Arc<Engine>,
266266
}
267267

268268
#[cfg(feature = "compiler")]
@@ -295,7 +295,7 @@ cfg_if! {
295295
#[no_mangle]
296296
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
297297
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
298-
let engine: Arc<UniversalEngine> = Arc::new(Universal::new(compiler_config).engine());
298+
let engine: Arc<Engine> = Arc::new(Universal::new(compiler_config).engine());
299299
Box::new(wasm_engine_t { inner: engine })
300300
}
301301
} else if #[cfg(feature = "universal")] {
@@ -308,7 +308,7 @@ cfg_if! {
308308
/// cbindgen:ignore
309309
#[no_mangle]
310310
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
311-
let engine: Arc<UniversalEngine> = Arc::new(Universal::headless().engine());
311+
let engine: Arc<Engine> = Arc::new(Universal::headless().engine());
312312
Box::new(wasm_engine_t { inner: engine })
313313
}
314314
} else {
@@ -421,7 +421,7 @@ pub extern "C" fn wasm_engine_new_with_config(
421421
#[cfg(not(feature = "universal"))]
422422
return return_with_error("Wasmer has not been compiled with the `universal` feature.");
423423
#[cfg(feature = "universal")]
424-
let inner: Arc<UniversalEngine> =
424+
let inner: Arc<Engine> =
425425
{
426426
let mut builder = Universal::new(compiler_config);
427427

@@ -437,7 +437,7 @@ pub extern "C" fn wasm_engine_new_with_config(
437437
};
438438
Some(Box::new(wasm_engine_t { inner }))
439439
} else {
440-
let inner: Arc<UniversalEngine> =
440+
let inner: Arc<Engine> =
441441
cfg_if! {
442442
if #[cfg(feature = "universal")] {
443443
let mut builder = Universal::headless();

lib/cli-compiler/src/store.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::string::ToString;
77
#[allow(unused_imports)]
88
use std::sync::Arc;
99
use structopt::StructOpt;
10-
use wasmer_compiler::UniversalEngineBuilder;
10+
use wasmer_compiler::EngineBuilder;
1111
use wasmer_compiler::{CompilerConfig, Features};
1212
use wasmer_types::{MemoryStyle, MemoryType, Pages, PointerWidth, TableStyle, TableType, Target};
1313

@@ -172,10 +172,9 @@ impl CompilerOptions {
172172
&self,
173173
target: Target,
174174
compiler_config: Box<dyn CompilerConfig>,
175-
) -> Result<UniversalEngineBuilder> {
175+
) -> Result<EngineBuilder> {
176176
let features = self.get_features(compiler_config.default_features_for_target(&target))?;
177-
let engine: UniversalEngineBuilder =
178-
UniversalEngineBuilder::new(Some(compiler_config.compiler()), features);
177+
let engine: EngineBuilder = EngineBuilder::new(Some(compiler_config.compiler()), features);
179178

180179
Ok(engine)
181180
}
@@ -358,11 +357,8 @@ impl ToString for CompilerType {
358357
}
359358

360359
impl StoreOptions {
361-
/// Get a UniversalEngineBulder for the Target
362-
pub fn get_engine_for_target(
363-
&self,
364-
target: Target,
365-
) -> Result<(UniversalEngineBuilder, CompilerType)> {
360+
/// Get a EngineBulder for the Target
361+
pub fn get_engine_for_target(&self, target: Target) -> Result<(EngineBuilder, CompilerType)> {
366362
let (compiler_config, compiler_type) = self.compiler.get_compiler_config()?;
367363
let engine = self.get_engine_with_compiler(target, compiler_config)?;
368364
Ok((engine, compiler_type))
@@ -372,7 +368,7 @@ impl StoreOptions {
372368
&self,
373369
target: Target,
374370
compiler_config: Box<dyn CompilerConfig>,
375-
) -> Result<UniversalEngineBuilder> {
371+
) -> Result<EngineBuilder> {
376372
self.compiler.get_engine_by_type(target, compiler_config)
377373
}
378374

lib/cli/src/store.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ impl CompilerOptions {
112112
&self,
113113
target: Target,
114114
compiler_config: Box<dyn CompilerConfig>,
115-
) -> Result<Box<UniversalEngine>> {
115+
) -> Result<Box<Engine>> {
116116
let features = self.get_features(compiler_config.default_features_for_target(&target))?;
117-
let engine: Box<UniversalEngine> = Box::new(
117+
let engine: Box<Engine> = Box::new(
118118
wasmer_compiler::Universal::new(compiler_config)
119119
.features(features)
120120
.target(target)
@@ -321,7 +321,7 @@ impl StoreOptions {
321321
&self,
322322
target: Target,
323323
compiler_config: Box<dyn CompilerConfig>,
324-
) -> Result<Box<UniversalEngine>> {
324+
) -> Result<Box<Engine>> {
325325
let engine = self.compiler.get_engine(target, compiler_config)?;
326326

327327
Ok(engine)
@@ -331,9 +331,8 @@ impl StoreOptions {
331331
// If we don't have a compiler, but we have an engine
332332
#[cfg(not(feature = "compiler"))]
333333
impl StoreOptions {
334-
fn get_engine_headless(&self) -> Result<Arc<UniversalEngine>> {
335-
let engine: Arc<UniversalEngine> =
336-
Arc::new(wasmer_compiler::Universal::headless().engine());
334+
fn get_engine_headless(&self) -> Result<Arc<Engine>> {
335+
let engine: Arc<Engine> = Arc::new(wasmer_compiler::Universal::headless().engine());
337336
Ok(engine)
338337
}
339338

lib/compiler/src/engine/universal/artifact.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Define `UniversalArtifact`, based on `UniversalArtifactBuild`
22
//! to allow compiling and instantiating to be done as separate steps.
33
4-
use super::engine::{UniversalEngine, UniversalEngineInner};
4+
use super::engine::{Engine, EngineInner};
55
use crate::engine::universal::link::link_module;
66
use crate::ArtifactCreate;
77
use crate::Features;
@@ -39,7 +39,7 @@ impl UniversalArtifact {
3939
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
4040
#[cfg(feature = "universal_engine")]
4141
pub fn new(
42-
engine: &UniversalEngine,
42+
engine: &Engine,
4343
data: &[u8],
4444
tunables: &dyn Tunables,
4545
) -> Result<Self, CompileError> {
@@ -71,7 +71,7 @@ impl UniversalArtifact {
7171

7272
/// Compile a data buffer into a `UniversalArtifactBuild`, which may then be instantiated.
7373
#[cfg(not(feature = "universal_engine"))]
74-
pub fn new(_engine: &UniversalEngine, _data: &[u8]) -> Result<Self, CompileError> {
74+
pub fn new(_engine: &Engine, _data: &[u8]) -> Result<Self, CompileError> {
7575
Err(CompileError::Codegen(
7676
"Compilation is not enabled in the engine".to_string(),
7777
))
@@ -82,10 +82,7 @@ impl UniversalArtifact {
8282
/// # Safety
8383
/// This function is unsafe because rkyv reads directly without validating
8484
/// the data.
85-
pub unsafe fn deserialize(
86-
engine: &UniversalEngine,
87-
bytes: &[u8],
88-
) -> Result<Self, DeserializeError> {
85+
pub unsafe fn deserialize(engine: &Engine, bytes: &[u8]) -> Result<Self, DeserializeError> {
8986
if !UniversalArtifactBuild::is_deserializable(bytes) {
9087
return Err(DeserializeError::Incompatible(
9188
"The provided bytes are not wasmer-universal".to_string(),
@@ -102,7 +99,7 @@ impl UniversalArtifact {
10299

103100
/// Construct a `UniversalArtifactBuild` from component parts.
104101
pub fn from_parts(
105-
engine_inner: &mut UniversalEngineInner,
102+
engine_inner: &mut EngineInner,
106103
artifact: UniversalArtifactBuild,
107104
) -> Result<Self, CompileError> {
108105
let module_info = artifact.create_module_info();

lib/compiler/src/engine/universal/builder.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::UniversalEngine;
1+
use super::Engine;
22
use crate::{CompilerConfig, Features};
33
use wasmer_types::Target;
44

@@ -44,24 +44,24 @@ impl Universal {
4444
self
4545
}
4646

47-
/// Build the `UniversalEngine` for this configuration
47+
/// Build the `Engine` for this configuration
4848
#[cfg(feature = "universal_engine")]
49-
pub fn engine(self) -> UniversalEngine {
49+
pub fn engine(self) -> Engine {
5050
let target = self.target.unwrap_or_default();
5151
if let Some(compiler_config) = self.compiler_config {
5252
let features = self
5353
.features
5454
.unwrap_or_else(|| compiler_config.default_features_for_target(&target));
5555
let compiler = compiler_config.compiler();
56-
UniversalEngine::new(compiler, target, features)
56+
Engine::new(compiler, target, features)
5757
} else {
58-
UniversalEngine::headless()
58+
Engine::headless()
5959
}
6060
}
6161

62-
/// Build the `UniversalEngine` for this configuration
62+
/// Build the `Engine` for this configuration
6363
#[cfg(not(feature = "universal_engine"))]
64-
pub fn engine(self) -> UniversalEngine {
65-
UniversalEngine::headless()
64+
pub fn engine(self) -> Engine {
65+
Engine::headless()
6666
}
6767
}

0 commit comments

Comments
 (0)