7117303: VM uses non-monotonic time source and complains that it is non-monotonic

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
This commit is contained in:
John Cuthbertson 2011-12-19 10:02:05 -08:00
parent 2768349b41
commit 870bea622a
10 changed files with 57 additions and 57 deletions

View file

@ -821,17 +821,15 @@ jlong os::javaTimeMillis() {
}
}
#define NANOS_PER_SEC CONST64(1000000000)
#define NANOS_PER_MILLISEC 1000000
jlong os::javaTimeNanos() {
if (!has_performance_count) {
return javaTimeMillis() * NANOS_PER_MILLISEC; // the best we can do.
return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do.
} else {
LARGE_INTEGER current_count;
QueryPerformanceCounter(&current_count);
double current = as_long(current_count);
double freq = performance_frequency;
jlong time = (jlong)((current/freq) * NANOS_PER_SEC);
jlong time = (jlong)((current/freq) * NANOSECS_PER_SEC);
return time;
}
}
@ -847,15 +845,15 @@ void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
info_ptr->may_skip_forward = true;
} else {
jlong freq = performance_frequency;
if (freq < NANOS_PER_SEC) {
if (freq < NANOSECS_PER_SEC) {
// the performance counter is 64 bits and we will
// be multiplying it -- so no wrap in 64 bits
info_ptr->max_value = ALL_64_BITS;
} else if (freq > NANOS_PER_SEC) {
} else if (freq > NANOSECS_PER_SEC) {
// use the max value the counter can reach to
// determine the max value which could be returned
julong max_counter = (julong)ALL_64_BITS;
info_ptr->max_value = (jlong)(max_counter / (freq / NANOS_PER_SEC));
info_ptr->max_value = (jlong)(max_counter / (freq / NANOSECS_PER_SEC));
} else {
// the performance counter is 64 bits and we will
// be using it directly -- so no wrap in 64 bits