Skip to content

Commit 3ba9849

Browse files
committed
Reorganize RR module with hooks
1 parent d6adc43 commit 3ba9849

File tree

16 files changed

+33
-31
lines changed

16 files changed

+33
-31
lines changed

crates/wasmtime/src/runtime.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub(crate) mod memory;
4949
pub(crate) mod module;
5050
pub(crate) mod resources;
5151
pub(crate) mod rr;
52-
pub(crate) mod rr_hooks;
5352
pub(crate) mod store;
5453
pub(crate) mod trampoline;
5554
pub(crate) mod trap;

crates/wasmtime/src/runtime/component/func.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::component::storage::storage_as_slice;
44
use crate::component::types::Type;
55
use crate::component::values::Val;
66
use crate::prelude::*;
7-
use crate::rr_hooks::component_hooks;
7+
use crate::rr::component_hooks;
88
use crate::runtime::vm::component::{ComponentInstance, InstanceFlags, ResourceTables};
99
use crate::runtime::vm::{Export, VMFuncRef};
1010
use crate::store::StoreOpaque;

crates/wasmtime/src/runtime/component/func/host.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use crate::component::matching::InstanceType;
55
use crate::component::storage::{slice_to_storage_mut, storage_as_slice_mut};
66
use crate::component::{ComponentNamedList, ComponentType, Instance, Lift, Lower, Val};
77
use crate::prelude::*;
8-
use crate::rr_hooks;
8+
use crate::rr;
99
#[cfg(feature = "rr-component")]
10-
use crate::rr_hooks::component_hooks::ReplayLoweringPhase;
10+
use crate::rr::component_hooks::ReplayLoweringPhase;
1111
use crate::runtime::vm::component::{
1212
ComponentInstance, VMComponentContext, VMLowering, VMLoweringCallee,
1313
};
@@ -257,7 +257,7 @@ where
257257

258258
let types = vminstance.component().types().clone();
259259

260-
rr_hooks::component_hooks::record_replay_host_func_entry(storage, &ty, store.0)?;
260+
rr::component_hooks::record_replay_host_func_entry(storage, &ty, store.0)?;
261261

