annotate src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp @ 6862:8a5ea0a9ccc4

7127708: G1: change task num types from int to uint in concurrent mark Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich. Reviewed-by: johnc Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author johnc
date Sat, 06 Oct 2012 01:17:44 -0700
parents d2a62e0f25eb
children b9a9ed0f8eeb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
1983
c760f78e0a53 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 1972
diff changeset
28 #include "memory/memRegion.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "utilities/bitMap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class oopDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class ParMarkBitMapClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1983
diff changeset
35 class ParMarkBitMap: public CHeapObj<mtGC>
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
38 typedef BitMap::idx_t idx_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Values returned by the iterate() methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
41 enum IterationStatus { incomplete, complete, full, would_overflow };
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 inline ParMarkBitMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 inline ParMarkBitMap(MemRegion covered_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool initialize(MemRegion covered_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Atomically mark an object as live.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 bool mark_obj(HeapWord* addr, size_t size);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 inline bool mark_obj(oop obj, int size);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 inline bool mark_obj(oop obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Return whether the specified begin or end bit is set.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 inline bool is_obj_beg(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 inline bool is_obj_end(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Traditional interface for testing whether an object is marked or not (these
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // test only the begin bits).
a61af66fc99e Initial load
duke
parents:
diff changeset
58 inline bool is_marked(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 inline bool is_marked(HeapWord* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 inline bool is_marked(oop obj) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 inline bool is_unmarked(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 inline bool is_unmarked(HeapWord* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 inline bool is_unmarked(oop obj) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Convert sizes from bits to HeapWords and back. An object that is n bits
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // long will be bits_to_words(n) words long. An object that is m words long
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // will take up words_to_bits(m) bits in the bitmap.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 inline static size_t bits_to_words(idx_t bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 inline static idx_t words_to_bits(size_t words);
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Return the size in words of an object given a begin bit and an end bit, or
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // the equivalent beg_addr and end_addr.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 inline size_t obj_size(idx_t beg_bit, idx_t end_bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 inline size_t obj_size(HeapWord* beg_addr, HeapWord* end_addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Return the size in words of the object (a search is done for the end bit).
a61af66fc99e Initial load
duke
parents:
diff changeset
78 inline size_t obj_size(idx_t beg_bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 inline size_t obj_size(HeapWord* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 inline size_t obj_size(oop obj) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Synonyms for the above.
a61af66fc99e Initial load
duke
parents:
diff changeset
83 size_t obj_size_in_words(oop obj) const { return obj_size((HeapWord*)obj); }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 size_t obj_size_in_words(HeapWord* addr) const { return obj_size(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Apply live_closure to each live object that lies completely within the
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // range [live_range_beg, live_range_end). This is used to iterate over the
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // compacted region of the heap. Return values:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 //
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // incomplete The iteration is not complete. The last object that
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // begins in the range does not end in the range;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // closure->source() is set to the start of that object.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 //
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // complete The iteration is complete. All objects in the range
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // were processed and the closure is not full;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // closure->source() is set one past the end of the range.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // full The closure is full; closure->source() is set to one
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // past the end of the last object processed.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 //
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // would_overflow The next object in the range would overflow the closure;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // closure->source() is set to the start of that object.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 IterationStatus iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
104 idx_t range_beg, idx_t range_end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
106 HeapWord* range_beg,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 HeapWord* range_end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Apply live closure as above and additionally apply dead_closure to all dead
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // space in the range [range_beg, dead_range_end). Note that dead_range_end
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // must be >= range_end. This is used to iterate over the dense prefix.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 //
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // This method assumes that if the first bit in the range (range_beg) is not
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // marked, then dead space begins at that point and the dead_closure is
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // applied. Thus callers must ensure that range_beg is not in the middle of a
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // live object.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 IterationStatus iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 ParMarkBitMapClosure* dead_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
119 idx_t range_beg, idx_t range_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
120 idx_t dead_range_end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
122 ParMarkBitMapClosure* dead_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 HeapWord* range_beg,
a61af66fc99e Initial load
duke
parents:
diff changeset
124 HeapWord* range_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
125 HeapWord* dead_range_end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Return the number of live words in the range [beg_addr, end_addr) due to
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // objects that start in the range. If a live object extends onto the range,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // the caller must detect and account for any live words due to that object.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // If a live object extends beyond the end of the range, only the words within
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // the range are included in the result.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 size_t live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Same as the above, except the end of the range must be a live object, which
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // is the case when updating pointers. This allows a branch to be removed
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // from inside the loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 inline HeapWord* region_start() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 inline HeapWord* region_end() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 inline size_t region_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 inline size_t size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Convert a heap address to/from a bit index.
a61af66fc99e Initial load
duke
parents:
diff changeset
145 inline idx_t addr_to_bit(HeapWord* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 inline HeapWord* bit_to_addr(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Return the bit index of the first marked object that begins (or ends,
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // respectively) in the range [beg, end). If no object is found, return end.
a61af66fc99e Initial load
duke
parents:
diff changeset
150 inline idx_t find_obj_beg(idx_t beg, idx_t end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 inline idx_t find_obj_end(idx_t beg, idx_t end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 inline HeapWord* find_obj_beg(HeapWord* beg, HeapWord* end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Clear a range of bits or the entire bitmap (both begin and end bits are
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // cleared).
a61af66fc99e Initial load
duke
parents:
diff changeset
158 inline void clear_range(idx_t beg, idx_t end);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 inline void clear() { clear_range(0, size()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Return the number of bits required to represent the specified number of
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // HeapWords, or the specified region.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 static inline idx_t bits_required(size_t words);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 static inline idx_t bits_required(MemRegion covered_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 static inline idx_t words_required(MemRegion covered_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // CAS statistics.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 size_t cas_tries() { return _cas_tries; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 size_t cas_retries() { return _cas_retries; }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 size_t cas_by_another() { return _cas_by_another; }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void reset_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #endif // #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
177 void verify_clear() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 inline void verify_bit(idx_t bit) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 inline void verify_addr(HeapWord* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 #endif // #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // Each bit in the bitmap represents one unit of 'object granularity.' Objects
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // are double-word aligned in 32-bit VMs, but not in 64-bit VMs, so the 32-bit
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // granularity is 2, 64-bit is 1.
a61af66fc99e Initial load
duke
parents:
diff changeset
186 static inline size_t obj_granularity() { return size_t(MinObjAlignment); }
808
353ba4575581 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 342
diff changeset
187 static inline int obj_granularity_shift() { return LogMinObjAlignment; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 HeapWord* _region_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 size_t _region_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 BitMap _beg_bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 BitMap _end_bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 PSVirtualSpace* _virtual_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
196 size_t _cas_tries;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 size_t _cas_retries;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 size_t _cas_by_another;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 #endif // #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
200 };
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 inline ParMarkBitMap::ParMarkBitMap():
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
203 _beg_bits(),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
204 _end_bits()
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 _region_start = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 _virtual_space = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 inline ParMarkBitMap::ParMarkBitMap(MemRegion covered_region):
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
211 _beg_bits(),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
212 _end_bits()
0
a61af66fc99e Initial load
duke
parents:
diff changeset
213 {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 initialize(covered_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
a61af66fc99e Initial load
duke
parents:
diff changeset
218 {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 _beg_bits.clear_range(beg, end);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 _end_bits.clear_range(beg, end);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
224 ParMarkBitMap::bits_required(size_t words)
a61af66fc99e Initial load
duke
parents:
diff changeset
225 {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Need two bits (one begin bit, one end bit) for each unit of 'object
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // granularity' in the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 return words_to_bits(words * 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
232 ParMarkBitMap::bits_required(MemRegion covered_region)
a61af66fc99e Initial load
duke
parents:
diff changeset
233 {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return bits_required(covered_region.word_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
238 ParMarkBitMap::words_required(MemRegion covered_region)
a61af66fc99e Initial load
duke
parents:
diff changeset
239 {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return bits_required(covered_region) / BitsPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 inline HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
244 ParMarkBitMap::region_start() const
a61af66fc99e Initial load
duke
parents:
diff changeset
245 {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return _region_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 inline HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
250 ParMarkBitMap::region_end() const
a61af66fc99e Initial load
duke
parents:
diff changeset
251 {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return region_start() + region_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 inline size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
256 ParMarkBitMap::region_size() const
a61af66fc99e Initial load
duke
parents:
diff changeset
257 {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return _region_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 inline size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
262 ParMarkBitMap::size() const
a61af66fc99e Initial load
duke
parents:
diff changeset
263 {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return _beg_bits.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 inline bool ParMarkBitMap::is_obj_beg(idx_t bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
268 {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return _beg_bits.at(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 inline bool ParMarkBitMap::is_obj_end(idx_t bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
273 {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 return _end_bits.at(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 inline bool ParMarkBitMap::is_marked(idx_t bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
278 {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return is_obj_beg(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 inline bool ParMarkBitMap::is_marked(HeapWord* addr) const
a61af66fc99e Initial load
duke
parents:
diff changeset
283 {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return is_marked(addr_to_bit(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 inline bool ParMarkBitMap::is_marked(oop obj) const
a61af66fc99e Initial load
duke
parents:
diff changeset
288 {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 return is_marked((HeapWord*)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 inline bool ParMarkBitMap::is_unmarked(idx_t bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
293 {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 return !is_marked(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 inline bool ParMarkBitMap::is_unmarked(HeapWord* addr) const
a61af66fc99e Initial load
duke
parents:
diff changeset
298 {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return !is_marked(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 inline bool ParMarkBitMap::is_unmarked(oop obj) const
a61af66fc99e Initial load
duke
parents:
diff changeset
303 {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return !is_marked(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 inline size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
308 ParMarkBitMap::bits_to_words(idx_t bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
309 {
808
353ba4575581 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 342
diff changeset
310 return bits << obj_granularity_shift();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
314 ParMarkBitMap::words_to_bits(size_t words)
a61af66fc99e Initial load
duke
parents:
diff changeset
315 {
808
353ba4575581 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 342
diff changeset
316 return words >> obj_granularity_shift();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 inline size_t ParMarkBitMap::obj_size(idx_t beg_bit, idx_t end_bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
320 {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 DEBUG_ONLY(verify_bit(beg_bit);)
a61af66fc99e Initial load
duke
parents:
diff changeset
322 DEBUG_ONLY(verify_bit(end_bit);)
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return bits_to_words(end_bit - beg_bit + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 inline size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
327 ParMarkBitMap::obj_size(HeapWord* beg_addr, HeapWord* end_addr) const
a61af66fc99e Initial load
duke
parents:
diff changeset
328 {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 DEBUG_ONLY(verify_addr(beg_addr);)
a61af66fc99e Initial load
duke
parents:
diff changeset
330 DEBUG_ONLY(verify_addr(end_addr);)
a61af66fc99e Initial load
duke
parents:
diff changeset
331 return pointer_delta(end_addr, beg_addr) + obj_granularity();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 inline size_t ParMarkBitMap::obj_size(idx_t beg_bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
335 {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
336 const idx_t end_bit = _end_bits.get_next_one_offset_inline(beg_bit, size());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
337 assert(is_marked(beg_bit), "obj not marked");
a61af66fc99e Initial load
duke
parents:
diff changeset
338 assert(end_bit < size(), "end bit missing");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 return obj_size(beg_bit, end_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 inline size_t ParMarkBitMap::obj_size(HeapWord* addr) const
a61af66fc99e Initial load
duke
parents:
diff changeset
343 {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 return obj_size(addr_to_bit(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 inline size_t ParMarkBitMap::obj_size(oop obj) const
a61af66fc99e Initial load
duke
parents:
diff changeset
348 {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 return obj_size((HeapWord*)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 inline ParMarkBitMap::IterationStatus
a61af66fc99e Initial load
duke
parents:
diff changeset
353 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
354 HeapWord* range_beg,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 HeapWord* range_end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
356 {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return iterate(live_closure, addr_to_bit(range_beg), addr_to_bit(range_end));
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 inline ParMarkBitMap::IterationStatus
a61af66fc99e Initial load
duke
parents:
diff changeset
361 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
362 ParMarkBitMapClosure* dead_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
363 HeapWord* range_beg,
a61af66fc99e Initial load
duke
parents:
diff changeset
364 HeapWord* range_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
365 HeapWord* dead_range_end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
366 {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 return iterate(live_closure, dead_closure,
a61af66fc99e Initial load
duke
parents:
diff changeset
368 addr_to_bit(range_beg), addr_to_bit(range_end),
a61af66fc99e Initial load
duke
parents:
diff changeset
369 addr_to_bit(dead_range_end));
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 inline bool
a61af66fc99e Initial load
duke
parents:
diff changeset
373 ParMarkBitMap::mark_obj(oop obj, int size)
a61af66fc99e Initial load
duke
parents:
diff changeset
374 {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 return mark_obj((HeapWord*)obj, (size_t)size);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 inline BitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
379 ParMarkBitMap::addr_to_bit(HeapWord* addr) const
a61af66fc99e Initial load
duke
parents:
diff changeset
380 {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 DEBUG_ONLY(verify_addr(addr);)
a61af66fc99e Initial load
duke
parents:
diff changeset
382 return words_to_bits(pointer_delta(addr, region_start()));
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 inline HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
386 ParMarkBitMap::bit_to_addr(idx_t bit) const
a61af66fc99e Initial load
duke
parents:
diff changeset
387 {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 DEBUG_ONLY(verify_bit(bit);)
a61af66fc99e Initial load
duke
parents:
diff changeset
389 return region_start() + bits_to_words(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
393 ParMarkBitMap::find_obj_beg(idx_t beg, idx_t end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
394 {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
395 return _beg_bits.get_next_one_offset_inline_aligned_right(beg, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 inline ParMarkBitMap::idx_t
a61af66fc99e Initial load
duke
parents:
diff changeset
399 ParMarkBitMap::find_obj_end(idx_t beg, idx_t end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
400 {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
401 return _end_bits.get_next_one_offset_inline_aligned_right(beg, end);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 inline HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
405 ParMarkBitMap::find_obj_beg(HeapWord* beg, HeapWord* end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
406 {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 const idx_t beg_bit = addr_to_bit(beg);
a61af66fc99e Initial load
duke
parents:
diff changeset
408 const idx_t end_bit = addr_to_bit(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 const idx_t search_end = BitMap::word_align_up(end_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
410 const idx_t res_bit = MIN2(find_obj_beg(beg_bit, search_end), end_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 return bit_to_addr(res_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 inline HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
415 ParMarkBitMap::find_obj_end(HeapWord* beg, HeapWord* end) const
a61af66fc99e Initial load
duke
parents:
diff changeset
416 {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 const idx_t beg_bit = addr_to_bit(beg);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 const idx_t end_bit = addr_to_bit(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 const idx_t search_end = BitMap::word_align_up(end_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 const idx_t res_bit = MIN2(find_obj_end(beg_bit, search_end), end_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
421 return bit_to_addr(res_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
425 inline void ParMarkBitMap::verify_bit(idx_t bit) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // Allow one past the last valid bit; useful for loop bounds.
a61af66fc99e Initial load
duke
parents:
diff changeset
427 assert(bit <= _beg_bits.size(), "bit out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 inline void ParMarkBitMap::verify_addr(HeapWord* addr) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // Allow one past the last valid address; useful for loop bounds.
a61af66fc99e Initial load
duke
parents:
diff changeset
432 assert(addr >= region_start(), "addr too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
433 assert(addr <= region_start() + region_size(), "addr too big");
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435 #endif // #ifdef ASSERT
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
436
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
437 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP