Skip to content

Commit 2e4b712

Browse files
committed
Remove module checksums on wasm function begin events; only rely on instance id
1 parent 573e308 commit 2e4b712

File tree

5 files changed

+23
-53
lines changed

5 files changed

+23
-53
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,11 @@ impl Func {
552552
{
553553
use crate::rr::component_events::WasmFuncBeginEvent;
554554

555-
let component = *self.instance.id().get(store.0).component().checksum();
556555
let instance = self.instance.id().instance();
557556
let func_idx = self.index;
558-
store.0.record_event(|| WasmFuncBeginEvent {
559-
component,
560-
instance,
561-
func_idx,
562-
})?;
557+
store
558+
.0
559+
.record_event(|| WasmFuncBeginEvent { instance, func_idx })?;
563560
}
564561
let export = self.lifted_core_func(store.0);
565562

crates/wasmtime/src/runtime/rr/core/events/component_events.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use wasmtime_environ::{
1313
/// Beginning marker for a Wasm component function call from host
1414
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1515
pub struct WasmFuncBeginEvent {
16-
/// Checksum of component containing function
17-
pub component: [u8; 32],
1816
/// Instance ID for the component instance
1917
pub instance: ComponentInstanceId,
2018
/// Export index for the invoked function

crates/wasmtime/src/runtime/rr/core/events/core_events.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ pub struct InstantiationEvent {
1616
/// A call event from Host into a core Wasm function
1717
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1818
pub struct WasmFuncEntryEvent {
19-
/// Checksum of module containing function
20-
pub module: [u8; 32],
2119
/// Origin (instance + function index) for this function
2220
pub origin: WasmFuncOrigin,
2321
/// Raw values passed across call boundary

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use crate::rr::core_events::{HostFuncReturnEvent, WasmFuncEntryEvent};
55
use crate::rr::{
66
RRFuncArgVals, ResultEvent, core_events::HostFuncEntryEvent, core_events::WasmFuncReturnEvent,
77
};
8-
#[cfg(feature = "rr")]
9-
use crate::store::StoreInstanceId;
108
use crate::store::StoreOpaque;
119
use crate::{FuncType, StoreContextMut, ValRaw, WasmFuncOrigin, prelude::*};
1210

@@ -28,15 +26,9 @@ where
2826
#[cfg(feature = "rr")]
2927
{
3028
if let Some(origin) = origin {
31-
let checksum = *store
32-
.0
33-
.module_for_instance(StoreInstanceId::new(store.0.id(), origin.instance))
34-
.unwrap()
35-
.checksum();
3629
store.0.record_event(|| {
3730
let flat = ty.params().map(|t| t.to_wasm_type().byte_size());
3831
WasmFuncEntryEvent {
39-
module: checksum,
4032
origin,
4133
args: RRFuncArgVals::from_flat_iter(args, flat),
4234
}

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

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#[cfg(feature = "rr-component")]
2-
use crate::component::{self, Component};
2+
use crate::component::{self, Component, ComponentInstanceId};
33
#[cfg(feature = "rr-component")]
44
use crate::rr::component_events;
55
use crate::rr::{
66
RREvent, ReplayError, Validate, component_hooks::ReplayLoweringPhase, core_events,
77
};
8+
use crate::store::InstanceId;
89
use crate::{
910
AsContextMut, Engine, Module, ReplayReader, ReplaySettings, Store, ValRaw, prelude::*,
1011
};
@@ -92,8 +93,9 @@ pub struct ReplayInstance<T: 'static> {
9293
store: Store<T>,
9394
component_linker: component::Linker<T>,
9495
module_linker: crate::Linker<T>,
95-
module_instances: BTreeMap<core_events::InstantiationEvent, crate::Instance>,
96-
component_instances: BTreeMap<component_events::InstantiationEvent, component::Instance>,
96+
module_instances: BTreeMap<InstanceId, crate::Instance>,
97+
#[cfg(feature = "rr-component")]
98+
component_instances: BTreeMap<ComponentInstanceId, component::Instance>,
9799
}
98100

99101
impl<T: 'static> ReplayInstance<T> {
@@ -119,6 +121,7 @@ impl<T: 'static> ReplayInstance<T> {
119121
component_linker,
120122
module_linker,
121123
module_instances: BTreeMap::new(),
124+
#[cfg(feature = "rr-component")]
122125
component_instances: BTreeMap::new(),
123126
})
124127
}
@@ -161,9 +164,8 @@ impl<T: 'static> ReplayInstance<T> {
161164
instance: instance.id().instance(),
162165
})?;
163166

164-
let ret = self.component_instances.insert(event, instance);
165-
// Ensures that an already-instantiated configuration is not re-instantiated
166-
assert!(ret.is_none());
167+
self.component_instances
168+
.insert(instance.id().instance(), instance);
167169
}
168170
#[cfg(not(feature = "rr-component"))]
169171
{
@@ -176,14 +178,11 @@ impl<T: 'static> ReplayInstance<T> {
176178
#[cfg(feature = "rr-component")]
177179
{
178180
// Grab the correct component instance
179-
let key = component_events::InstantiationEvent {
180-
component: event.component,
181-
instance: event.instance,
182-
};
181+
let key = event.instance;
183182
let instance = self
184183
.component_instances
185184
.get_mut(&key)
186-
.ok_or(ReplayError::MissingComponentInstance(key.instance.as_u32()))?;
185+
.ok_or(ReplayError::MissingComponentInstance(key.as_u32()))?;
187186

188187
// Replay lowering steps and obtain raw value arguments to raw function call
189188
let func = component::Func::from_lifted_func(*instance, event.func_idx);
@@ -247,20 +246,15 @@ impl<T: 'static> ReplayInstance<T> {
247246
instance: instance.id(),
248247
})?;
249248

250-
let ret = self.module_instances.insert(event, instance);
251-
// Ensures that an already-instantiated configuration is not re-instantiated
252-
assert!(ret.is_none());
249+
self.module_instances.insert(instance.id(), instance);
253250
}
254251
RREvent::CoreWasmFuncEntry(event) => {
255252
// Grab the correct module instance
256-
let key = core_events::InstantiationEvent {
257-
module: event.module,
258-
instance: event.origin.instance,
259-
};
253+
let key = event.origin.instance;
260254
let instance = self
261255
.module_instances
262256
.get_mut(&key)
263-
.ok_or(ReplayError::MissingModuleInstance(key.instance.as_u32()))?;
257+
.ok_or(ReplayError::MissingModuleInstance(key.as_u32()))?;
264258

265259
let entity = EntityIndex::from(event.origin.index);
266260
let mut store = self.store.as_context_mut();
@@ -316,9 +310,8 @@ impl<T: 'static> ReplayInstance<T> {
316310
instance: instance.id().instance(),
317311
})?;
318312

