Mercurial > hg > truffle
diff src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 4712:e7dead7e90af
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not (and cannot) guarantee monotonicity, in GC code to an equivalent expression that uses os::javaTimeNanos(). os::javaTimeNanos is guaranteed monotonically non-decreasing if the underlying platform provides a monotonic time source. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by: dholmes, ysr
author | johnc |
---|---|
date | Mon, 19 Dec 2011 10:02:05 -0800 |
parents | 7913e93dca52 |
children | aa3d708d67c4 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Dec 16 11:40:00 2011 -0800 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Mon Dec 19 10:02:05 2011 -0800 @@ -3398,17 +3398,22 @@ } jlong PSParallelCompact::millis_since_last_gc() { - jlong ret_val = os::javaTimeMillis() - _time_of_last_gc; + // We need a monotonically non-deccreasing time in ms but + // os::javaTimeMillis() does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + jlong ret_val = now - _time_of_last_gc; // XXX See note in genCollectedHeap::millis_since_last_gc(). if (ret_val < 0) { - NOT_PRODUCT(warning("time warp: %d", ret_val);) + NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);) return 0; } return ret_val; } void PSParallelCompact::reset_millis_since_last_gc() { - _time_of_last_gc = os::javaTimeMillis(); + // We need a monotonically non-deccreasing time in ms but + // os::javaTimeMillis() does not guarantee monotonicity. + _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; } ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full()