RFR(M): 8077413: Avoid use of Universe::heap() inside collectors
stefan.karlsson at oracle.com
Fri Apr 10 15:09:01 UTC 2015
On 2015-04-10 16:45, Per Liden wrote:
> This patch cleans up the usage of Universe::heap() in our collectors.
> A typical pattern we have is code like this:
> ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
> assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
> This patch changes this to:
> ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
> There are also other places where Universe::heap() is used, even when
> it's clear what we are inside, e.g. ParallelScavenge-related code. We
> should be using ParallelScavengeHeap::heap() here instead.
> Universe::heap() should (for clarity) only be used by code that
> doesn't know/care which collector we are currently using.
> Bug: https://bugs.openjdk.java.net/browse/JDK-8077413
> Complete webrev:
> If someone finds it easier to review in smaller chunks, I've split it
> in three parts.
> Changes made to G1:
> Changes made to GenCollectedHeap-type collectors:
> Changes made to ParallelScavenge:
> I have two more cleanups in this area, which will be sent out
> separately. These are:
> JDK-8077415 : Remove duplicate variables holding the CollectedHeap
> JDK-8077417 : Cleanup of Universe::initialize_heap()
More information about the hotspot-gc-dev