--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Wed Jul 05 22:07:34 2017 +0200
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Fri Aug 19 17:19:47 2016 +0200
@@ -1256,21 +1256,21 @@
};
jlong GenCollectedHeap::millis_since_last_gc() {
- // javaTimeNanos() is guaranteed to be monotonically non-decreasing
- // provided the underlying platform provides such a time source
- // (and it is bug free). So we still have to guard against getting
- // back a time later than 'now'.
+ // We need a monotonically non-decreasing time in ms but
+ // os::javaTimeMillis() does not guarantee monotonicity.
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
GenTimeOfLastGCClosure tolgc_cl(now);
// iterate over generations getting the oldest
// time that a generation was collected
generation_iterate(&tolgc_cl, false);
+ // javaTimeNanos() is guaranteed to be monotonically non-decreasing
+ // provided the underlying platform provides such a time source
+ // (and it is bug free). So we still have to guard against getting
+ // back a time later than 'now'.
jlong retVal = now - tolgc_cl.time();
if (retVal < 0) {
- log_warning(gc)("Detected clock going backwards. "
- "Milliseconds since last GC would be " JLONG_FORMAT
- ". returning zero instead.", retVal);
+ NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);)
return 0;
}
return retVal;