author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49455 | 848864ed9b17 |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
17327 | 1 |
/* |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
17327 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_G1_G1CARDCOUNTS_HPP |
26 |
#define SHARE_VM_GC_G1_G1CARDCOUNTS_HPP |
|
17327 | 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 | 29 |
#include "gc/g1/g1RegionToSpaceMapper.hpp" |
17327 | 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 | 32 |
#include "utilities/globalDefinitions.hpp" |
33 |
||
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49164
diff
changeset
|
34 |
class CardTableBarrierSet; |
26160 | 35 |
class G1CardCounts; |
17327 | 36 |
class G1CollectedHeap; |
26160 | 37 |
class G1RegionToSpaceMapper; |
17327 | 38 |
class HeapRegion; |
39 |
||
26160 | 40 |
class G1CardCountsMappingChangedListener : public G1MappingChangedListener { |
41 |
private: |
|
42 |
G1CardCounts* _counts; |
|
43 |
public: |
|
44 |
void set_cardcounts(G1CardCounts* counts) { _counts = counts; } |
|
45 |
||
27149 | 46 |
virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); |
26160 | 47 |
}; |
48 |
||
17327 | 49 |
// Table to track the number of times a card has been refined. Once |
50 |
// a card has been refined a certain number of times, it is |
|
51 |
// considered 'hot' and its refinement is delayed by inserting the |
|
52 |
// card into the hot card cache. The card will then be refined when |
|
53 |
// it is evicted from the hot card cache, or when the hot card cache |
|
54 |
// is 'drained' during the next evacuation pause. |
|
55 |
||
56 |
class G1CardCounts: public CHeapObj<mtGC> { |
|
26160 | 57 |
G1CardCountsMappingChangedListener _listener; |
58 |
||
17327 | 59 |
G1CollectedHeap* _g1h; |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47216
diff
changeset
|
60 |
G1CardTable* _ct; |
17327 | 61 |
|
62 |
// The table of counts |
|
63 |
jubyte* _card_counts; |
|
64 |
||
65 |
// Max capacity of the reserved space for the counts table |
|
66 |
size_t _reserved_max_card_num; |
|
67 |
||
68 |
// CardTable bottom. |
|
69 |
const jbyte* _ct_bot; |
|
70 |
||
71 |
// Returns true if the card counts table has been reserved. |
|
72 |
bool has_reserved_count_table() { return _card_counts != NULL; } |
|
73 |
||
74 |
// Returns true if the card counts table has been reserved and committed. |
|
75 |
bool has_count_table() { |
|
26160 | 76 |
return has_reserved_count_table(); |
17327 | 77 |
} |
78 |
||
79 |
size_t ptr_2_card_num(const jbyte* card_ptr) { |
|
80 |
assert(card_ptr >= _ct_bot, |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
81 |
"Invalid card pointer: " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
82 |
"card_ptr: " PTR_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
83 |
"_ct_bot: " PTR_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
84 |
p2i(card_ptr), p2i(_ct_bot)); |
17327 | 85 |
size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte)); |
29580
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
27149
diff
changeset
|
86 |
assert(card_num < _reserved_max_card_num, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
87 |
"card pointer out of range: " PTR_FORMAT, p2i(card_ptr)); |
17327 | 88 |
return card_num; |
89 |
} |
|
90 |
||
91 |
jbyte* card_num_2_ptr(size_t card_num) { |
|
29580
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
27149
diff
changeset
|
92 |
assert(card_num < _reserved_max_card_num, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
93 |
"card num out of range: " SIZE_FORMAT, card_num); |
17327 | 94 |
return (jbyte*) (_ct_bot + card_num); |
95 |
} |
|
96 |
||
97 |
// Clear the counts table for the given (exclusive) index range. |
|
98 |
void clear_range(size_t from_card_num, size_t to_card_num); |
|
99 |
||
100 |
public: |
|
101 |
G1CardCounts(G1CollectedHeap* g1h); |
|
102 |
||
30565
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29580
diff
changeset
|
103 |
// 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
|
104 |
// that covers mem_region_words words. |
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29580
diff
changeset
|
105 |
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
|
106 |
|
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29580
diff
changeset
|
107 |
// 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
|
108 |
// corresponds to. |
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29580
diff
changeset
|
109 |
static size_t heap_map_factor(); |
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29580
diff
changeset
|
110 |
|
26160 | 111 |
void initialize(G1RegionToSpaceMapper* mapper); |
17327 | 112 |
|
113 |
// Increments the refinement count for the given card. |
|
114 |
// Returns the pre-increment count value. |
|
115 |
uint add_card_count(jbyte* card_ptr); |
|
116 |
||
117 |
// Returns true if the given count is high enough to be considered |
|
118 |
// 'hot'; false otherwise. |
|
119 |
bool is_hot(uint count); |
|
120 |
||
121 |
// Clears the card counts for the cards spanned by the region |
|
122 |
void clear_region(HeapRegion* hr); |
|
123 |
||
26160 | 124 |
// Clears the card counts for the cards spanned by the MemRegion |
125 |
void clear_range(MemRegion mr); |
|
126 |
||
17327 | 127 |
// Clear the entire card counts table during GC. |
128 |
void clear_all(); |
|
129 |
}; |
|
130 |
||
30764 | 131 |
#endif // SHARE_VM_GC_G1_G1CARDCOUNTS_HPP |