comparison src/share/vm/runtime/sweeper.cpp @ 13400:86e6d691f2e1

8028128: Add a type safe alternative for working with counter based data Reviewed-by: dholmes, egahlin
author mgronlun
date Sat, 23 Nov 2013 12:25:13 +0100
parents 938e1e64e28f
children 02f27ecb4f3a d49557091d18 3205e78d8193
comparison
equal deleted inserted replaced
13399:260ac69dc096 13400:86e6d691f2e1
36 #include "runtime/os.hpp" 36 #include "runtime/os.hpp"
37 #include "runtime/sweeper.hpp" 37 #include "runtime/sweeper.hpp"
38 #include "runtime/vm_operations.hpp" 38 #include "runtime/vm_operations.hpp"
39 #include "trace/tracing.hpp" 39 #include "trace/tracing.hpp"
40 #include "utilities/events.hpp" 40 #include "utilities/events.hpp"
41 #include "utilities/ticks.inline.hpp"
41 #include "utilities/xmlstream.hpp" 42 #include "utilities/xmlstream.hpp"
42 43
43 #ifdef ASSERT 44 #ifdef ASSERT
44 45
45 #define SWEEP(nm) record_sweep(nm, __LINE__) 46 #define SWEEP(nm) record_sweep(nm, __LINE__)
142 // 1) alive -> not_entrant 143 // 1) alive -> not_entrant
143 // 2) not_entrant -> zombie 144 // 2) not_entrant -> zombie
144 // 3) zombie -> marked_for_reclamation 145 // 3) zombie -> marked_for_reclamation
145 146
146 int NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed 147 int NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed
147 jlong NMethodSweeper::_total_time_sweeping = 0; // Accumulated time sweeping 148 Tickspan NMethodSweeper::_total_time_sweeping; // Accumulated time sweeping
148 jlong NMethodSweeper::_total_time_this_sweep = 0; // Total time this sweep 149 Tickspan NMethodSweeper::_total_time_this_sweep; // Total time this sweep
149 jlong NMethodSweeper::_peak_sweep_time = 0; // Peak time for a full sweep 150 Tickspan NMethodSweeper::_peak_sweep_time; // Peak time for a full sweep
150 jlong NMethodSweeper::_peak_sweep_fraction_time = 0; // Peak time sweeping one fraction 151 Tickspan NMethodSweeper::_peak_sweep_fraction_time; // Peak time sweeping one fraction
151 int NMethodSweeper::_hotness_counter_reset_val = 0; 152 int NMethodSweeper::_hotness_counter_reset_val = 0;
152 153
153 154
154 class MarkActivationClosure: public CodeBlobClosure { 155 class MarkActivationClosure: public CodeBlobClosure {
155 public: 156 public:
207 if (!sweep_in_progress()) { 208 if (!sweep_in_progress()) {
208 _seen = 0; 209 _seen = 0;
209 _sweep_fractions_left = NmethodSweepFraction; 210 _sweep_fractions_left = NmethodSweepFraction;
210 _current = CodeCache::first_nmethod(); 211 _current = CodeCache::first_nmethod();
211 _traversals += 1; 212 _traversals += 1;
212 _total_time_this_sweep = 0; 213 _total_time_this_sweep = Tickspan();
213 214
214 if (PrintMethodFlushing) { 215 if (PrintMethodFlushing) {
215 tty->print_cr("### Sweep: stack traversal %d", _traversals); 216 tty->print_cr("### Sweep: stack traversal %d", _traversals);
216 } 217 }
217 Threads::nmethods_do(&mark_activation_closure); 218 Threads::nmethods_do(&mark_activation_closure);
301 _sweep_started = 0; 302 _sweep_started = 0;
302 } 303 }
303 } 304 }
304 305
305 void NMethodSweeper::sweep_code_cache() { 306 void NMethodSweeper::sweep_code_cache() {
306 jlong sweep_start_counter = os::elapsed_counter(); 307 Ticks sweep_start_counter = Ticks::now();
307 308
308 _flushed_count = 0; 309 _flushed_count = 0;
309 _zombified_count = 0; 310 _zombified_count = 0;
310 _marked_for_reclamation_count = 0; 311 _marked_for_reclamation_count = 0;
311 312
365 } 366 }
366 } 367 }
367 368
368 assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache"); 369 assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache");
369 370
370 jlong sweep_end_counter = os::elapsed_counter(); 371 const Ticks sweep_end_counter = Ticks::now();
371 jlong sweep_time = sweep_end_counter - sweep_start_counter; 372 const Tickspan sweep_time = sweep_end_counter - sweep_start_counter;
372 _total_time_sweeping += sweep_time; 373 _total_time_sweeping += sweep_time;
373 _total_time_this_sweep += sweep_time; 374 _total_time_this_sweep += sweep_time;
374 _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); 375 _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time);
375 _total_nof_methods_reclaimed += _flushed_count; 376 _total_nof_methods_reclaimed += _flushed_count;
376 377
387 event.commit(); 388 event.commit();
388 } 389 }
389 390
390 #ifdef ASSERT 391 #ifdef ASSERT
391 if(PrintMethodFlushing) { 392 if(PrintMethodFlushing) {
392 tty->print_cr("### sweeper: sweep time(%d): " INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time); 393 tty->print_cr("### sweeper: sweep time(%d): "
394 INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time.value());
393 } 395 }
394 #endif 396 #endif
395 397
396 if (_sweep_fractions_left == 1) { 398 if (_sweep_fractions_left == 1) {
397 _peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); 399 _peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep);