RFR: 8134797: Remove explicit casts in CollectorPolicy hierarchy

Kim Barrett kim.barrett at oracle.com
Thu Sep 3 03:30:49 UTC 2015


On Sep 1, 2015, at 4:05 AM, Thomas Schatzl <thomas.schatzl at oracle.com> wrote:
> 
> Hi,
> 
> On Mon, 2015-08-31 at 21:04 -0400, Kim Barrett wrote:
>> Please review this change to eliminate explicit casts within the
>> CollectorPolicy hierarchy.  All of the casts being eliminated were
>> C-style casts; there are no C++ style casts in this hierarchy.
>> 
>> For downcasts to GenCollectorPolicy* the policy was being obtained
>> from a GenCollectedHeap, so we just use gen_policy instead of an
>> unchecked downcast of collector_policy.
>> 
>> For the remaining downcast (to ConcurrentMarkSweepPolicy*) we now
>> assert the corresponding is_xxx_policy and use as_xxx_policy to
>> perform the conversion.
>> 
>> Changed the explicit upcasts to CollectorPolicy* to implict
>> conversions.  For the problematic one, moved to a scope where
>> G1CollectorPolicy is complete, so the now implicit conversion works.
>> I'm kind of surprised that one didn't cause obvious problems.
> 

> - please fix the indentation of method arguments in e.g.
> genCollectedHeap.cpp:184 and genCollectedHeap.cpp:823 before pushing.

Oops on line 184 - I should have fixed the indentation when I made that change.

I don’t see anything to fix at 823 - that’s a pretty common indentation style.

> - as Per already mentioned, g1CollectorPolicy.hpp is indirectly
> included by g1CollectedHeap.o (via g1CollectedHeap.inline.hpp?), but
> should be either made explicit, or the method kept in the cpp file. I
> have no preference either way.

See response to Per.

> I do not need a re-review for these changes.

Thanks for looking at this.




More information about the hotspot-gc-dev mailing list