src/os/solaris/vm/os_solaris.cpp

changeset 1329
665be97e8704
parent 1126
956304450e80
child 1552
95e9083cf4a7
equal deleted inserted replaced
1328:dd0a4e1e219b 1329: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

mercurial