Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1CardCounts.hpp @ 20450:fa6c442c59ee
8057827: notify an obj when allocation context stats are available
Reviewed-by: mikael, jmasa, tschatzl
author | jcoomes |
---|---|
date | Wed, 10 Sep 2014 16:06:53 -0700 |
parents | 1f1d373cd044 |
children | e7d0505c8a30 |
rev | line source |
---|---|
10246 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12241
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
10246 | 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 | |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP | |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP | |
27 | |
20337 | 28 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp" |
10246 | 29 #include "memory/allocation.hpp" |
30 #include "runtime/virtualspace.hpp" | |
31 #include "utilities/globalDefinitions.hpp" | |
32 | |
33 class CardTableModRefBS; | |
20337 | 34 class G1CardCounts; |
10246 | 35 class G1CollectedHeap; |
20337 | 36 class G1RegionToSpaceMapper; |
10246 | 37 class HeapRegion; |
38 | |
20337 | 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); | |
46 }; | |
47 | |
10246 | 48 // Table to track the number of times a card has been refined. Once |
49 // a card has been refined a certain number of times, it is | |
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> { | |
20337 | 56 G1CardCountsMappingChangedListener _listener; |
57 | |
10246 | 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() { | |
20337 | 77 return has_reserved_count_table(); |
10246 | 78 } |
79 | |
80 size_t ptr_2_card_num(const jbyte* card_ptr) { | |
81 assert(card_ptr >= _ct_bot, | |
12241
9cb63cd234a0
8024671: G1 generates assert error messages in product builds
shade
parents:
10289
diff
changeset
|
82 err_msg("Invalid card pointer: " |
10246 | 83 "card_ptr: " PTR_FORMAT ", " |
84 "_ct_bot: " PTR_FORMAT, | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12241
diff
changeset
|
85 p2i(card_ptr), p2i(_ct_bot))); |
10246 | 86 size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte)); |
20337 | 87 assert(card_num >= 0 && card_num < _reserved_max_card_num, |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12241
diff
changeset
|
88 err_msg("card pointer out of range: " PTR_FORMAT, p2i(card_ptr))); |
10246 | 89 return card_num; |
90 } | |
91 | |
92 jbyte* card_num_2_ptr(size_t card_num) { | |
20337 | 93 assert(card_num >= 0 && card_num < _reserved_max_card_num, |
12241
9cb63cd234a0
8024671: G1 generates assert error messages in product builds
shade
parents:
10289
diff
changeset
|
94 err_msg("card num out of range: "SIZE_FORMAT, card_num)); |
10246 | 95 return (jbyte*) (_ct_bot + card_num); |
96 } | |
97 | |
98 // Clear the counts table for the given (exclusive) index range. | |
99 void clear_range(size_t from_card_num, size_t to_card_num); | |
100 | |
101 public: | |
102 G1CardCounts(G1CollectedHeap* g1h); | |
103 | |
20337 | 104 void initialize(G1RegionToSpaceMapper* mapper); |
10246 | 105 |
106 // Increments the refinement count for the given card. | |
107 // Returns the pre-increment count value. | |
108 uint add_card_count(jbyte* card_ptr); | |
109 | |
110 // Returns true if the given count is high enough to be considered | |
111 // 'hot'; false otherwise. | |
112 bool is_hot(uint count); | |
113 | |
114 // Clears the card counts for the cards spanned by the region | |
115 void clear_region(HeapRegion* hr); | |
116 | |
20337 | 117 // Clears the card counts for the cards spanned by the MemRegion |
118 void clear_range(MemRegion mr); | |
119 | |
10246 | 120 // Clear the entire card counts table during GC. |
121 void clear_all(); | |
122 }; | |
123 | |
124 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP |