mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
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:
parent
9387db9948
commit
2641db378b
6 changed files with 117 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue