@@ -24,8 +24,6 @@ use crate::stack::{StackCreator, StackCreatorProxy};
2424#[ cfg( feature = "async" ) ]
2525use wasmtime_fiber:: RuntimeFiberStackCreator ;
2626
27- #[ cfg( feature = "rr" ) ]
28- use crate :: rr:: ReplayReader ;
2927#[ cfg( feature = "runtime" ) ]
3028pub use crate :: runtime:: code_memory:: CustomCodeMemory ;
3129#[ cfg( feature = "cache" ) ]
@@ -178,6 +176,8 @@ pub struct Config {
178176 pub ( crate ) detect_host_feature : Option < fn ( & str ) -> Option < bool > > ,
179177 #[ cfg( feature = "rr" ) ]
180178 pub ( crate ) record_support : bool ,
179+ #[ cfg( feature = "rr" ) ]
180+ pub ( crate ) replay_support : bool ,
181181}
182182
183183/// User-provided configuration for the compiler.
@@ -234,63 +234,6 @@ impl Default for CompilerConfig {
234234 }
235235}
236236
237- /// Settings for execution replay.
238- #[ cfg( feature = "rr" ) ]
239- #[ derive( Debug , Clone ) ]
240- pub struct ReplaySettings {
241- /// Flag to include additional signatures for replay validation.
242- pub validate : bool ,
243- /// Static buffer size for deserialization of variable-length types (like [String]).
244- pub deser_buffer_size : usize ,
245- }
246-
247- #[ cfg( feature = "rr" ) ]
248- impl Default for ReplaySettings {
249- fn default ( ) -> Self {
250- Self {
251- validate : false ,
252- deser_buffer_size : 64 ,
253- }
254- }
255- }
256-
257- /// Configuration for replay execution.
258- #[ cfg( feature = "rr" ) ]
259- #[ derive( Clone ) ]
260- pub struct ReplayConfig {
261- /// Closure that generates a reader for replaying execution traces.
262- pub reader_initializer : Arc < dyn Fn ( ) -> Box < dyn ReplayReader > + Send + Sync > ,
263- /// Flag for dynamic validation checks when replaying events.
264- pub settings : ReplaySettings ,
265- }
266-
267- /// Configurations for record/replay (RR) executions.
268- #[ cfg( feature = "rr" ) ]
269- #[ derive( Clone ) ]
270- pub enum RRConfig {
271- /// Replay configuration.
272- Replay ( ReplayConfig ) ,
273- }
274-
275- #[ cfg( feature = "rr" ) ]
276- impl From < ReplayConfig > for RRConfig {
277- fn from ( value : ReplayConfig ) -> Self {
278- Self :: Replay ( value)
279- }
280- }
281-
282- #[ cfg( feature = "rr" ) ]
283- impl RRConfig {
284- /// Obtain the replay configuration.
285- ///
286- /// Return [`None`] if it is not configured.
287- pub fn replay ( & self ) -> Option < & ReplayConfig > {
288- match self {
289- Self :: Replay ( r) => Some ( r) ,
290- }
291- }
292- }
293-
294237impl Config {
295238 /// Creates a new configuration object with the default configuration
296239 /// specified.
@@ -345,6 +288,8 @@ impl Config {
345288 detect_host_feature : None ,
346289 #[ cfg( feature = "rr" ) ]
347290 record_support : false ,
291+ #[ cfg( feature = "rr" ) ]
292+ replay_support : false ,
348293 } ;
349294 #[ cfg( any( feature = "cranelift" , feature = "winch" ) ) ]
350295 {
@@ -2799,14 +2744,30 @@ impl Config {
27992744 self
28002745 }
28012746
2747+ /// Enable execution trace replaying with the provided configuration.
2748+ ///
2749+ /// This method implicitly enforces determinism (see [`Config::enforce_determinism`]
2750+ /// for details).
2751+ #[ cfg( feature = "rr" ) ]
2752+ #[ inline]
2753+ pub fn replaying ( & mut self , enable : bool ) -> & mut Self {
2754+ if enable {
2755+ self . enforce_determinism ( ) ;
2756+ } else {
2757+ self . remove_determinism_enforcement ( ) ;
2758+ }
2759+ self . replay_support = enable;
2760+ self
2761+ }
2762+
28022763 /// Evaluates to true if current configuration must respect
28032764 /// deterministic execution in its configuration.
28042765 ///
28052766 /// Required for faithful record/replay execution.
28062767 #[ cfg( feature = "rr" ) ]
28072768 #[ inline]
28082769 pub fn is_determinism_enforced ( & mut self ) -> bool {
2809- self . record_support
2770+ self . record_support || self . replay_support
28102771 }
28112772}
28122773
0 commit comments