11#[ cfg( feature = "rr-component" ) ]
2- use crate :: component:: { self , Component } ;
2+ use crate :: component:: { self , Component , ComponentInstanceId } ;
33#[ cfg( feature = "rr-component" ) ]
44use crate :: rr:: component_events;
55use crate :: rr:: {
66 RREvent , ReplayError , Validate , component_hooks:: ReplayLoweringPhase , core_events,
77} ;
8+ use crate :: store:: InstanceId ;
89use 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
99101impl < 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