src/hotspot/share/gc/g1/g1CardCounts.hpp
author tschatzl
Wed, 13 Mar 2019 21:01:56 +0100
changeset 54110 f4f0dce5d0bb
parent 53244 9807daeb47c4
permissions -rw-r--r--
8220301: Remove jbyte use in CardTable Summary: Use CardTable::CardValue aliased to uint8_t instead. Reviewed-by: kbarrett, shade
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
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49455
diff changeset
     2
 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
17327
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49455
diff changeset
    25
#ifndef SHARE_GC_G1_G1CARDCOUNTS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49455
diff changeset
    26
#define SHARE_GC_G1_G1CARDCOUNTS_HPP
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    27
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
    28
#include "gc/g1/g1CardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30579
diff changeset
    29
#include "gc/g1/g1RegionToSpaceMapper.hpp"
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    30
#include "memory/allocation.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 29580
diff changeset
    31
#include "memory/virtualspace.hpp"
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    33
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    34
class CardTableBarrierSet;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    35
class G1CardCounts;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    36
class G1CollectedHeap;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    37
class G1RegionToSpaceMapper;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    38
class HeapRegion;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    39
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    40
class G1CardCountsMappingChangedListener : public G1MappingChangedListener {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    41
 private:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    42
  G1CardCounts* _counts;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    43
 public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    44
  void set_cardcounts(G1CardCounts* counts) { _counts = counts; }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    45
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26160
diff changeset
    46
  virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    47
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    48
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    49
// Table to track the number of times a card has been refined. Once
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    50
// a card has been refined a certain number of times, it is
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    51
// considered 'hot' and its refinement is delayed by inserting the
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    52
// card into the hot card cache. The card will then be refined when
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    53
// it is evicted from the hot card cache, or when the hot card cache
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    54
// is 'drained' during the next evacuation pause.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    55
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    56
class G1CardCounts: public CHeapObj<mtGC> {
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    57
public:
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    58
  typedef CardTable::CardValue CardValue;
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    59
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    60
private:
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    61
  G1CardCountsMappingChangedListener _listener;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    62
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    63
  G1CollectedHeap* _g1h;
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
    64
  G1CardTable*     _ct;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    65
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    66
  // The table of counts
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    67
  uint8_t* _card_counts;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    68
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    69
  // Max capacity of the reserved space for the counts table
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    70
  size_t _reserved_max_card_num;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    71
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    72
  // CardTable bottom.
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    73
  const CardValue* _ct_bot;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    74
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    75
  // Returns true if the card counts table has been reserved.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    76
  bool has_reserved_count_table() { return _card_counts != NULL; }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    77
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    78
  // Returns true if the card counts table has been reserved and committed.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    79
  bool has_count_table() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    80
    return has_reserved_count_table();
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    81
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    82
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    83
  size_t ptr_2_card_num(const CardValue* card_ptr) {
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    84
    assert(card_ptr >= _ct_bot,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    85
           "Invalid card pointer: "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    86
           "card_ptr: " PTR_FORMAT ", "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    87
           "_ct_bot: " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    88
           p2i(card_ptr), p2i(_ct_bot));
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    89
    size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(CardValue));
29580
a67a581cfe11 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents: 27149
diff changeset
    90
    assert(card_num < _reserved_max_card_num,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    91
           "card pointer out of range: " PTR_FORMAT, p2i(card_ptr));
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    92
    return card_num;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    93
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
    94
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    95
  CardValue* card_num_2_ptr(size_t card_num) {
29580
a67a581cfe11 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents: 27149
diff changeset
    96
    assert(card_num < _reserved_max_card_num,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    97
           "card num out of range: " SIZE_FORMAT, card_num);
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
    98
    return (CardValue*) (_ct_bot + card_num);
17327
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
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   101
  // Clear the counts table for the given (exclusive) index range.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   102
  void 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
   103
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   104
 public:
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   105
  G1CardCounts(G1CollectedHeap* g1h);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   106
30565
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   107
  // Return the number of slots needed for a card counts table
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   108
  // that covers mem_region_words words.
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   109
  static size_t compute_size(size_t mem_region_size_in_words);
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   110
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   111
  // Returns how many bytes of the heap a single byte of the card counts table
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   112
  // corresponds to.
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   113
  static size_t heap_map_factor();
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 29580
diff changeset
   114
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
   115
  void initialize(G1RegionToSpaceMapper* mapper);
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   116
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   117
  // Increments the refinement count for the given card.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   118
  // Returns the pre-increment count value.
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 53244
diff changeset
   119
  uint add_card_count(CardValue* card_ptr);
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   120
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   121
  // Returns true if the given count is high enough to be considered
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   122
  // 'hot'; false otherwise.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   123
  bool is_hot(uint count);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   124
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   125
  // Clears the card counts for the cards spanned by the region
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   126
  void clear_region(HeapRegion* hr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   127
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
   128
  // Clears the card counts for the cards spanned by the MemRegion
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
   129
  void clear_range(MemRegion mr);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
   130
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   131
  // Clear the entire card counts table during GC.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   132
  void clear_all();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   133
};
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
diff changeset
   134
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49455
diff changeset
   135
#endif // SHARE_GC_G1_G1CARDCOUNTS_HPP