Mercurial > hg > graal-jvmci-8
comparison src/os/solaris/vm/os_solaris.cpp @ 894:665be97e8704
6863420: os::javaTimeNanos() go backward on Solaris x86
Summary: Use new atomic long load method Atomic::load() to load max_hrtime.
Reviewed-by: never, ysr, johnc, phh, dcubed, acorn
author | kvn |
---|---|
date | Sun, 26 Jul 2009 16:40:14 -0700 |
parents | 956304450e80 |
children | 95e9083cf4a7 |
comparison
equal
deleted
inserted
replaced
893:dd0a4e1e219b | 894:665be97e8704 |
---|---|
1641 // gethrtime can move backwards if read from one cpu and then a different cpu | 1641 // gethrtime can move backwards if read from one cpu and then a different cpu |
1642 // getTimeNanos is guaranteed to not move backward on Solaris | 1642 // getTimeNanos is guaranteed to not move backward on Solaris |
1643 inline hrtime_t getTimeNanos() { | 1643 inline hrtime_t getTimeNanos() { |
1644 if (VM_Version::supports_cx8()) { | 1644 if (VM_Version::supports_cx8()) { |
1645 const hrtime_t now = gethrtime(); | 1645 const hrtime_t now = gethrtime(); |
1646 const hrtime_t prev = max_hrtime; | 1646 // Use atomic long load since 32-bit x86 uses 2 registers to keep long. |
1647 const hrtime_t prev = Atomic::load((volatile jlong*)&max_hrtime); | |
1647 if (now <= prev) return prev; // same or retrograde time; | 1648 if (now <= prev) return prev; // same or retrograde time; |
1648 const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev); | 1649 const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev); |
1649 assert(obsv >= prev, "invariant"); // Monotonicity | 1650 assert(obsv >= prev, "invariant"); // Monotonicity |
1650 // If the CAS succeeded then we're done and return "now". | 1651 // If the CAS succeeded then we're done and return "now". |
1651 // If the CAS failed and the observed value "obs" is >= now then | 1652 // If the CAS failed and the observed value "obs" is >= now then |