comparison src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.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 4dfb2df418f2
children aa3d708d67c4
comparison
equal deleted inserted replaced
4711:adedfbbf0360 4712:e7dead7e90af
670 old_gen->compact(); 670 old_gen->compact();
671 young_gen->compact(); 671 young_gen->compact();
672 } 672 }
673 673
674 jlong PSMarkSweep::millis_since_last_gc() { 674 jlong PSMarkSweep::millis_since_last_gc() {
675 jlong ret_val = os::javaTimeMillis() - _time_of_last_gc; 675 // We need a monotonically non-deccreasing time in ms but
676 // os::javaTimeMillis() does not guarantee monotonicity.
677 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
678 jlong ret_val = now - _time_of_last_gc;
676 // XXX See note in genCollectedHeap::millis_since_last_gc(). 679 // XXX See note in genCollectedHeap::millis_since_last_gc().
677 if (ret_val < 0) { 680 if (ret_val < 0) {
678 NOT_PRODUCT(warning("time warp: %d", ret_val);) 681 NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
679 return 0; 682 return 0;
680 } 683 }
681 return ret_val; 684 return ret_val;
682 } 685 }
683 686
684 void PSMarkSweep::reset_millis_since_last_gc() { 687 void PSMarkSweep::reset_millis_since_last_gc() {
685 _time_of_last_gc = os::javaTimeMillis(); 688 // We need a monotonically non-deccreasing time in ms but
686 } 689 // os::javaTimeMillis() does not guarantee monotonicity.
690 _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
691 }