6863420: os::javaTimeNanos() go backward on Solaris x86

Use new atomic long load method Atomic::load() to load max_hrtime.

Reviewed-by: never, ysr, johnc, phh, dcubed, acorn
This commit is contained in:
Vladimir Kozlov 2009-07-26 16:40:14 -07:00
parent 9387db9948
commit 2641db378b
6 changed files with 117 additions and 1 deletions

View file

@ -1643,7 +1643,8 @@ inline hrtime_t oldgetTimeNanos() {
inline hrtime_t getTimeNanos() {
if (VM_Version::supports_cx8()) {
const hrtime_t now = gethrtime();
const hrtime_t prev = max_hrtime;
// 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;
const hrtime_t obsv = Atomic::cmpxchg(now, (volatile jlong*)&max_hrtime, prev);
assert(obsv >= prev, "invariant"); // Monotonicity