src/hotspot/share/gc/g1/g1SurvivorRegions.cpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 47216 71c04702a3d5
child 54467 0c5d713cf43f
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     1
/*
37039
79f62b89a7a6 8151178: Move the collection set out of the G1 collector policy
mgerdin
parents: 36365
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     4
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     8
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    13
 * accompanied this code).
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    14
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    18
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    21
 * questions.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    22
 *
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    23
 */
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    24
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    25
#include "precompiled.hpp"
38186
ccaa890f8617 8155943: Move G1Eden/SurvivorRegions into their own source files
mgerdin
parents: 38183
diff changeset
    26
#include "gc/g1/g1SurvivorRegions.hpp"
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    27
#include "gc/g1/heapRegion.hpp"
38162
4e2c3433a3ae 8150393: Maintain the set of survivor regions in an array between GCs
mgerdin
parents: 38109
diff changeset
    28
#include "utilities/growableArray.hpp"
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    29
#include "utilities/debug.hpp"
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    30
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    31
G1SurvivorRegions::G1SurvivorRegions() : _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapRegion*>(8, true, mtGC)) {}
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    32
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    33
void G1SurvivorRegions::add(HeapRegion* hr) {
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    34
  assert(hr->is_survivor(), "should be flagged as survivor region");
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    35
  _regions->append(hr);
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    36
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    37
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    38
uint G1SurvivorRegions::length() const {
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    39
  return (uint)_regions->length();
38162
4e2c3433a3ae 8150393: Maintain the set of survivor regions in an array between GCs
mgerdin
parents: 38109
diff changeset
    40
}
4e2c3433a3ae 8150393: Maintain the set of survivor regions in an array between GCs
mgerdin
parents: 38109
diff changeset
    41
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    42
void G1SurvivorRegions::convert_to_eden() {
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    43
  for (GrowableArrayIterator<HeapRegion*> it = _regions->begin();
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    44
       it != _regions->end();
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    45
       ++it) {
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    46
    HeapRegion* hr = *it;
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    47
    hr->set_eden_pre_gc();
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    48
  }
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    49
  clear();
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    50
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    51
38183
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    52
void G1SurvivorRegions::clear() {
cb68e4923223 8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents: 38162
diff changeset
    53
  _regions->clear();
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    54
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    55