262262
let ty = &types[ty];
263263
let param_tys = InterfaceType::Tuple(ty.params);
@@ -621,27 +621,27 @@ where
621621
) -> Result<()> {
622622
match self.lower_dst() {
623623
Dst::Direct(storage) => {
624-
let result = rr_hooks::component_hooks::record_lower_flat(
624+
let result = rr::component_hooks::record_lower_flat(
625625
|cx, ty| ret.linear_lower_to_flat(cx, ty, storage),
626626
cx,
627627
ty,
628628
);
629-
rr_hooks::component_hooks::record_host_func_return(
629+
rr::component_hooks::record_host_func_return(
630630
unsafe { storage_as_slice_mut(storage) },
631631
cx.store.0,
632632
)?;
633633
result
634634
}
635635
Dst::Indirect(ptr) => {
636636
let ptr = validate_inbounds::<R>(cx.as_slice(), ptr)?;
637-
let result = rr_hooks::component_hooks::record_lower_memory(
637+
let result = rr::component_hooks::record_lower_memory(
638638
|cx, ty, ptr| ret.linear_lower_to_memory(cx, ty, ptr),
639639
cx,
640640
ty,
641641
ptr,
642642
);
643643
// Recording here is just for marking the return event
644-
rr_hooks::component_hooks::record_host_func_return(&[], cx.store.0)?;
644+
rr::component_hooks::record_host_func_return(&[], cx.store.0)?;
645645
result
646646
}
647647
}
@@ -811,7 +811,7 @@ where
811811

812812
let types = instance.id().get(store.0).component().types().clone();
813813

814-
rr_hooks::component_hooks::record_replay_host_func_entry(storage, &ty, store.0)?;
814+
rr::component_hooks::record_replay_host_func_entry(storage, &ty, store.0)?;
815815

816816
let func_ty = &types[ty];
817817
let param_tys = &types[func_ty.params];
@@ -924,28 +924,28 @@ where
924924
if let Some(cnt) = result_tys.abi.flat_count(MAX_FLAT_RESULTS) {
925925
let mut dst = storage[..cnt].iter_mut();
926926
for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) {
927-
rr_hooks::component_hooks::record_lower_flat(
927+
rr::component_hooks::record_lower_flat(
928928
|cx, ty| val.lower(cx, ty, &mut dst),
929929
&mut cx,
930930
*ty,
931931
)?;
932932
}
933933
assert!(dst.next().is_none());
934-
rr_hooks::component_hooks::record_host_func_return(storage, cx.store.0)?;
934+
rr::component_hooks::record_host_func_return(storage, cx.store.0)?;
935935
} else {
936936
let ret_ptr = unsafe { storage[ret_index].assume_init_ref() };
937937
let mut ptr = validate_inbounds_dynamic(&result_tys.abi, cx.as_slice(), ret_ptr)?;
938938
for (val, ty) in result_vals.iter().zip(result_tys.types.iter()) {
939939
let offset = types.canonical_abi(ty).next_field32_size(&mut ptr);
940-
rr_hooks::component_hooks::record_lower_memory(
940+
rr::component_hooks::record_lower_memory(
941941
|cx, ty, ptr| val.store(cx, ty, ptr),
942942
&mut cx,
943943
*ty,
944944
offset,
945945
)?;
946946
}
947947
// Recording here is just for marking the return event
948-
rr_hooks::component_hooks::record_host_func_return(&[], cx.store.0)?;
948+
rr::component_hooks::record_host_func_return(&[], cx.store.0)?;
949949
}
950950

951951
unsafe {

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::rr::{
1111
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
1212
use crate::rr::{Validate, component_events::ReallocReturnEvent};
1313
#[cfg(feature = "rr-component")]
14-
use crate::rr_hooks::component_hooks::ReplayLoweringPhase;
15-
use crate::rr_hooks::{ConstMemorySliceCell, MemorySliceCell};
14+
use crate::rr::component_hooks::ReplayLoweringPhase;
15+
use crate::rr::{ConstMemorySliceCell, MemorySliceCell};
1616
use crate::runtime::vm::component::{
1717
CallContexts, ComponentInstance, InstanceFlags, ResourceTable, ResourceTables,
1818
};

crates/wasmtime/src/runtime/component/func/typed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::component::func::{Func, LiftContext, LowerContext, Options};
33
use crate::component::matching::InstanceType;
44
use crate::component::storage::{storage_as_slice, storage_as_slice_mut};
55
use crate::prelude::*;
6-
use crate::rr_hooks::component_hooks;
6+
use crate::rr::component_hooks;
77
use crate::{AsContextMut, StoreContext, StoreContextMut, ValRaw};
88
use alloc::borrow::Cow;
99
use core::fmt;

crates/wasmtime/src/runtime/func.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::prelude::*;
2-
use crate::rr_hooks;
2+
use crate::rr;
33
use crate::runtime::Uninhabited;
44
use crate::runtime::vm::{
55
InterpreterRef, SendSyncPtr, StoreBox, VMArrayCallHostFuncContext, VMCommonStackInformation,
@@ -2378,7 +2378,7 @@ impl HostContext {
23782378

23792379
// Record/replay(validation) of the raw parameter arguments
23802380
// Don't need auto-assert GC store here since we aren't using P, just raw args
2381-
rr_hooks::core_hooks::record_replay_host_func_entry(
2381+
rr::core_hooks::record_replay_host_func_entry(
23822382
unsafe { &args.as_ref()[..num_params] },
23832383
&func_type_index,
23842384
caller.store.0,
@@ -2423,14 +2423,14 @@ impl HostContext {
24232423
unsafe { ret.store(&mut store, args.as_mut())? };
24242424
}
24252425
// Record the return values
2426-
rr_hooks::core_hooks::record_host_func_return(
2426+
rr::core_hooks::record_host_func_return(
24272427
unsafe { &args.as_ref()[..num_results] },
24282428
&func_type_index,
24292429
caller.store.0,
24302430
)?;
24312431
} else {
24322432
// Replay the return values
2433-
rr_hooks::core_hooks::replay_host_func_return(
2433+
rr::core_hooks::replay_host_func_return(
24342434
unsafe { &mut args.as_mut()[..num_results] },
24352435
&func_type_index,
24362436
caller.store.0,

crates/wasmtime/src/runtime/rr.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Wasmtime's Record and Replay support.
2+
//!
3+
//! This feature is currently not optimized and under development
4+
5+
/// Convenience method hooks for injecting event recording/replaying in the rest of the engine
6+
mod hooks;
7+
pub use hooks::{ConstMemorySliceCell, MemorySliceCell, component_hooks, core_hooks};
8+
9+
#[cfg(feature = "rr")]
10+
/// Core infrastructure for RR support
11+
mod core;
12+
#[cfg(feature = "rr")]
13+
pub use core::*;
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
#![cfg(feature = "rr")]
2-
//! Wasmtime's Record and Replay support.
3-
//!
4-
//! This feature is currently not optimized and under development
5-
//!
6-
//! ## Notes
7-
//!
8-
//! This module does NOT support RR for component builtins yet.
9-
101
use crate::config::{ModuleVersionStrategy, ReplaySettings};
112
use crate::prelude::*;
123
use core::fmt;
File renamed without changes.

crates/wasmtime/src/runtime/rr/events/common_events.rs renamed to crates/wasmtime/src/runtime/rr/core/events/common_events.rs

File renamed without changes.

0 commit comments

Comments
 (0)