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

@@ -1672,11 +1672,10 @@
   void* r = NULL;
   return thr_getspecific((thread_key_t)index, &r) != 0 ? NULL : r;
-const int NANOSECS_PER_MILLISECS = 1000000;
 // gethrtime can move backwards if read from one cpu and then a different cpu
 // getTimeNanos is guaranteed to not move backward on Solaris
 // local spinloop created as faster for a CAS on an int than
 // a CAS on a 64bit jlong. Also Atomic::cmpxchg for jlong is not
 // supported on sparc v8 or pre supports_cx8 intel boxes.

@@ -1801,11 +1800,11 @@
 // Used internally for comparisons only
 // getTimeMillis guaranteed to not move backwards on Solaris
 jlong getTimeMillis() {
   jlong nanotime = getTimeNanos();
-  return (jlong)(nanotime / NANOSECS_PER_MILLISECS);
+  return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
 jlong os::javaTimeMillis() {
   timeval t;

@@ -6062,14 +6061,11 @@
  * on the condvar. Contention seen when trying to park implies that someone
  * is unparking you, so don't wait. And spurious returns are fine, so there
  * is no need to track notifications.
-#define NANOSECS_PER_SEC 1000000000
-#define NANOSECS_PER_MILLISEC 1000000
 #define MAX_SECS 100000000
  * This code is common to linux and solaris and will be moved to a
  * common place in dolphin.
  * The passed in time value is either a relative time in nanoseconds