src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 54465 c4f16445675a
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     1
/*
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     4
 *
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     8
 *
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    14
 *
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    18
 *
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    21
 * questions.
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    22
 *
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    23
 */
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    24
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    26
#include "gc/g1/g1CollectionSetCandidates.hpp"
53704
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents: 53703
diff changeset
    27
#include "gc/g1/g1CollectionSetChooser.hpp"
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    28
#include "gc/g1/heapRegion.inline.hpp"
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    29
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    30
void G1CollectionSetCandidates::remove(uint num_regions) {
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    31
  assert(num_regions <= num_remaining(), "Trying to remove more regions (%u) than available (%u)", num_regions, num_remaining());
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    32
  for (uint i = 0; i < num_regions; i++) {
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    33
    _remaining_reclaimable_bytes -= at(_front_idx)->reclaimable_bytes();
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    34
    _front_idx++;
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    35
  }
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    36
}
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    37
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    38
void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    39
  for (uint i = _front_idx; i < _num_regions; i++) {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    40
    HeapRegion* r = _regions[i];
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    41
    if (cl->do_heap_region(r)) {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    42
      cl->set_incomplete();
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    43
      break;
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    44
    }
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    45
  }
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    46
}
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    47
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    48
#ifndef PRODUCT
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    49
void G1CollectionSetCandidates::verify() const {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    50
  guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions);
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53704
diff changeset
    51
  uint idx = _front_idx;
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    52
  size_t sum_of_reclaimable_bytes = 0;
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    53
  HeapRegion *prev = NULL;
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    54
  for (; idx < _num_regions; idx++) {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    55
    HeapRegion *cur = _regions[idx];
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    56
    guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx);
53704
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents: 53703
diff changeset
    57
    guarantee(G1CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index());
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    58
    if (prev != NULL) {
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    59
      guarantee(prev->gc_efficiency() >= cur->gc_efficiency(),
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    60
                "GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f",
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    61
                prev->hrm_index(), prev->gc_efficiency(), cur->hrm_index(), cur->gc_efficiency());
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    62
    }
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    63
    sum_of_reclaimable_bytes += cur->reclaimable_bytes();
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    64
    prev = cur;
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    65
  }
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    66
  guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes,
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    67
            "Inconsistent remaining_reclaimable bytes, remaining " SIZE_FORMAT " calculated " SIZE_FORMAT,
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    68
            _remaining_reclaimable_bytes, sum_of_reclaimable_bytes);
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    69
}
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff changeset
    70
#endif // !PRODUCT