Skip to content

Commit 4b32230

Browse files
committed
Fix warnings and replace call_unchecked_raw to use RR arg
1 parent 875a4b1 commit 4b32230

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ impl Instance {
18031803
} else {
18041804
RRWasmFuncType::None
18051805
};
1806-
crate::Func::call_unchecked_raw_with_rr(
1806+
crate::Func::call_unchecked_raw(
18071807
&mut store,
18081808
callee.as_non_null(),
18091809
NonNull::new(
@@ -1992,6 +1992,7 @@ impl Instance {
19921992
&mut store,
19931993
func.as_non_null(),
19941994
slice::from_ref(&post_return_arg).into(),
1995+
RRWasmFuncType::None,
19951996
)?;
19961997
}
19971998
}
@@ -2137,13 +2138,15 @@ impl Instance {
21372138
// for details) we know it takes count parameters and returns
21382139
// `dst.len()` results.
21392140
unsafe {
2141+
// No RR on guest->guest calls
21402142
crate::Func::call_unchecked_raw(
21412143
&mut store,
21422144
start.as_non_null(),
21432145
NonNull::new(
21442146
&mut src[..count.max(dst.len())] as *mut [MaybeUninit<ValRaw>] as _,
21452147
)
21462148
.unwrap(),
2149+
RRWasmFuncType::None,
21472150
)?;
21482151
}
21492152
dst.copy_from_slice(&src[..dst.len()]);
@@ -2172,10 +2175,12 @@ impl Instance {
21722175
// for details) we know it takes `src.len()` parameters and
21732176
// returns up to 1 result.
21742177
unsafe {
2178+
// No RR on guest->guest calls
21752179
crate::Func::call_unchecked_raw(
21762180
&mut store,
21772181
return_.as_non_null(),
21782182
my_src.as_mut_slice().into(),
2183+
RRWasmFuncType::None,
21792184
)?;
21802185
}
21812186
let state = store.0.concurrent_state_mut();
@@ -2265,6 +2270,7 @@ impl Instance {
22652270
&mut store,
22662271
function.as_non_null(),
22672272
params.as_mut_slice().into(),
2273+
RRWasmFuncType::None,
22682274
)?;
22692275
flags.set_may_enter(may_enter_after_call);
22702276
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ impl Func {
633633

634634
let type_idx = self.abi_info(store.0).2;
635635
let types = self.instance.id().get(store.0).component().types().clone();
636-
crate::Func::call_unchecked_raw_with_rr(
636+
crate::Func::call_unchecked_raw(
637637
&mut store,
638638
export,
639639
params_and_returns,
@@ -791,6 +791,7 @@ impl Func {
791791
func,
792792
NonNull::new(core::ptr::slice_from_raw_parts(&post_return_arg, 1).cast_mut())
793793
.unwrap(),
794+
RRWasmFuncType::None,
794795
)?;
795796
}
796797

crates/wasmtime/src/runtime/component/resources/any.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,15 @@ impl ResourceAny {
211211
// destructors have al been previously type-checked and are guaranteed
212212
// to take one i32 argument and return no results, so the parameters
213213
// here should be configured correctly.
214-
unsafe { crate::Func::call_unchecked_raw(store, dtor, NonNull::from(&mut args)) }
214+
unsafe {
215+
// No recording since builtins are recorded
216+
crate::Func::call_unchecked_raw(
217+
store,
218+
dtor,
219+
NonNull::from(&mut args),
220+
crate::rr::RRWasmFuncType::None,
221+
)
222+
}
215223
}
216224

217225
fn lower_to_index<U>(&self, cx: &mut LowerContext<'_, U>, ty: InterfaceType) -> Result<u32> {

crates/wasmtime/src/runtime/func.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ impl Func {
10461046
unsafe {
10471047
let ty = &self.ty(&store);
10481048
let origin = self.origin.expand();
1049-
Self::call_unchecked_raw_with_rr(
1049+
Self::call_unchecked_raw(
10501050
&mut store,
10511051
func_ref,
10521052
params_and_returns,
@@ -1055,17 +1055,11 @@ impl Func {
10551055
}
10561056
}
10571057

1058-
/// Same as [`Func::call_unchecked_raw`] but enables recording and replaying
1059-
/// hooks for func entry/exit based on whether the intended call was from a component or
1060-
/// core wasm module.
1058+
/// Raw, unchecked call to the underlying func_ref.
10611059
///
1062-
/// This method is essentially a wrapper over [`Func::call_unchecked_raw`] and operates exactly like it
1063-
/// when recording/replay is not enabled, so use this for all calls that will potentially need
1064-
/// to be recorded/replayed.
1065-
///
1066-
/// `RRWasmFuncType::None` can be used to disable recording/replaying and passthrough to `call_unchecked_raw`.
1067-
/// Eventually we can replace all occurences of `call_unchecked_raw` with this method with `RRWasmFuncType::None``
1068-
pub(crate) unsafe fn call_unchecked_raw_with_rr<T>(
1060+
/// This method contains record/replay hooks for either component or core wasm source that
1061+
/// invoked it based on `rr`. `RRWasmFuncType::None` can be used to disable record/replay for the call
1062+
pub(crate) unsafe fn call_unchecked_raw<T>(
10691063
mut store: &mut StoreContextMut<'_, T>,
10701064
func_ref: NonNull<VMFuncRef>,
10711065
params_and_returns: NonNull<[ValRaw]>,
@@ -1080,7 +1074,7 @@ impl Func {
10801074
// SAFETY: the safety of this function call is the same as the contract
10811075
// of this function.
10821076
unsafe {
1083-
Self::call_unchecked_raw(&mut store, func_ref, params_and_returns)
1077+
Self::call_unchecked_raw_inner(&mut store, func_ref, params_and_returns)
10841078
}
10851079
},
10861080
unsafe { params_and_returns.as_ref() },
@@ -1093,7 +1087,7 @@ impl Func {
10931087
RRWasmFuncType::Component { type_idx, types } => {
10941088
rr::component_hooks::record_and_replay_validate_wasm_func(
10951089
|mut store| unsafe {
1096-
Self::call_unchecked_raw(&mut store, func_ref, params_and_returns)
1090+
Self::call_unchecked_raw_inner(&mut store, func_ref, params_and_returns)
10971091
},
10981092
unsafe { params_and_returns.as_ref() },
10991093
type_idx,
@@ -1102,13 +1096,14 @@ impl Func {
11021096
)
11031097
}
11041098
// Passthrough
1099+
#[cfg(feature = "component-model")]
11051100
RRWasmFuncType::None => unsafe {
1106-
Self::call_unchecked_raw(&mut store, func_ref, params_and_returns)
1101+
Self::call_unchecked_raw_inner(&mut store, func_ref, params_and_returns)
11071102
},
11081103
}
11091104
}
11101105

1111-
pub(crate) unsafe fn call_unchecked_raw<T>(
1106+
unsafe fn call_unchecked_raw_inner<T>(
11121107
store: &mut StoreContextMut<'_, T>,
11131108
func_ref: NonNull<VMFuncRef>,
11141109
params_and_returns: NonNull<[ValRaw]>,

crates/wasmtime/src/runtime/rr/hooks.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use wasmtime_environ::component::{ComponentTypes, TypeFuncIndex};
1212

1313
/// Wasm function type information for RR hooks
1414
pub enum RRWasmFuncType<'a> {
15-
/// No RR hooks to be performed
16-
None,
1715
/// Core RR hooks to be performed
1816
Core {
1917
ty: &'a FuncType,
@@ -25,4 +23,7 @@ pub enum RRWasmFuncType<'a> {
2523
type_idx: TypeFuncIndex,
2624
types: Arc<ComponentTypes>,
2725
},
26+
/// No RR hooks to be performed
27+
#[cfg(feature = "component-model")]
28+
None,
2829
}

0 commit comments

Comments
 (0)