hotspot/src/share/vm/gc/g1/youngList.cpp
author tschatzl
Wed, 25 Nov 2015 14:43:29 +0100
changeset 34300 6075c1e0e913
parent 33203 e1034e5d33eb
child 35061 be6025ebffea
permissions -rw-r--r--
8136679: JFR event for adaptive IHOP Reviewed-by: tbenson, mgerdin, sangheki, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33203
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     1
/*
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    26
#include "gc/g1/g1CollectedHeap.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    27
#include "gc/g1/g1CollectorPolicy.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    28
#include "gc/g1/heapRegion.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    29
#include "gc/g1/heapRegion.inline.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    30
#include "gc/g1/heapRegionRemSet.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    31
#include "gc/g1/youngList.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    32
#include "utilities/ostream.hpp"
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    33
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    34
YoungList::YoungList(G1CollectedHeap* g1h) :
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    35
    _g1h(g1h), _head(NULL), _length(0), _last_sampled_rs_lengths(0),
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    36
    _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    37
  guarantee(check_list_empty(false), "just making sure...");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    38
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    39
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    40
void YoungList::push_region(HeapRegion *hr) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    41
  assert(!hr->is_young(), "should not already be young");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    42
  assert(hr->get_next_young_region() == NULL, "cause it should!");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    43
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    44
  hr->set_next_young_region(_head);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    45
  _head = hr;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    46
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    47
  _g1h->g1_policy()->set_region_eden(hr, (int) _length);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    48
  ++_length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    49
}
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
void YoungList::add_survivor_region(HeapRegion* hr) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    52
  assert(hr->is_survivor(), "should be flagged as survivor region");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    53
  assert(hr->get_next_young_region() == NULL, "cause it should!");
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
  hr->set_next_young_region(_survivor_head);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    56
  if (_survivor_head == NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    57
    _survivor_tail = hr;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    58
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    59
  _survivor_head = hr;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    60
  ++_survivor_length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    61
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    62
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    63
void YoungList::empty_list(HeapRegion* list) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    64
  while (list != NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    65
    HeapRegion* next = list->get_next_young_region();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    66
    list->set_next_young_region(NULL);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    67
    list->uninstall_surv_rate_group();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    68
    // This is called before a Full GC and all the non-empty /
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    69
    // non-humongous regions at the end of the Full GC will end up as
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    70
    // old anyway.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    71
    list->set_old();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    72
    list = next;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    73
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    74
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    75
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    76
void YoungList::empty_list() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    77
  assert(check_list_well_formed(), "young list should be well formed");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    78
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    79
  empty_list(_head);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    80
  _head = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    81
  _length = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    82
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    83
  empty_list(_survivor_head);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    84
  _survivor_head = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    85
  _survivor_tail = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    86
  _survivor_length = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    87
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    88
  _last_sampled_rs_lengths = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    89
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    90
  assert(check_list_empty(false), "just making sure...");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    91
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    92
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    93
bool YoungList::check_list_well_formed() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    94
  bool ret = true;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    95
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    96
  uint length = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    97
  HeapRegion* curr = _head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    98
  HeapRegion* last = NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
    99
  while (curr != NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   100
    if (!curr->is_young()) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   101
      gclog_or_tty->print_cr("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " "
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   102
                             "incorrectly tagged (y: %d, surv: %d)",
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   103
                             p2i(curr->bottom()), p2i(curr->end()),
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   104
                             curr->is_young(), curr->is_survivor());
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   105
      ret = false;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   106
    }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   107
    ++length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   108
    last = curr;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   109
    curr = curr->get_next_young_region();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   110
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   111
  ret = ret && (length == _length);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   112
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   113
  if (!ret) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   114
    gclog_or_tty->print_cr("### YOUNG LIST seems not well formed!");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   115
    gclog_or_tty->print_cr("###   list has %u entries, _length is %u",
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   116
                           length, _length);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   117
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   118
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   119
  return ret;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   120
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   121
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   122
bool YoungList::check_list_empty(bool check_sample) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   123
  bool ret = true;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   124
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   125
  if (_length != 0) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   126
    gclog_or_tty->print_cr("### YOUNG LIST should have 0 length, not %u",
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   127
                  _length);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   128
    ret = false;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   129
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   130
  if (check_sample && _last_sampled_rs_lengths != 0) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   131
    gclog_or_tty->print_cr("### YOUNG LIST has non-zero last sampled RS lengths");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   132
    ret = false;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   133
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   134
  if (_head != NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   135
    gclog_or_tty->print_cr("### YOUNG LIST does not have a NULL head");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   136
    ret = false;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   137
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   138
  if (!ret) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   139
    gclog_or_tty->print_cr("### YOUNG LIST does not seem empty");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   140
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   141
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   142
  return ret;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   143
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   144
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   145
void
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   146
YoungList::rs_length_sampling_init() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   147
  _sampled_rs_lengths = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   148
  _curr               = _head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   149
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   150
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   151
bool
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   152
YoungList::rs_length_sampling_more() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   153
  return _curr != NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   154
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   155
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   156
void
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   157
YoungList::rs_length_sampling_next() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   158
  assert( _curr != NULL, "invariant" );
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   159
  size_t rs_length = _curr->rem_set()->occupied();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   160
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   161
  _sampled_rs_lengths += rs_length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   162
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   163
  // The current region may not yet have been added to the
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   164
  // incremental collection set (it gets added when it is
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   165
  // retired as the current allocation region).
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   166
  if (_curr->in_collection_set()) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   167
    // Update the collection set policy information for this region
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   168
    _g1h->g1_policy()->update_incremental_cset_info(_curr, rs_length);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   169
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   170
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   171
  _curr = _curr->get_next_young_region();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   172
  if (_curr == NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   173
    _last_sampled_rs_lengths = _sampled_rs_lengths;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   174
    // gclog_or_tty->print_cr("last sampled RS lengths = %d", _last_sampled_rs_lengths);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   175
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   176
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   177
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   178
void
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   179
YoungList::reset_auxilary_lists() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   180
  guarantee( is_empty(), "young list should be empty" );
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   181
  assert(check_list_well_formed(), "young list should be well formed");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   182
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   183
  // Add survivor regions to SurvRateGroup.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   184
  _g1h->g1_policy()->note_start_adding_survivor_regions();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   185
  _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   186
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   187
  int young_index_in_cset = 0;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   188
  for (HeapRegion* curr = _survivor_head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   189
       curr != NULL;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   190
       curr = curr->get_next_young_region()) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   191
    _g1h->g1_policy()->set_region_survivor(curr, young_index_in_cset);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   192
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   193
    // The region is a non-empty survivor so let's add it to
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   194
    // the incremental collection set for the next evacuation
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   195
    // pause.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   196
    _g1h->g1_policy()->add_region_to_incremental_cset_rhs(curr);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   197
    young_index_in_cset += 1;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   198
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   199
  assert((uint) young_index_in_cset == _survivor_length, "post-condition");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   200
  _g1h->g1_policy()->note_stop_adding_survivor_regions();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   201
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   202
  _head   = _survivor_head;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   203
  _length = _survivor_length;
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   204
  if (_survivor_head != NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   205
    assert(_survivor_tail != NULL, "cause it shouldn't be");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   206
    assert(_survivor_length > 0, "invariant");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   207
    _survivor_tail->set_next_young_region(NULL);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   208
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   209
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   210
  // Don't clear the survivor list handles until the start of
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   211
  // the next evacuation pause - we need it in order to re-tag
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   212
  // the survivor regions from this evacuation pause as 'young'
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   213
  // at the start of the next.
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   214
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   215
  _g1h->g1_policy()->finished_recalculating_age_indexes(false /* is_survivors */);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   216
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   217
  assert(check_list_well_formed(), "young list should be well formed");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   218
}
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   219
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   220
void YoungList::print() {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   221
  HeapRegion* lists[] = {_head,   _survivor_head};
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   222
  const char* names[] = {"YOUNG", "SURVIVOR"};
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   223
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   224
  for (uint list = 0; list < ARRAY_SIZE(lists); ++list) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   225
    gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   226
    HeapRegion *curr = lists[list];
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   227
    if (curr == NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   228
      gclog_or_tty->print_cr("  empty");
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   229
    }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   230
    while (curr != NULL) {
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   231
      gclog_or_tty->print_cr("  " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d",
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   232
                             HR_FORMAT_PARAMS(curr),
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   233
                             p2i(curr->prev_top_at_mark_start()),
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   234
                             p2i(curr->next_top_at_mark_start()),
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   235
                             curr->age_in_surv_rate_group_cond());
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   236
      curr = curr->get_next_young_region();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   237
    }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   238
  }
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   239
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   240
  gclog_or_tty->cr();
e1034e5d33eb 8139427: Break out YoungList to own class.
david
parents:
diff changeset
   241
}