8231457: Asserts on AIX because os::elapsed_counter() is not monotonic
authorazeller
Sat, 28 Sep 2019 17:52:07 -0400
changeset 58390 4107e5a422b6
parent 58389 31524b016783
child 58391 ff29dba057f9
child 58393 0df9370fee29
8231457: Asserts on AIX because os::elapsed_counter() is not monotonic Summary: replace gettimeofday with javaTimeNanos Reviewed-by: dholmes, stuefe
src/hotspot/os/aix/os_aix.cpp
--- 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();
 }