Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp @ 6027:8a2e5a6a19a4
7143490: G1: Remove HeapRegion::_top_at_conc_mark_count
Summary: Removed the HeapRegion::_top_at_conc_mark_count field. It is no longer needed as a result of the changes for 6888336 and 7127706. Refactored the closures that finalize and verify the liveness counting data so that common functionality was placed into a base class.
Reviewed-by: brutisso, tonyp
author | johnc |
---|---|
date | Wed, 25 Apr 2012 10:23:12 -0700 |
parents | f08d439fab8c |
children | d2a62e0f25eb |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
237
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
237
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:
237
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" | |
27 #include "gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp" | |
28 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" | |
29 #include "oops/oop.inline.hpp" | |
30 #include "runtime/os.hpp" | |
31 #include "utilities/bitMap.inline.hpp" | |
32 #ifdef TARGET_OS_FAMILY_linux | |
33 # include "os_linux.inline.hpp" | |
34 #endif | |
35 #ifdef TARGET_OS_FAMILY_solaris | |
36 # include "os_solaris.inline.hpp" | |
37 #endif | |
38 #ifdef TARGET_OS_FAMILY_windows | |
39 # include "os_windows.inline.hpp" | |
40 #endif | |
3960 | 41 #ifdef TARGET_OS_FAMILY_bsd |
42 # include "os_bsd.inline.hpp" | |
43 #endif | |
0 | 44 |
45 bool | |
46 ParMarkBitMap::initialize(MemRegion covered_region) | |
47 { | |
48 const idx_t bits = bits_required(covered_region); | |
49 // The bits will be divided evenly between two bitmaps; each of them should be | |
50 // an integral number of words. | |
51 assert(bits % (BitsPerWord * 2) == 0, "region size unaligned"); | |
52 | |
53 const size_t words = bits / BitsPerWord; | |
54 const size_t raw_bytes = words * sizeof(idx_t); | |
55 const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10); | |
56 const size_t granularity = os::vm_allocation_granularity(); | |
57 const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity)); | |
58 | |
59 const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 : | |
60 MAX2(page_sz, granularity); | |
79
82db0859acbe
6642862: Code cache allocation fails with large pages after 6588638
jcoomes
parents:
0
diff
changeset
|
61 ReservedSpace rs(bytes, rs_align, rs_align > 0); |
0 | 62 os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz, |
63 rs.base(), rs.size()); | |
64 _virtual_space = new PSVirtualSpace(rs, page_sz); | |
65 if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) { | |
66 _region_start = covered_region.start(); | |
67 _region_size = covered_region.word_size(); | |
68 idx_t* map = (idx_t*)_virtual_space->reserved_low_addr(); | |
69 _beg_bits.set_map(map); | |
70 _beg_bits.set_size(bits / 2); | |
71 _end_bits.set_map(map + words / 2); | |
72 _end_bits.set_size(bits / 2); | |
73 return true; | |
74 } | |
75 | |
76 _region_start = 0; | |
77 _region_size = 0; | |
78 if (_virtual_space != NULL) { | |
79 delete _virtual_space; | |
80 _virtual_space = NULL; | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
196
diff
changeset
|
81 // Release memory reserved in the space. |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
196
diff
changeset
|
82 rs.release(); |
0 | 83 } |
84 return false; | |
85 } | |
86 | |
87 #ifdef ASSERT | |
88 extern size_t mark_bitmap_count; | |
89 extern size_t mark_bitmap_size; | |
90 #endif // #ifdef ASSERT | |
91 | |
92 bool | |
93 ParMarkBitMap::mark_obj(HeapWord* addr, size_t size) | |
94 { | |
95 const idx_t beg_bit = addr_to_bit(addr); | |
96 if (_beg_bits.par_set_bit(beg_bit)) { | |
97 const idx_t end_bit = addr_to_bit(addr + size - 1); | |
98 bool end_bit_ok = _end_bits.par_set_bit(end_bit); | |
99 assert(end_bit_ok, "concurrency problem"); | |
100 DEBUG_ONLY(Atomic::inc_ptr(&mark_bitmap_count)); | |
101 DEBUG_ONLY(Atomic::add_ptr(size, &mark_bitmap_size)); | |
102 return true; | |
103 } | |
104 return false; | |
105 } | |
106 | |
107 size_t | |
108 ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const | |
109 { | |
110 assert(beg_addr <= end_addr, "bad range"); | |
111 | |
112 idx_t live_bits = 0; | |
113 | |
114 // The bitmap routines require the right boundary to be word-aligned. | |
115 const idx_t end_bit = addr_to_bit(end_addr); | |
116 const idx_t range_end = BitMap::word_align_up(end_bit); | |
117 | |
118 idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); | |
119 while (beg_bit < end_bit) { | |
120 idx_t tmp_end = find_obj_end(beg_bit, range_end); | |
121 if (tmp_end < end_bit) { | |
122 live_bits += tmp_end - beg_bit + 1; | |
123 beg_bit = find_obj_beg(tmp_end + 1, range_end); | |
124 } else { | |
125 live_bits += end_bit - beg_bit; // No + 1 here; end_bit is not counted. | |
126 return bits_to_words(live_bits); | |
127 } | |
128 } | |
129 return bits_to_words(live_bits); | |
130 } | |
131 | |
132 size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const | |
133 { | |
134 assert(beg_addr <= (HeapWord*)end_obj, "bad range"); | |
135 assert(is_marked(end_obj), "end_obj must be live"); | |
136 | |
137 idx_t live_bits = 0; | |
138 | |
139 // The bitmap routines require the right boundary to be word-aligned. | |
140 const idx_t end_bit = addr_to_bit((HeapWord*)end_obj); | |
141 const idx_t range_end = BitMap::word_align_up(end_bit); | |
142 | |
143 idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); | |
144 while (beg_bit < end_bit) { | |
145 idx_t tmp_end = find_obj_end(beg_bit, range_end); | |
146 assert(tmp_end < end_bit, "missing end bit"); | |
147 live_bits += tmp_end - beg_bit + 1; | |
148 beg_bit = find_obj_beg(tmp_end + 1, range_end); | |
149 } | |
150 return bits_to_words(live_bits); | |
151 } | |
152 | |
153 ParMarkBitMap::IterationStatus | |
154 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure, | |
155 idx_t range_beg, idx_t range_end) const | |
156 { | |
157 DEBUG_ONLY(verify_bit(range_beg);) | |
158 DEBUG_ONLY(verify_bit(range_end);) | |
159 assert(range_beg <= range_end, "live range invalid"); | |
160 | |
161 // The bitmap routines require the right boundary to be word-aligned. | |
162 const idx_t search_end = BitMap::word_align_up(range_end); | |
163 | |
164 idx_t cur_beg = find_obj_beg(range_beg, search_end); | |
165 while (cur_beg < range_end) { | |
166 const idx_t cur_end = find_obj_end(cur_beg, search_end); | |
167 if (cur_end >= range_end) { | |
168 // The obj ends outside the range. | |
169 live_closure->set_source(bit_to_addr(cur_beg)); | |
170 return incomplete; | |
171 } | |
172 | |
173 const size_t size = obj_size(cur_beg, cur_end); | |
174 IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size); | |
175 if (status != incomplete) { | |
176 assert(status == would_overflow || status == full, "sanity"); | |
177 return status; | |
178 } | |
179 | |
180 // Successfully processed the object; look for the next object. | |
181 cur_beg = find_obj_beg(cur_end + 1, search_end); | |
182 } | |
183 | |
184 live_closure->set_source(bit_to_addr(range_end)); | |
185 return complete; | |
186 } | |
187 | |
188 ParMarkBitMap::IterationStatus | |
189 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure, | |
190 ParMarkBitMapClosure* dead_closure, | |
191 idx_t range_beg, idx_t range_end, | |
192 idx_t dead_range_end) const | |
193 { | |
194 DEBUG_ONLY(verify_bit(range_beg);) | |
195 DEBUG_ONLY(verify_bit(range_end);) | |
196 DEBUG_ONLY(verify_bit(dead_range_end);) | |
197 assert(range_beg <= range_end, "live range invalid"); | |
198 assert(range_end <= dead_range_end, "dead range invalid"); | |
199 | |
200 // The bitmap routines require the right boundary to be word-aligned. | |
201 const idx_t live_search_end = BitMap::word_align_up(range_end); | |
202 const idx_t dead_search_end = BitMap::word_align_up(dead_range_end); | |
203 | |
204 idx_t cur_beg = range_beg; | |
205 if (range_beg < range_end && is_unmarked(range_beg)) { | |
206 // The range starts with dead space. Look for the next object, then fill. | |
207 cur_beg = find_obj_beg(range_beg + 1, dead_search_end); | |
208 const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1); | |
209 const size_t size = obj_size(range_beg, dead_space_end); | |
210 dead_closure->do_addr(bit_to_addr(range_beg), size); | |
211 } | |
212 | |
213 while (cur_beg < range_end) { | |
214 const idx_t cur_end = find_obj_end(cur_beg, live_search_end); | |
215 if (cur_end >= range_end) { | |
216 // The obj ends outside the range. | |
217 live_closure->set_source(bit_to_addr(cur_beg)); | |
218 return incomplete; | |
219 } | |
220 | |
221 const size_t size = obj_size(cur_beg, cur_end); | |
222 IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size); | |
223 if (status != incomplete) { | |
224 assert(status == would_overflow || status == full, "sanity"); | |
225 return status; | |
226 } | |
227 | |
228 // Look for the start of the next object. | |
229 const idx_t dead_space_beg = cur_end + 1; | |
230 cur_beg = find_obj_beg(dead_space_beg, dead_search_end); | |
231 if (cur_beg > dead_space_beg) { | |
232 // Found dead space; compute the size and invoke the dead closure. | |
233 const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1); | |
234 const size_t size = obj_size(dead_space_beg, dead_space_end); | |
235 dead_closure->do_addr(bit_to_addr(dead_space_beg), size); | |
236 } | |
237 } | |
238 | |
239 live_closure->set_source(bit_to_addr(range_end)); | |
240 return complete; | |
241 } | |
242 | |
243 #ifndef PRODUCT | |
244 void ParMarkBitMap::reset_counters() | |
245 { | |
246 _cas_tries = _cas_retries = _cas_by_another = 0; | |
247 } | |
248 #endif // #ifndef PRODUCT | |
249 | |
250 #ifdef ASSERT | |
251 void ParMarkBitMap::verify_clear() const | |
252 { | |
253 const idx_t* const beg = (const idx_t*)_virtual_space->committed_low_addr(); | |
254 const idx_t* const end = (const idx_t*)_virtual_space->committed_high_addr(); | |
255 for (const idx_t* p = beg; p < end; ++p) { | |
256 assert(*p == 0, "bitmap not clear"); | |
257 } | |
258 } | |
259 #endif // #ifdef ASSERT |