|
1 /* |
|
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
|
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_G1_HEAPREGIONREMSET_INLINE_HPP |
|
26 #define SHARE_VM_GC_G1_HEAPREGIONREMSET_INLINE_HPP |
|
27 |
|
28 #include "gc/g1/heapRegion.inline.hpp" |
|
29 #include "gc/g1/heapRegionRemSet.hpp" |
|
30 #include "gc/g1/sparsePRT.hpp" |
|
31 #include "utilities/bitMap.inline.hpp" |
|
32 |
|
33 template <class Closure> |
|
34 inline void HeapRegionRemSet::iterate_prts(Closure& cl) { |
|
35 _other_regions.iterate(cl); |
|
36 } |
|
37 |
|
38 inline void PerRegionTable::add_card_work(CardIdx_t from_card, bool par) { |
|
39 if (!_bm.at(from_card)) { |
|
40 if (par) { |
|
41 if (_bm.par_set_bit(from_card)) { |
|
42 Atomic::inc(&_occupied); |
|
43 } |
|
44 } else { |
|
45 _bm.set_bit(from_card); |
|
46 _occupied++; |
|
47 } |
|
48 } |
|
49 } |
|
50 |
|
51 inline void PerRegionTable::add_reference_work(OopOrNarrowOopStar from, bool par) { |
|
52 // Must make this robust in case "from" is not in "_hr", because of |
|
53 // concurrency. |
|
54 |
|
55 HeapRegion* loc_hr = hr(); |
|
56 // If the test below fails, then this table was reused concurrently |
|
57 // with this operation. This is OK, since the old table was coarsened, |
|
58 // and adding a bit to the new table is never incorrect. |
|
59 if (loc_hr->is_in_reserved(from)) { |
|
60 CardIdx_t from_card = OtherRegionsTable::card_within_region(from, loc_hr); |
|
61 add_card_work(from_card, par); |
|
62 } |
|
63 } |
|
64 |
|
65 inline void PerRegionTable::add_card(CardIdx_t from_card_index) { |
|
66 add_card_work(from_card_index, /*parallel*/ true); |
|
67 } |
|
68 |
|
69 inline void PerRegionTable::seq_add_card(CardIdx_t from_card_index) { |
|
70 add_card_work(from_card_index, /*parallel*/ false); |
|
71 } |
|
72 |
|
73 inline void PerRegionTable::add_reference(OopOrNarrowOopStar from) { |
|
74 add_reference_work(from, /*parallel*/ true); |
|
75 } |
|
76 |
|
77 inline void PerRegionTable::seq_add_reference(OopOrNarrowOopStar from) { |
|
78 add_reference_work(from, /*parallel*/ false); |
|
79 } |
|
80 |
|
81 inline void PerRegionTable::init(HeapRegion* hr, bool clear_links_to_all_list) { |
|
82 if (clear_links_to_all_list) { |
|
83 set_next(NULL); |
|
84 set_prev(NULL); |
|
85 } |
|
86 _collision_list_next = NULL; |
|
87 _occupied = 0; |
|
88 _bm.clear(); |
|
89 // Make sure that the bitmap clearing above has been finished before publishing |
|
90 // this PRT to concurrent threads. |
|
91 OrderAccess::release_store(&_hr, hr); |
|
92 } |
|
93 |
|
94 template <class Closure> |
|
95 void OtherRegionsTable::iterate(Closure& cl) { |
|
96 if (_n_coarse_entries > 0) { |
|
97 BitMap::idx_t cur = _coarse_map.get_next_one_offset(0); |
|
98 while (cur != _coarse_map.size()) { |
|
99 cl.next_coarse_prt((uint)cur); |
|
100 cur = _coarse_map.get_next_one_offset(cur + 1); |
|
101 } |
|
102 } |
|
103 { |
|
104 PerRegionTable* cur = _first_all_fine_prts; |
|
105 while (cur != NULL) { |
|
106 cl.next_fine_prt(cur->hr()->hrm_index(), cur->bm()); |
|
107 cur = cur->next(); |
|
108 } |
|
109 } |
|
110 { |
|
111 SparsePRTBucketIter iter(&_sparse_table); |
|
112 SparsePRTEntry* cur; |
|
113 while (iter.has_next(cur)) { |
|
114 cl.next_sparse_prt(cur->r_ind(), cur->cards(), cur->num_valid_cards()); |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 #endif // SHARE_VM_GC_G1_HEAPREGIONREMSET_INLINE_HPP |