Skip to content

Commit 1bdbe5c

Browse files
authored
Refactor baseline and optimized runtimes (bytecodealliance#168)
This patch modularises the optimized runtime in the same manner as the baseline runtime already was. It factors out the `StackChain` logic into a separate module `stack_chain`, which is needed to add support for backtraces to the baseline implementation (yet to be done!).
1 parent 9c9264c commit 1bdbe5c

File tree

16 files changed

+698
-627
lines changed

16 files changed

+698
-627
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ jobs:
647647
648648
# Test baseline implementation
649649
- name: Baseline implementation
650-
run: cargo test --features=default,typed_continuations_baseline_implementation
650+
run: cargo test --features=default,wasmfx_baseline
651651
env:
652652
RUST_BACKTRACE: 1
653653

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ unsafe_disable_continuation_linearity_check = [
410410
]
411411

412412
# The following toggles the baseline implementation of typed continuations.
413-
typed_continuations_baseline_implementation = [
414-
"wasmtime-cranelift/typed_continuations_baseline_implementation",
415-
"wasmtime/typed_continuations_baseline_implementation"
413+
wasmfx_baseline = [
414+
"wasmtime-cranelift/wasmfx_baseline",
415+
"wasmtime/wasmfx_baseline"
416416
]
417417

418418
# CLI subcommands for the `wasmtime` executable. See `wasmtime $cmd --help`

crates/cranelift/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ component-model = ["wasmtime-environ/component-model"]
3939
incremental-cache = ["cranelift-codegen/incremental-cache"]
4040
wmemcheck = []
4141
unsafe_disable_continuation_linearity_check = []
42-
typed_continuations_baseline_implementation = []
42+
wasmfx_baseline = []
4343
gc = ["wasmtime-environ/gc"]
4444
threads = ["wasmtime-environ/threads"]

crates/cranelift/src/func_environ.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use wasmtime_environ::{
2424
use wasmtime_environ::{FUNCREF_INIT_BIT, FUNCREF_MASK};
2525

2626
cfg_if::cfg_if! {
27-
if #[cfg(feature = "typed_continuations_baseline_implementation")] {
27+
if #[cfg(feature = "wasmfx_baseline")] {
2828
use crate::wasmfx::baseline as wasmfx_impl;
2929
} else {
3030
use crate::wasmfx::optimized as wasmfx_impl;

crates/cranelift/src/wasmfx/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@
77
/// implementations.
88
mod shared;
99

10-
#[cfg_attr(
11-
not(feature = "typed_continuations_baseline_implementation"),
12-
allow(dead_code)
13-
)]
10+
#[cfg_attr(not(feature = "wasmfx_baseline"), allow(dead_code))]
1411
pub(crate) mod baseline;
1512

16-
#[cfg_attr(
17-
feature = "typed_continuations_baseline_implementation",
18-
allow(dead_code)
19-
)]
13+
#[cfg_attr(feature = "wasmfx_baseline", allow(dead_code))]
2014
pub(crate) mod optimized;

crates/wasmtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,4 @@ std = [
270270
unsafe_disable_continuation_linearity_check = []
271271

272272
# Toggle the baseline implementation of WasmFX
273-
typed_continuations_baseline_implementation = ["async"]
273+
wasmfx_baseline = ["async"]

crates/wasmtime/src/runtime/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ use crate::instance::InstanceData;
8080
use crate::linker::Definition;
8181
use crate::module::{BareModuleInfo, RegisteredModuleId};
8282
use crate::prelude::*;
83-
use crate::runtime::vm::continuation::{StackChain, StackChainCell, StackLimits};
83+
use crate::runtime::vm::continuation::stack_chain::{StackChain, StackChainCell, StackLimits};
8484
use crate::runtime::vm::mpk::{self, ProtectionKey, ProtectionMask};
8585
use crate::runtime::vm::{
8686
Backtrace, ExportGlobal, GcHeapAllocationIndex, GcRootsList, GcStore,

crates/wasmtime/src/runtime/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use alloc::sync::Arc;
77
use anyhow::{Error, Result};
8-
use continuation::StackChainCell;
8+
use continuation::stack_chain::StackChainCell;
99
use core::fmt;
1010
use core::ptr::NonNull;
1111
use core::sync::atomic::{AtomicU64, AtomicUsize, Ordering};

0 commit comments

Comments
 (0)