RFR(M): 8077413: Avoid use of Universe::heap() inside collectors
Stefan Karlsson
stefan.karlsson at oracle.com
Fri Apr 10 15:09:01 UTC 2015
On 2015-04-10 16:45, Per Liden wrote:
> Hi,
>
> 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:
> http://cr.openjdk.java.net/~pliden/8077413/webrev.0/
Looks good.
StefanK
>
> If someone finds it easier to review in smaller chunks, I've split it
> in three parts.
>
> Changes made to G1:
> http://cr.openjdk.java.net/~pliden/8077413/webrev.0-g1_cleanup/
>
> Changes made to GenCollectedHeap-type collectors:
> http://cr.openjdk.java.net/~pliden/8077413/webrev.0-gencollected_heap_cleanup/
>
>
> Changes made to ParallelScavenge:
> http://cr.openjdk.java.net/~pliden/8077413/webrev.0-parallelscavenge_cleanup/
>
>
>
> 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()
>
> cheers,
> /Per
More information about the hotspot-gc-dev
mailing list