@@ -110,6 +110,17 @@ impl ModuleVersionStrategy {
110110 }
111111}
112112
113+ /// Configuration for record/replay
114+ #[ derive( Clone ) ]
115+ pub enum RRConfig {
116+ /// Recording on store is enabled
117+ Recording ,
118+ /// Replaying on store is enabled
119+ Replaying ,
120+ /// No record/replay is enabled
121+ None ,
122+ }
123+
113124/// Global configuration options used to create an [`Engine`](crate::Engine)
114125/// and customize its behavior.
115126///
@@ -175,9 +186,7 @@ pub struct Config {
175186 pub ( crate ) macos_use_mach_ports : bool ,
176187 pub ( crate ) detect_host_feature : Option < fn ( & str ) -> Option < bool > > ,
177188 #[ cfg( feature = "rr" ) ]
178- pub ( crate ) record_support : bool ,
179- #[ cfg( feature = "rr" ) ]
180- pub ( crate ) replay_support : bool ,
189+ pub ( crate ) rr_config : RRConfig ,
181190}
182191
183192/// User-provided configuration for the compiler.
@@ -287,9 +296,7 @@ impl Config {
287296 #[ cfg( not( feature = "std" ) ) ]
288297 detect_host_feature : None ,
289298 #[ cfg( feature = "rr" ) ]
290- record_support : false ,
291- #[ cfg( feature = "rr" ) ]
292- replay_support : false ,
299+ rr_config : RRConfig :: None ,
293300 } ;
294301 #[ cfg( any( feature = "cranelift" , feature = "winch" ) ) ]
295302 {
@@ -2705,11 +2712,9 @@ impl Config {
27052712 self
27062713 }
27072714
2708- /// Enforce deterministic execution configurations. Currently, means the following:
2715+ /// Enforce deterministic execution configurations. Currently, this means the following:
27092716 /// * Enabling NaN canonicalization with [`Config::cranelift_nan_canonicalization`]
27102717 /// * Enabling deterministic relaxed SIMD with [`Config::relaxed_simd_deterministic`]
2711- ///
2712- /// Required for faithful record/replay execution.
27132718 #[ inline]
27142719 pub fn enforce_determinism ( & mut self ) -> & mut Self {
27152720 #[ cfg( any( feature = "cranelift" , feature = "winch" ) ) ]
@@ -2718,56 +2723,29 @@ impl Config {
27182723 self
27192724 }
27202725
2721- /// Remove determinstic execution enforcements (if any) applied
2722- /// by [`Config::enforce_determinism`].
2723- #[ inline]
2724- pub fn remove_determinism_enforcement ( & mut self ) -> & mut Self {
2725- #[ cfg( any( feature = "cranelift" , feature = "winch" ) ) ]
2726- self . cranelift_nan_canonicalization ( false ) ;
2727- self . relaxed_simd_deterministic ( false ) ;
2728- self
2729- }
2730-
2731- /// Enable execution trace recording with the provided configuration.
2726+ /// Enable execution trace recording or replaying to the configuration
27322727 ///
2733- /// This method implicitly enforces determinism (see [`Config::enforce_determinism`]
2734- /// for details).
2728+ /// When either recording/replaying are enabled, determinism is implicitly
2729+ /// enforced (see [`Config::enforce_determinism`] for details)
27352730 #[ cfg( feature = "rr" ) ]
27362731 #[ inline]
2737- pub fn recording ( & mut self , enable : bool ) -> & mut Self {
2738- if enable {
2739- self . enforce_determinism ( ) ;
2740- } else {
2741- self . remove_determinism_enforcement ( ) ;
2742- }
2743- self . record_support = enable;
2744- self
2745- }
2746-
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 ( ) ;
2732+ pub fn rr ( & mut self , cfg : RRConfig ) -> & mut Self {
2733+ self . rr_config = cfg;
2734+ match self . rr_config {
2735+ RRConfig :: Recording | RRConfig :: Replaying => self . enforce_determinism ( ) ,
2736+ _ => self ,
27582737 }
2759- self . replay_support = enable;
2760- self
27612738 }
27622739
27632740 /// Evaluates to true if current configuration must respect
27642741 /// deterministic execution in its configuration.
2765- ///
2766- /// Required for faithful record/replay execution.
27672742 #[ cfg( feature = "rr" ) ]
27682743 #[ inline]
27692744 pub fn is_determinism_enforced ( & mut self ) -> bool {
2770- self . record_support || self . replay_support
2745+ match self . rr_config {
2746+ RRConfig :: Recording | RRConfig :: Replaying => true ,
2747+ RRConfig :: None => false ,
2748+ }
27712749 }
27722750}
27732751
0 commit comments