Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8077413

Avoid use of Universe::heap() inside collectors

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
      gc
    • Resolved In Build:
      b64
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        The following pattern is fairly common in the GC code:

        ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
        assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");

        Code for a specific collector should use its heap() function to avoid casting and asserting. The example above should be replaced by:

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  pliden Per Liden
                  Reporter:
                  pliden Per Liden
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: