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

Avoid G1 write barriers on newly allocated objects

    XMLWordPrintable

Details

    • b37

    Backports

      Description

        G1 requires pre and post barriers when writing references. They can under different circumstances be filtered to be avoided and the compiler is able to remove some of them and others are dynamically filtered during runtime to avoid doing the actual barrier.

        For newly allocated objects it should be possible to avoid the barrier if it can be proven the reference write is the first write to the object and no safe point exists between the allocation and the write itself.

        This pattern can for example be found in some objects where a reference is written to the object as part of the constructor, please look at the Node class in HashMap for a specific example.

        A small microbenchmark trying to mimic the Node class allocation and write shows that it is possible to prove the barrier is not required in this case and performance gets closer to what the parallel GC is able to achieve in this case. See attached images for a graphical comparison, the 3 fields version is most similar to the Node class which has three fields being written.

        Attachments

          Issue Links

            Activity

              People

                sfriberg Staffan Friberg (Inactive)
                sfriberg Staffan Friberg (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: