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
25 #ifndef SHARE_VM_GC_G1_G1CARDCOUNTS_HPP
26 #define SHARE_VM_GC_G1_G1CARDCOUNTS_HPP
27
28 #include "gc/g1/g1RegionToSpaceMapper.hpp"
29 #include "memory/allocation.hpp"
30 #include "memory/virtualspace.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 class CardTableModRefBS;
34 class G1CardCounts;
35 class G1CollectedHeap;
36 class G1RegionToSpaceMapper;
37 class HeapRegion;
38
39 class G1CardCountsMappingChangedListener : public G1MappingChangedListener {
40 private:
41 G1CardCounts* _counts;
42 public:
43 void set_cardcounts(G1CardCounts* counts) { _counts = counts; }
44
45 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
46 };
47
50 // considered 'hot' and its refinement is delayed by inserting the
51 // card into the hot card cache. The card will then be refined when
52 // it is evicted from the hot card cache, or when the hot card cache
53 // is 'drained' during the next evacuation pause.
54
55 class G1CardCounts: public CHeapObj<mtGC> {
56 G1CardCountsMappingChangedListener _listener;
57
58 G1CollectedHeap* _g1h;
59
60 // The table of counts
61 jubyte* _card_counts;
62
63 // Max capacity of the reserved space for the counts table
64 size_t _reserved_max_card_num;
65
66 // CardTable bottom.
67 const jbyte* _ct_bot;
68
69 // Barrier set
70 CardTableModRefBS* _ct_bs;
71
72 // Returns true if the card counts table has been reserved.
73 bool has_reserved_count_table() { return _card_counts != NULL; }
74
75 // Returns true if the card counts table has been reserved and committed.
76 bool has_count_table() {
77 return has_reserved_count_table();
78 }
79
80 size_t ptr_2_card_num(const jbyte* card_ptr) {
81 assert(card_ptr >= _ct_bot,
82 "Invalid card pointer: "
83 "card_ptr: " PTR_FORMAT ", "
84 "_ct_bot: " PTR_FORMAT,
85 p2i(card_ptr), p2i(_ct_bot));
86 size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
87 assert(card_num < _reserved_max_card_num,
88 "card pointer out of range: " PTR_FORMAT, p2i(card_ptr));
89 return card_num;
90 }
|
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
25 #ifndef SHARE_VM_GC_G1_G1CARDCOUNTS_HPP
26 #define SHARE_VM_GC_G1_G1CARDCOUNTS_HPP
27
28 #include "gc/g1/g1CardTable.hpp"
29 #include "gc/g1/g1RegionToSpaceMapper.hpp"
30 #include "memory/allocation.hpp"
31 #include "memory/virtualspace.hpp"
32 #include "utilities/globalDefinitions.hpp"
33
34 class CardTableModRefBS;
35 class G1CardCounts;
36 class G1CollectedHeap;
37 class G1RegionToSpaceMapper;
38 class HeapRegion;
39
40 class G1CardCountsMappingChangedListener : public G1MappingChangedListener {
41 private:
42 G1CardCounts* _counts;
43 public:
44 void set_cardcounts(G1CardCounts* counts) { _counts = counts; }
45
46 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
47 };
48
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> {
57 G1CardCountsMappingChangedListener _listener;
58
59 G1CollectedHeap* _g1h;
60
61 // The table of counts
62 jubyte* _card_counts;
63
64 // Max capacity of the reserved space for the counts table
65 size_t _reserved_max_card_num;
66
67 // CardTable bottom.
68 const jbyte* _ct_bot;
69
70 // Barrier set
71 G1CardTable* _ct;
72
73 // Returns true if the card counts table has been reserved.
74 bool has_reserved_count_table() { return _card_counts != NULL; }
75
76 // Returns true if the card counts table has been reserved and committed.
77 bool has_count_table() {
78 return has_reserved_count_table();
79 }
80
81 size_t ptr_2_card_num(const jbyte* card_ptr) {
82 assert(card_ptr >= _ct_bot,
83 "Invalid card pointer: "
84 "card_ptr: " PTR_FORMAT ", "
85 "_ct_bot: " PTR_FORMAT,
86 p2i(card_ptr), p2i(_ct_bot));
87 size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
88 assert(card_num < _reserved_max_card_num,
89 "card pointer out of range: " PTR_FORMAT, p2i(card_ptr));
90 return card_num;
91 }
|