Skip to content

Commit c4cf712

Browse files
committed
rename new crate features
- compact -> indirect-dispatch - trampolines -> portable-dispatch
1 parent ffbd7c8 commit c4cf712

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

crates/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude.workspace = true
1515
publish = false
1616

1717
[dependencies]
18-
wasmi = { workspace = true, features = ["std", "simd", "trampolines", "extra-checks"] }
18+
wasmi = { workspace = true, features = ["std", "simd", "portable-dispatch", "extra-checks"] }
1919
wasmtime = { workspace = true, optional = true, features = [
2020
"cranelift",
2121
"runtime",

crates/wasmi/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ prefer-btree-collections = [
5252
]
5353
wat = ["dep:wat", "std"]
5454
simd = ["wasmi_core/simd", "wasmi_ir2/simd", "wasmparser/simd"]
55-
# Uses a compact representation for the IR to decrease
56-
# memory consumption at the cost of runtime performance.
57-
compact = []
58-
# Uses trampoline instruction dispatch instead of tail calls.
59-
# While this instruction dispatch is universally applicable it
60-
# usually is slower than tail dispatch.
61-
trampolines = []
55+
56+
# Enables a portable dispatch scheme that avoids tail-call reliance.
57+
# Recommended for targets without stable or guaranteed tail-call support.
58+
portable-dispatch = []
59+
# Enables an indirect dispatch scheme using op-codes instead of
60+
# embedded function pointers for more compact bytecode.
61+
indirect-dispatch = []
6262

6363
# Enables extra checks performed during Wasmi bytecode execution.
6464
#

crates/wasmi/src/engine/executor/handler/dispatch.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use core::{marker::PhantomData, ops::ControlFlow};
2626

2727
#[inline(always)]
2828
pub fn fetch_handler(ip: Ip) -> Handler {
29-
match cfg!(feature = "compact") {
29+
match cfg!(feature = "indirect-dispatch") {
3030
true => {
3131
let (_, op_code) = unsafe { ip.decode::<OpCode>() };
3232
op_code_to_handler(op_code)
@@ -289,7 +289,7 @@ impl<'a, T> HostFuncCall<'a, T, state::Done> {
289289
}
290290
}
291291

292-
#[cfg(feature = "trampolines")]
292+
#[cfg(feature = "portable-dispatch")]
293293
pub fn execute_until_done(
294294
mut state: VmState,
295295
mut ip: Ip,
@@ -321,7 +321,7 @@ pub fn execute_until_done(
321321
state.into_execution_outcome()
322322
}
323323

324-
#[cfg(not(feature = "trampolines"))]
324+
#[cfg(not(feature = "portable-dispatch"))]
325325
pub fn execute_until_done(
326326
state: VmState,
327327
ip: Ip,
@@ -380,11 +380,11 @@ impl From<Error> for ExecutionOutcome {
380380
}
381381
}
382382

383-
#[cfg(not(feature = "trampolines"))]
383+
#[cfg(not(feature = "portable-dispatch"))]
384384
#[derive(Debug)]
385385
pub enum NextState {}
386386

387-
#[cfg(feature = "trampolines")]
387+
#[cfg(feature = "portable-dispatch")]
388388
#[derive(Debug, Copy, Clone)]
389389
pub struct NextState {
390390
ip: Ip,
@@ -457,12 +457,12 @@ impl Break {
457457
pub type Control<C = (), B = Break> = ControlFlow<B, C>;
458458
pub type Done<T = NextState> = Control<T, Break>;
459459

460-
#[cfg(feature = "trampolines")]
460+
#[cfg(feature = "portable-dispatch")]
461461
pub trait ControlContinue: Sized {
462462
fn control_continue(ip: Ip, sp: Sp, mem0: Mem0Ptr, mem0_len: Mem0Len, instance: Inst) -> Self;
463463
}
464464

465-
#[cfg(feature = "trampolines")]
465+
#[cfg(feature = "portable-dispatch")]
466466
impl ControlContinue for Done<NextState> {
467467
fn control_continue(ip: Ip, sp: Sp, mem0: Mem0Ptr, mem0_len: Mem0Len, instance: Inst) -> Self {
468468
Self::Continue(NextState {
@@ -514,15 +514,15 @@ macro_rules! done {
514514
}};
515515
}
516516

517-
#[cfg(not(feature = "trampolines"))]
517+
#[cfg(not(feature = "portable-dispatch"))]
518518
macro_rules! dispatch {
519519
($state:expr, $ip:expr, $sp:expr, $mem0:expr, $mem0_len:expr, $instance:expr) => {{
520520
let handler = $crate::engine::executor::handler::dispatch::fetch_handler($ip);
521521
return handler($state, $ip, $sp, $mem0, $mem0_len, $instance);
522522
}};
523523
}
524524

525-
#[cfg(feature = "trampolines")]
525+
#[cfg(feature = "portable-dispatch")]
526526
macro_rules! dispatch {
527527
($state:expr, $ip:expr, $sp:expr, $mem0:expr, $mem0_len:expr, $instance:expr) => {{
528528
let _: &mut VmState = $state;

crates/wasmi/src/engine/executor/handler/exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use crate::{
5555
use core::cmp;
5656

5757
unsafe fn decode_op<Op: ir::Decode>(ip: Ip) -> (Ip, Op) {
58-
let ip = match cfg!(feature = "compact") {
58+
let ip = match cfg!(feature = "indirect-dispatch") {
5959
true => unsafe { ip.skip::<ir::OpCode>() },
6060
false => unsafe { ip.skip::<::core::primitive::usize>() },
6161
};

crates/wasmi/src/engine/executor/handler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod eval;
66
mod exec;
77
mod state;
88

9-
#[cfg(feature = "trampolines")]
9+
#[cfg(feature = "portable-dispatch")]
1010
use self::dispatch::ControlContinue;
1111
pub use self::{
1212
dispatch::{

crates/wasmi/src/engine/translator/func/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ impl FuelCostsSelector for FuelUsed {
750750

751751
/// Encodes an [`OpCode`] to a generic [`ir::Encoder`].
752752
fn encode_op_code<E: ir::Encoder>(encoder: &mut E, code: OpCode) -> Result<E::Pos, E::Error> {
753-
match cfg!(feature = "compact") {
753+
match cfg!(feature = "indirect-dispatch") {
754754
true => {
755755
// Note: encoding for indirect-threading
756756
//

crates/wast/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ wast = { workspace = true, features = ["wasm-module"] }
1919
anyhow = "1.0"
2020

2121
[features]
22-
default = ["trampolines", "extra-checks"]
23-
compact = ["wasmi/compact"]
24-
trampolines = ["wasmi/trampolines"]
22+
default = ["portable-dispatch", "extra-checks"]
23+
portable-dispatch = ["wasmi/portable-dispatch"]
24+
indirect-dispatch = ["wasmi/indirect-dispatch"]
2525
extra-checks = ["wasmi/extra-checks"]

0 commit comments

Comments
 (0)