RFR: 8069016: Add BarrierSet downcast support

Kim Barrett kim.barrett at oracle.com
Mon Feb 16 23:16:38 UTC 2015


Please review this change that ensures all barrier set downcasts are
checked when running in debug mode. This is a step toward some
cleanups and changes to the barrier set class hierarchy, improving
error checking and making it easier to find places where assumptions
are being made that would be invalidated by changes.

I will need a sponsor for this change.

CR:
https://bugs.openjdk.java.net/browse/JDK-8069016

Webrev:
http://cr.openjdk.java.net/~kbarrett/8069016/webrev.00

Changeset includes

* New FakeRttiSupport utility class template.  This provides some
  infrastructure for performing the checks. It is intended to
  ease similar changes in some other class hierarchies where ad hoc
  checking or unchecked downcasts are common, such as the
  CollectedHeap hierarchy.

* Re-implementation of BarrierSet's "fake RTTI" to use
  FakeRttiSupport.  As part of this, BarrierSet::is_a() is now just an
  integer bit test rather than a virtual function that needs to walk
  up the class hierarchy.

* Adds barrier_set_cast function template, which uses the improved
  is_a() test to assert the validity of the conversion.

* Adds BarrierSet::CardTableForRS barrier set name tag, so that all
  existing classes have an associated tag.

* Changes all C-style barrier set downcasts to use barrier_set_cast.  In
  most cases, this is just a mechanical translation.  In some cases some
  existing checks have been eliminated in favor of the check made by the
  new mechanism.  In a few places more extensive changes have been made,
  as detailed below:

** In various g1_write_barrier_post() implementations, downcast to
   G1SATBCardTableLoggingModRefBS rather than G1SATBCardTableModRefBS,
   since the code being generated includes logging.

** In PSMarkSweep::invoke_no_policy(), don't bother conditionalizing
   clear/invalidate of barrier set on whether the bs is a modrefbs; it
   always will be for parallel scavenge collector.  Similarly in
   PSParallelCompact::post_compact().

** For VerifyLiveClosure constructor initialization of _bs member, just
   use barrier_set_cast of the heap's barrier. If the previous is_a
   conditionalization failed it would just lead to a later segfault
   when attempting to dereference through the NULL _bs member.

Testing:
JPRT, local JTREG of test/[closed]/{gc,runtime},
local RefWorkload using CMS, G1, ParallelOld




More information about the hotspot-gc-dev mailing list