diff 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
line wrap: on
line diff
--- a/src/share/vm/runtime/sweeper.cpp	Sat Nov 23 09:56:59 2013 +0100
+++ b/src/share/vm/runtime/sweeper.cpp	Sat Nov 23 12:25:13 2013 +0100
@@ -38,6 +38,7 @@
 #include "runtime/vm_operations.hpp"
 #include "trace/tracing.hpp"
 #include "utilities/events.hpp"
+#include "utilities/ticks.inline.hpp"
 #include "utilities/xmlstream.hpp"
 
 #ifdef ASSERT
@@ -144,10 +145,10 @@
                                                                //   3) zombie      -> marked_for_reclamation
 
 int   NMethodSweeper::_total_nof_methods_reclaimed     = 0;    // Accumulated nof methods flushed
-jlong NMethodSweeper::_total_time_sweeping             = 0;    // Accumulated time sweeping
-jlong NMethodSweeper::_total_time_this_sweep           = 0;    // Total time this sweep
-jlong NMethodSweeper::_peak_sweep_time                 = 0;    // Peak time for a full sweep
-jlong NMethodSweeper::_peak_sweep_fraction_time        = 0;    // Peak time sweeping one fraction
+Tickspan NMethodSweeper::_total_time_sweeping;                 // Accumulated time sweeping
+Tickspan NMethodSweeper::_total_time_this_sweep;               // Total time this sweep
+Tickspan NMethodSweeper::_peak_sweep_time;                     // Peak time for a full sweep
+Tickspan NMethodSweeper::_peak_sweep_fraction_time;            // Peak time sweeping one fraction
 int   NMethodSweeper::_hotness_counter_reset_val       = 0;
 
 
@@ -209,7 +210,7 @@
     _sweep_fractions_left = NmethodSweepFraction;
     _current = CodeCache::first_nmethod();
     _traversals += 1;
-    _total_time_this_sweep = 0;
+    _total_time_this_sweep = Tickspan();
 
     if (PrintMethodFlushing) {
       tty->print_cr("### Sweep: stack traversal %d", _traversals);
@@ -303,7 +304,7 @@
 }
 
 void NMethodSweeper::sweep_code_cache() {
-  jlong sweep_start_counter = os::elapsed_counter();
+  Ticks sweep_start_counter = Ticks::now();
 
   _flushed_count                = 0;
   _zombified_count              = 0;
@@ -367,8 +368,8 @@
 
   assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache");
 
-  jlong sweep_end_counter = os::elapsed_counter();
-  jlong sweep_time = sweep_end_counter - sweep_start_counter;
+  const Ticks sweep_end_counter = Ticks::now();
+  const Tickspan sweep_time = sweep_end_counter - sweep_start_counter;
   _total_time_sweeping  += sweep_time;
   _total_time_this_sweep += sweep_time;
   _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time);
@@ -389,7 +390,8 @@
 
 #ifdef ASSERT
   if(PrintMethodFlushing) {
-    tty->print_cr("### sweeper:      sweep time(%d): " INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time);
+    tty->print_cr("### sweeper:      sweep time(%d): "
+      INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time.value());
   }
 #endif