@@ -11,9 +11,8 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
1111use std:: sync:: Arc ;
1212use std:: sync:: Mutex ;
1313
14- // TODO: Increasing this number would cause JikesRVM die at boot time. I don't really know why.
15- // E.g. using 1 << 14 will cause JikesRVM segfault at boot time.
16- pub const MAX_PHASES : usize = 1 << 12 ;
14+ /// The default number of phases for the statistics.
15+ pub const DEFAULT_NUM_PHASES : usize = 1 << 12 ;
1716pub const MAX_COUNTERS : usize = 100 ;
1817
1918/// GC stats shared among counters
@@ -51,7 +50,6 @@ pub struct Stats {
5150 // Initialization of libpfm4 is required before we can use `PerfEvent` types
5251 #[ cfg( feature = "perf_counter" ) ]
5352 perfmon : Perfmon ,
54-
5553 pub shared : Arc < SharedStats > ,
5654 counters : Mutex < Vec < Arc < Mutex < dyn Counter + Send > > > > ,
5755 exceeded_phase_limit : AtomicBool ,
@@ -99,7 +97,6 @@ impl Stats {
9997 total_time : t,
10098 #[ cfg( feature = "perf_counter" ) ]
10199 perfmon,
102-
103100 shared,
104101 counters : Mutex :: new ( counters) ,
105102 exceeded_phase_limit : AtomicBool :: new ( false ) ,
@@ -157,32 +154,22 @@ impl Stats {
157154 if !self . get_gathering_stats ( ) {
158155 return ;
159156 }
160- if self . get_phase ( ) < MAX_PHASES - 1 {
161- let counters = self . counters . lock ( ) . unwrap ( ) ;
162- for counter in & ( * counters) {
163- counter. lock ( ) . unwrap ( ) . phase_change ( self . get_phase ( ) ) ;
164- }
165- self . shared . increment_phase ( ) ;
166- } else if !self . exceeded_phase_limit . load ( Ordering :: SeqCst ) {
167- eprintln ! ( "Warning: number of GC phases exceeds MAX_PHASES" ) ;
168- self . exceeded_phase_limit . store ( true , Ordering :: SeqCst ) ;
157+ let counters = self . counters . lock ( ) . unwrap ( ) ;
158+ for counter in & ( * counters) {
159+ counter. lock ( ) . unwrap ( ) . phase_change ( self . get_phase ( ) ) ;
169160 }
161+ self . shared . increment_phase ( ) ;
170162 }
171163
172164 pub fn end_gc ( & self ) {
173165 if !self . get_gathering_stats ( ) {
174166 return ;
175167 }
176- if self . get_phase ( ) < MAX_PHASES - 1 {
177- let counters = self . counters . lock ( ) . unwrap ( ) ;
178- for counter in & ( * counters) {
179- counter. lock ( ) . unwrap ( ) . phase_change ( self . get_phase ( ) ) ;
180- }
181- self . shared . increment_phase ( ) ;
182- } else if !self . exceeded_phase_limit . load ( Ordering :: SeqCst ) {
183- eprintln ! ( "Warning: number of GC phases exceeds MAX_PHASES" ) ;
184- self . exceeded_phase_limit . store ( true , Ordering :: SeqCst ) ;
168+ let counters = self . counters . lock ( ) . unwrap ( ) ;
169+ for counter in & ( * counters) {
170+ counter. lock ( ) . unwrap ( ) . phase_change ( self . get_phase ( ) ) ;
185171 }
172+ self . shared . increment_phase ( ) ;
186173 }
187174
188175 pub fn print_stats < VM : VMBinding > ( & self , mmtk : & ' static MMTK < VM > ) {
0 commit comments