hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.cpp
author shade
Fri, 13 Sep 2013 07:57:13 +0200
changeset 19994 ca520adcee02
parent 18496 78b3897aa229
child 20309 7445302daff6
permissions -rw-r--r--
8024671: G1 generates assert error messages in product builds Reviewed-by: brutisso, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     1
/*
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     4
 *
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     8
 *
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    13
 * accompanied this code).
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    14
 *
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    18
 *
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    21
 * questions.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    22
 *
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    23
 */
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    24
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    25
#include "precompiled.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    26
#include "gc_implementation/g1/g1CardCounts.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    27
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    28
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    29
#include "gc_implementation/g1/g1GCPhaseTimes.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    30
#include "memory/cardTableModRefBS.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    31
#include "services/memTracker.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    32
#include "utilities/copy.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    33
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    34
void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    35
  if (has_count_table()) {
19994
ca520adcee02 8024671: G1 generates assert error messages in product builds
shade
parents: 18496
diff changeset
    36
    assert(from_card_num >= 0 && from_card_num < _committed_max_card_num,
ca520adcee02 8024671: G1 generates assert error messages in product builds
shade
parents: 18496
diff changeset
    37
           err_msg("from card num out of range: "SIZE_FORMAT, from_card_num));
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    38
    assert(from_card_num < to_card_num,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    39
           err_msg("Wrong order? from: " SIZE_FORMAT ", to: "SIZE_FORMAT,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    40
                   from_card_num, to_card_num));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    41
    assert(to_card_num <= _committed_max_card_num,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    42
           err_msg("to card num out of range: "
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    43
                   "to: "SIZE_FORMAT ", "
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    44
                   "max: "SIZE_FORMAT,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    45
                   to_card_num, _committed_max_card_num));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    46
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    47
    to_card_num = MIN2(_committed_max_card_num, to_card_num);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    48
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    49
    Copy::fill_to_bytes(&_card_counts[from_card_num], (to_card_num - from_card_num));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    50
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    51
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    52
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    53
G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    54
  _g1h(g1h), _card_counts(NULL),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    55
  _reserved_max_card_num(0), _committed_max_card_num(0),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    56
  _committed_size(0) {}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    57
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    58
void G1CardCounts::initialize() {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    59
  assert(_g1h->max_capacity() > 0, "initialization order");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    60
  assert(_g1h->capacity() == 0, "initialization order");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    61
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    62
  if (G1ConcRSHotCardLimit > 0) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    63
    // The max value we can store in the counts table is
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    64
    // max_jubyte. Guarantee the value of the hot
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    65
    // threshold limit is no more than this.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    66
    guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    67
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    68
    ModRefBarrierSet* bs = _g1h->mr_bs();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    69
    guarantee(bs->is_a(BarrierSet::CardTableModRef), "Precondition");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    70
    _ct_bs = (CardTableModRefBS*)bs;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    71
    _ct_bot = _ct_bs->byte_for_const(_g1h->reserved_region().start());
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    72
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    73
    // Allocate/Reserve the counts table
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    74
    size_t reserved_bytes = _g1h->max_capacity();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    75
    _reserved_max_card_num = reserved_bytes >> CardTableModRefBS::card_shift;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    76
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    77
    size_t reserved_size = _reserved_max_card_num * sizeof(jbyte);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    78
    ReservedSpace rs(ReservedSpace::allocation_align_size_up(reserved_size));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    79
    if (!rs.is_reserved()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    80
      warning("Could not reserve enough space for the card counts table");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    81
      guarantee(!has_reserved_count_table(), "should be NULL");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    82
      return;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    83
    }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    84
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    85
    MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    86
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    87
    _card_counts_storage.initialize(rs, 0);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    88
    _card_counts = (jubyte*) _card_counts_storage.low();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    89
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    90
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    91
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    92
void G1CardCounts::resize(size_t heap_capacity) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    93
  // Expand the card counts table to handle a heap with the given capacity.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    94
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    95
  if (!has_reserved_count_table()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    96
    // Don't expand if we failed to reserve the card counts table.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    97
    return;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    98
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    99
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   100
  assert(_committed_size ==
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   101
         ReservedSpace::allocation_align_size_up(_committed_size),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   102
         err_msg("Unaligned? committed_size: " SIZE_FORMAT, _committed_size));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   103
17394
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   104
  // Verify that the committed space for the card counts matches our
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   105
  // committed max card num. Note for some allocation alignments, the
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   106
  // amount of space actually committed for the counts table will be able
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   107
  // to span more cards than the number spanned by the maximum heap.
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   108
  size_t prev_committed_size = _committed_size;
17394
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   109
  size_t prev_committed_card_num = committed_to_card_num(prev_committed_size);
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   110
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   111
  assert(prev_committed_card_num == _committed_max_card_num,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   112
         err_msg("Card mismatch: "
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   113
                 "prev: " SIZE_FORMAT ", "
17394
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   114
                 "committed: "SIZE_FORMAT", "
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   115
                 "reserved: "SIZE_FORMAT,
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   116
                 prev_committed_card_num, _committed_max_card_num, _reserved_max_card_num));
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   117
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   118
  size_t new_size = (heap_capacity >> CardTableModRefBS::card_shift) * sizeof(jbyte);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   119
  size_t new_committed_size = ReservedSpace::allocation_align_size_up(new_size);
17394
156f30e1d09a 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
johnc
parents: 17327
diff changeset
   120
  size_t new_committed_card_num = committed_to_card_num(new_committed_size);
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   121
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   122
  if (_committed_max_card_num < new_committed_card_num) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   123
    // we need to expand the backing store for the card counts
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   124
    size_t expand_size = new_committed_size - prev_committed_size;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   125
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   126
    if (!_card_counts_storage.expand_by(expand_size)) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   127
      warning("Card counts table backing store commit failure");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   128
      return;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   129
    }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   130
    assert(_card_counts_storage.committed_size() == new_committed_size,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   131
           "expansion commit failure");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   132
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   133
    _committed_size = new_committed_size;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   134
    _committed_max_card_num = new_committed_card_num;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   135
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   136
    clear_range(prev_committed_card_num, _committed_max_card_num);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   137
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   138
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   139
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   140
uint G1CardCounts::add_card_count(jbyte* card_ptr) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   141
  // Returns the number of times the card has been refined.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   142
  // If we failed to reserve/commit the counts table, return 0.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   143
  // If card_ptr is beyond the committed end of the counts table,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   144
  // return 0.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   145
  // Otherwise return the actual count.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   146
  // Unless G1ConcRSHotCardLimit has been set appropriately,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   147
  // returning 0 will result in the card being considered
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   148
  // cold and will be refined immediately.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   149
  uint count = 0;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   150
  if (has_count_table()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   151
    size_t card_num = ptr_2_card_num(card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   152
    if (card_num < _committed_max_card_num) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   153
      count = (uint) _card_counts[card_num];
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   154
      if (count < G1ConcRSHotCardLimit) {
18496
78b3897aa229 8017070: G1: assert(_card_counts[card_num] <= G1ConcRSHotCardLimit) failed
johnc
parents: 17394
diff changeset
   155
        _card_counts[card_num] =
78b3897aa229 8017070: G1: assert(_card_counts[card_num] <= G1ConcRSHotCardLimit) failed
johnc
parents: 17394
diff changeset
   156
          (jubyte)(MIN2((uintx)(_card_counts[card_num] + 1), G1ConcRSHotCardLimit));
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   157
      }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   158
    }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   159
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   160
  return count;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   161
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   162
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   163
bool G1CardCounts::is_hot(uint count) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   164
  return (count >= G1ConcRSHotCardLimit);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   165
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   166
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   167
void G1CardCounts::clear_region(HeapRegion* hr) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   168
  assert(!hr->isHumongous(), "Should have been cleared");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   169
  if (has_count_table()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   170
    HeapWord* bottom = hr->bottom();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   171
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   172
    // We use the last address in hr as hr could be the
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   173
    // last region in the heap. In which case trying to find
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   174
    // the card for hr->end() will be an OOB accesss to the
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   175
    // card table.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   176
    HeapWord* last = hr->end() - 1;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   177
    assert(_g1h->g1_committed().contains(last),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   178
           err_msg("last not in committed: "
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   179
                   "last: " PTR_FORMAT ", "
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   180
                   "committed: [" PTR_FORMAT ", " PTR_FORMAT ")",
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   181
                   last,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   182
                   _g1h->g1_committed().start(),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   183
                   _g1h->g1_committed().end()));
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   184
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   185
    const jbyte* from_card_ptr = _ct_bs->byte_for_const(bottom);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   186
    const jbyte* last_card_ptr = _ct_bs->byte_for_const(last);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   187
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   188
#ifdef ASSERT
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   189
    HeapWord* start_addr = _ct_bs->addr_for(from_card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   190
    assert(start_addr == hr->bottom(), "alignment");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   191
    HeapWord* last_addr = _ct_bs->addr_for(last_card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   192
    assert((last_addr + CardTableModRefBS::card_size_in_words) == hr->end(), "alignment");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   193
#endif // ASSERT
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   194
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   195
    // Clear the counts for the (exclusive) card range.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   196
    size_t from_card_num = ptr_2_card_num(from_card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   197
    size_t to_card_num = ptr_2_card_num(last_card_ptr) + 1;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   198
    clear_range(from_card_num, to_card_num);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   199
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   200
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   201
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   202
void G1CardCounts::clear_all() {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   203
  assert(SafepointSynchronize::is_at_safepoint(), "don't call this otherwise");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   204
  clear_range((size_t)0, _committed_max_card_num);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   205
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   206
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   207
G1CardCounts::~G1CardCounts() {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   208
  if (has_reserved_count_table()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   209
    _card_counts_storage.release();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   210
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   211
}
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   212