comparison src/os/solaris/vm/os_solaris.cpp @ 4712:e7dead7e90af

7117303: VM uses non-monotonic time source and complains that it is non-monotonic Summary: 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
author johnc
date Mon, 19 Dec 2011 10:02:05 -0800
parents 36b057451829
children 4b18532913c7
comparison
equal deleted inserted replaced
4711:adedfbbf0360 4712:e7dead7e90af
1672 void* r = NULL; 1672 void* r = NULL;
1673 return thr_getspecific((thread_key_t)index, &r) != 0 ? NULL : r; 1673 return thr_getspecific((thread_key_t)index, &r) != 0 ? NULL : r;
1674 } 1674 }
1675 1675
1676 1676
1677 const int NANOSECS_PER_MILLISECS = 1000000;
1678 // gethrtime can move backwards if read from one cpu and then a different cpu 1677 // gethrtime can move backwards if read from one cpu and then a different cpu
1679 // getTimeNanos is guaranteed to not move backward on Solaris 1678 // getTimeNanos is guaranteed to not move backward on Solaris
1680 // local spinloop created as faster for a CAS on an int than 1679 // local spinloop created as faster for a CAS on an int than
1681 // a CAS on a 64bit jlong. Also Atomic::cmpxchg for jlong is not 1680 // a CAS on a 64bit jlong. Also Atomic::cmpxchg for jlong is not
1682 // supported on sparc v8 or pre supports_cx8 intel boxes. 1681 // supported on sparc v8 or pre supports_cx8 intel boxes.
1801 1800
1802 // Used internally for comparisons only 1801 // Used internally for comparisons only
1803 // getTimeMillis guaranteed to not move backwards on Solaris 1802 // getTimeMillis guaranteed to not move backwards on Solaris
1804 jlong getTimeMillis() { 1803 jlong getTimeMillis() {
1805 jlong nanotime = getTimeNanos(); 1804 jlong nanotime = getTimeNanos();
1806 return (jlong)(nanotime / NANOSECS_PER_MILLISECS); 1805 return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
1807 } 1806 }
1808 1807
1809 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis 1808 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
1810 jlong os::javaTimeMillis() { 1809 jlong os::javaTimeMillis() {
1811 timeval t; 1810 timeval t;
6062 * on the condvar. Contention seen when trying to park implies that someone 6061 * on the condvar. Contention seen when trying to park implies that someone
6063 * is unparking you, so don't wait. And spurious returns are fine, so there 6062 * is unparking you, so don't wait. And spurious returns are fine, so there
6064 * is no need to track notifications. 6063 * is no need to track notifications.
6065 */ 6064 */
6066 6065
6067 #define NANOSECS_PER_SEC 1000000000
6068 #define NANOSECS_PER_MILLISEC 1000000
6069 #define MAX_SECS 100000000 6066 #define MAX_SECS 100000000
6070
6071 /* 6067 /*
6072 * This code is common to linux and solaris and will be moved to a 6068 * This code is common to linux and solaris and will be moved to a
6073 * common place in dolphin. 6069 * common place in dolphin.
6074 * 6070 *
6075 * The passed in time value is either a relative time in nanoseconds 6071 * The passed in time value is either a relative time in nanoseconds