src/share/vm/memory/referenceProcessor.cpp
Print this page
rev 2870 : 7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not guarantee montonicity, in GC code to os::javaTimeNanos() with a suitable conversion factor. os::javaTimeNanos is guaranteed monotonic if the underlying platform provides a monotonic timesource. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by: dholmes
*** 41,51 ****
void referenceProcessor_init() {
ReferenceProcessor::init_statics();
}
void ReferenceProcessor::init_statics() {
! jlong now = os::javaTimeMillis();
// Initialize the soft ref timestamp clock.
_soft_ref_timestamp_clock = now;
// Also update the soft ref clock in j.l.r.SoftReference
java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
--- 41,53 ----
void referenceProcessor_init() {
ReferenceProcessor::init_statics();
}
void ReferenceProcessor::init_statics() {
! // We need a montonically increasing time in ms but os::javaTimeMillis()
! // does not guarantee montonicity.
! jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
// Initialize the soft ref timestamp clock.
_soft_ref_timestamp_clock = now;
// Also update the soft ref clock in j.l.r.SoftReference
java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
*** 149,159 ****
}
void ReferenceProcessor::update_soft_ref_master_clock() {
// Update (advance) the soft ref master clock field. This must be done
// after processing the soft ref list.
! jlong now = os::javaTimeMillis();
jlong soft_ref_clock = java_lang_ref_SoftReference::clock();
assert(soft_ref_clock == _soft_ref_timestamp_clock, "soft ref clocks out of sync");
NOT_PRODUCT(
if (now < _soft_ref_timestamp_clock) {
--- 151,164 ----
}
void ReferenceProcessor::update_soft_ref_master_clock() {
// Update (advance) the soft ref master clock field. This must be done
// after processing the soft ref list.
!
! // We need a montonically increasing time in ms but os::javaTimeMillis()
! // does not guarantee montonicity.
! jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
jlong soft_ref_clock = java_lang_ref_SoftReference::clock();
assert(soft_ref_clock == _soft_ref_timestamp_clock, "soft ref clocks out of sync");
NOT_PRODUCT(
if (now < _soft_ref_timestamp_clock) {