RFR (XS): 8212753: Improve oopDesc::forward_to_atomic

Thomas Schatzl thomas.schatzl at oracle.com
Mon Oct 22 13:02:13 UTC 2018


Hi all,

  can I have reviews for this micro-optimization that de-clutters
oopDesc::forward_to_atomic used in CMS and G1?

Reasons for this change:

- the mark is reloaded in the method although all collectors could pass
in their current copy (the mark is a volatile member, so it can't be
optimized away) 
- it checks whether the mark is already set (i.e. already forwarded)
before doing the CAS, and after doing the CAS. 
The former is waste of time because forwarding undo-statistics show
that the number of failures (i.e. an object has already been forwarded)
is extremely rate. 
- the check after the CAS whether the mark is set is superfluous,
because after the CAS, independent of whether it was successful or not,
we know that the mark must have been forwarded. 

There is no particular performance change. Just removes needlessly
executed code.

(Just before somebody asks: the two asserts in the changed
forward_to_atomic() method are conditionalized on CMS because it will
CAS in a special value into the mark word that do not fit the rest of
the condition to "reserve" it for old gen promotion).

CR:
https://bugs.openjdk.java.net/browse/JDK-8212753
Webrev:
http://cr.openjdk.java.net/~tschatzl/8212753/webrev/
Testing:
hs-tier1-3

Thanks,
  Thomas



More information about the hotspot-gc-dev mailing list