Atomic::add(jlong) broken?

Roman Kennke rkennke at
Tue Feb 2 20:55:35 UTC 2016


I believe Atomic::add(jlong) is broken. The comment above it says:

  // Atomically add to a location, return updated value

Except in atomic.cpp, add(jlong) returns the old value.

It causes quite some headscratching on my side :-)

Fixing this seems easy. I am wonder if any code uses this though, maybe
it should be removed altogether?

On the other hand, the implementation there uses a CAS-based loop. I
think an easier fix would be to cast to size_t or intptr_t and use the
atomic impl of that.

What do you think?


More information about the hotspot-dev mailing list