src/share/vm/runtime/sweeper.cpp
Print this page
rev 5685 : 8028128: Add a type safe alternative for working with counter based data
Reviewed-by:
@@ -36,10 +36,11 @@
#include "runtime/os.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/vm_operations.hpp"
#include "trace/tracing.hpp"
#include "utilities/events.hpp"
+#include "utilities/ticks.inline.hpp"
#include "utilities/xmlstream.hpp"
#ifdef ASSERT
#define SWEEP(nm) record_sweep(nm, __LINE__)
@@ -142,14 +143,14 @@
// 1) alive -> not_entrant
// 2) not_entrant -> zombie
// 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;
class MarkActivationClosure: public CodeBlobClosure {
public:
@@ -207,11 +208,11 @@
if (!sweep_in_progress()) {
_seen = 0;
_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);
}
Threads::nmethods_do(&mark_activation_closure);
@@ -300,11 +301,11 @@
_sweep_started = 0;
}
}
void NMethodSweeper::sweep_code_cache() {
- jlong sweep_start_counter = os::elapsed_counter();
+ Ticks sweep_start_counter = Ticks::now();
_flushed_count = 0;
_zombified_count = 0;
_marked_for_reclamation_count = 0;
@@ -364,12 +365,12 @@
}
}
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);
_total_nof_methods_reclaimed += _flushed_count;
@@ -386,11 +387,12 @@
event.commit();
}
#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
if (_sweep_fractions_left == 1) {
_peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep);