src/share/vm/memory/referenceProcessor.cpp

Print this page
rev 2869 : 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() mostly guarantees montonicity depending on the underlying OS implementation and, as a result, a better alternative. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by:

*** 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,52 ---- void referenceProcessor_init() { ReferenceProcessor::init_statics(); } void ReferenceProcessor::init_statics() { ! // os::javaTimeMillis() does not guarantee monotonicity. ! 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) { --- 150,162 ---- } 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. ! ! // os::javaTimeMillis() does not guarantee monotonicity. ! 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) {