JDK-7125281 : G1: heap expansion code is replicated
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: hs23
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-12-27
  • Updated: 2013-09-18
  • Resolved: 2012-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u4Fixed 8Fixed hs23Fixed
Description
Recently, we accidentally replicated the code that does heap expansion at the end of a GC:

        init_mutator_alloc_region();

        {
          size_t expand_bytes = g1_policy()->expansion_amount();
          if (expand_bytes > 0) {
            size_t bytes_before = capacity();
            if (!expand(expand_bytes)) {
              // We failed to expand the heap so let's verify that
              // committed/uncommitted amount match the backing store
              assert(capacity() == _g1_storage.committed_size(), "committed size mismatch");
              assert(max_capacity() == _g1_storage.reserved_size(), "reserved size mismatch");
            }
          }
        }

  ...

      {
        size_t expand_bytes = g1_policy()->expansion_amount();
        if (expand_bytes > 0) {
          size_t bytes_before = capacity();
          // No need for an ergo verbose message here,
          // expansion_amount() does this when it returns a value > 0.
          if (!expand(expand_bytes)) {
            // We failed to expand the heap so let's verify that
            // committed/uncommitted amount match the backing store
            assert(capacity() == _g1_storage.committed_size(), "committed size mismatch");
            assert(max_capacity() == _g1_storage.reserved_size(), "reserved size mismatch");
          }
        }
      }

This looks to have happened due to a mis-merge. I _think_ it's the second copy that should be deleted (after the comment from it is also applied to the first copy).
The original intention was to move the heap expansion code "up" so it is indeed the second copy that should be deleted.

Comments
EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/97c00e21fecb
2012-03-22

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/97c00e21fecb
2012-01-18

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-gc/hotspot/rev/97c00e21fecb
2012-01-10