8231457: Asserts on AIX because os::elapsed_counter() is not monotonic
Summary: replace gettimeofday with javaTimeNanos
Reviewed-by: dholmes, stuefe
--- a/src/hotspot/os/aix/os_aix.cpp Sat Sep 28 12:33:34 2019 -0700
+++ b/src/hotspot/os/aix/os_aix.cpp Sat Sep 28 17:52:07 2019 -0400
@@ -1027,17 +1027,15 @@
// Time since start-up in seconds to a fine granularity.
// Used by VMSelfDestructTimer and the MemProfiler.
double os::elapsedTime() {
- return (double)(os::elapsed_counter()) * 0.000001;
+ return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution
}
jlong os::elapsed_counter() {
- timeval time;
- int status = gettimeofday(&time, NULL);
- return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
+ return javaTimeNanos() - initial_time_count;
}
jlong os::elapsed_frequency() {
- return (1000 * 1000);
+ return NANOSECS_PER_SEC; // nanosecond resolution
}
bool os::supports_vtime() { return true; }
@@ -3498,7 +3496,7 @@
// _main_thread points to the thread that created/loaded the JVM.
Aix::_main_thread = pthread_self();
- initial_time_count = os::elapsed_counter();
+ initial_time_count = javaTimeNanos();
os::Posix::init();
}