319-
let ret = self.component_instances.insert(event, instance);
320-
// Ensures that an already-instantiated configuration is not re-instantiated
321-
assert!(ret.is_none());
313+
self.component_instances
314+
.insert(instance.id().instance(), instance);
322315
}
323316
#[cfg(not(feature = "rr-component"))]
324317
{
@@ -331,14 +324,11 @@ impl<T: 'static> ReplayInstance<T> {
331324
#[cfg(feature = "rr-component")]
332325
{
333326
// Grab the correct component instance
334-
let key = component_events::InstantiationEvent {
335-
component: event.component,
336-
instance: event.instance,
337-
};
327+
let key = event.instance;
338328
let instance = self
339329
.component_instances
340330
.get_mut(&key)
341-
.ok_or(ReplayError::MissingComponentInstance(key.instance.as_u32()))?;
331+
.ok_or(ReplayError::MissingComponentInstance(key.as_u32()))?;
342332

343333
// Replay lowering steps and obtain raw value arguments to raw function call
344334
let func = component::Func::from_lifted_func(*instance, event.func_idx);
@@ -405,20 +395,15 @@ impl<T: 'static> ReplayInstance<T> {
405395
instance: instance.id(),
406396
})?;
407397

408-
let ret = self.module_instances.insert(event, instance);
409-
// Ensures that an already-instantiated configuration is not re-instantiated
410-
assert!(ret.is_none());
398+
self.module_instances.insert(instance.id(), instance);
411399
}
412400
RREvent::CoreWasmFuncEntry(event) => {
413401
// Grab the correct module instance
414-
let key = core_events::InstantiationEvent {
415-
module: event.module,
416-
instance: event.origin.instance,
417-
};
402+
let key = event.origin.instance;
418403
let instance = self
419404
.module_instances
420405
.get_mut(&key)
421-
.ok_or(ReplayError::MissingModuleInstance(key.instance.as_u32()))?;
406+
.ok_or(ReplayError::MissingModuleInstance(key.as_u32()))?;
422407

423408
let entity = EntityIndex::from(event.origin.index);
424409
let mut store = self.store.as_context_mut();

0 commit comments

Comments
 (0)