src/os/solaris/vm/os_solaris.cpp

Print this page
rev 6280 : [mq]: osx-clock

@@ -1393,13 +1393,18 @@
 // gethrtime can move backwards if read from one cpu and then a different cpu
 // getTimeNanos is guaranteed to not move backward on Solaris
 inline hrtime_t getTimeNanos() {
   if (VM_Version::supports_cx8()) {
     const hrtime_t now = gethrtime();
-    // Use atomic long load since 32-bit x86 uses 2 registers to keep long.
-    const hrtime_t prev = Atomic::load((volatile jlong*)&max_hrtime);
-    if (now <= prev)  return prev;   // same or retrograde time;
+    if (AssumeMonotonicOSTimers) {
+      return now;
+    }
+
+    const hrtime_t prev = max_hrtime;
+    if (now <= prev) {
+      return prev;   // same or retrograde time;
+    }
     const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev);
     assert(obsv >= prev, "invariant");   // Monotonicity
     // If the CAS succeeded then we're done and return "now".
     // If the CAS failed and the observed value "obs" is >= now then
     // we should return "obs".  If the CAS failed and now > obs > prv then