Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp @ 14213:6c4c27c5cc9a
8029366: ShouldNotReachHere error when creating an array with component type of void
Reviewed-by: kvn
author | twisti |
---|---|
date | Fri, 06 Dec 2013 16:43:56 -0800 |
parents | 190899198332 |
children | 78bbf4d43a14 |
rev | line source |
---|---|
0 | 1 /* |
10405 | 2 * Copyright (c) 2002, 2013, 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:
579
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
579
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:
579
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" | |
27 #include "gc_implementation/parallelScavenge/psOldGen.hpp" | |
28 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" | |
29 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" | |
10405 | 30 #include "gc_implementation/shared/gcTrace.hpp" |
1972 | 31 #include "gc_implementation/shared/mutableSpace.hpp" |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
32 #include "memory/allocation.inline.hpp" |
1972 | 33 #include "memory/memRegion.hpp" |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
34 #include "memory/padded.inline.hpp" |
1972 | 35 #include "oops/oop.inline.hpp" |
36 #include "oops/oop.psgc.inline.hpp" | |
0 | 37 |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
38 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
39 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
40 PSOldGen* PSPromotionManager::_old_gen = NULL; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
41 MutableSpace* PSPromotionManager::_young_space = NULL; |
0 | 42 |
43 void PSPromotionManager::initialize() { | |
44 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
45 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
46 | |
47 _old_gen = heap->old_gen(); | |
48 _young_space = heap->young_gen()->to_space(); | |
49 | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
50 // To prevent false sharing, we pad the PSPromotionManagers |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
51 // and make sure that the first instance starts at a cache line. |
0 | 52 assert(_manager_array == NULL, "Attempt to initialize twice"); |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
53 _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(ParallelGCThreads + 1); |
0 | 54 guarantee(_manager_array != NULL, "Could not initialize promotion manager"); |
55 | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
56 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); |
10405 | 57 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager"); |
0 | 58 |
59 // Create and register the PSPromotionManager(s) for the worker threads. | |
60 for(uint i=0; i<ParallelGCThreads; i++) { | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
61 stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth()); |
0 | 62 } |
63 // The VMThread gets its own PSPromotionManager, which is not available | |
64 // for work stealing. | |
65 } | |
66 | |
67 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { | |
68 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); | |
69 assert(_manager_array != NULL, "Sanity"); | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
70 return &_manager_array[index]; |
0 | 71 } |
72 | |
73 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { | |
74 assert(_manager_array != NULL, "Sanity"); | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
75 return &_manager_array[ParallelGCThreads]; |
0 | 76 } |
77 | |
78 void PSPromotionManager::pre_scavenge() { | |
79 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
80 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
81 | |
82 _young_space = heap->young_gen()->to_space(); | |
83 | |
84 for(uint i=0; i<ParallelGCThreads+1; i++) { | |
85 manager_array(i)->reset(); | |
86 } | |
87 } | |
88 | |
10405 | 89 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) { |
90 bool promotion_failure_occurred = false; | |
91 | |
1665 | 92 TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats()); |
1638 | 93 for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
0 | 94 PSPromotionManager* manager = manager_array(i); |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
95 assert(manager->claimed_stack_depth()->is_empty(), "should be empty"); |
10405 | 96 if (manager->_promotion_failed_info.has_failed()) { |
97 gc_tracer.report_promotion_failed(manager->_promotion_failed_info); | |
98 promotion_failure_occurred = true; | |
99 } | |
0 | 100 manager->flush_labs(); |
101 } | |
10405 | 102 return promotion_failure_occurred; |
0 | 103 } |
104 | |
1665 | 105 #if TASKQUEUE_STATS |
0 | 106 void |
1665 | 107 PSPromotionManager::print_taskqueue_stats(uint i) const { |
108 tty->print("%3u ", i); | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
109 _claimed_stack_depth.stats.print(); |
1665 | 110 tty->cr(); |
0 | 111 } |
112 | |
113 void | |
1665 | 114 PSPromotionManager::print_local_stats(uint i) const { |
115 #define FMT " " SIZE_FORMAT_W(10) | |
116 tty->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals, | |
117 _arrays_chunked, _array_chunks_processed); | |
118 #undef FMT | |
119 } | |
120 | |
121 static const char* const pm_stats_hdr[] = { | |
122 " --------masked------- arrays array", | |
123 "thr push steal chunked chunks", | |
124 "--- ---------- ---------- ---------- ----------" | |
125 }; | |
126 | |
127 void | |
0 | 128 PSPromotionManager::print_stats() { |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
129 tty->print_cr("== GC Tasks Stats, GC %3d", |
0 | 130 Universe::heap()->total_collections()); |
131 | |
1665 | 132 tty->print("thr "); TaskQueueStats::print_header(1); tty->cr(); |
133 tty->print("--- "); TaskQueueStats::print_header(2); tty->cr(); | |
134 for (uint i = 0; i < ParallelGCThreads + 1; ++i) { | |
135 manager_array(i)->print_taskqueue_stats(i); | |
136 } | |
137 | |
138 const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]); | |
139 for (uint i = 0; i < hlines; ++i) tty->print_cr(pm_stats_hdr[i]); | |
140 for (uint i = 0; i < ParallelGCThreads + 1; ++i) { | |
141 manager_array(i)->print_local_stats(i); | |
0 | 142 } |
143 } | |
144 | |
1665 | 145 void |
146 PSPromotionManager::reset_stats() { | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
147 claimed_stack_depth()->stats.reset(); |
1665 | 148 _masked_pushes = _masked_steals = 0; |
149 _arrays_chunked = _array_chunks_processed = 0; | |
150 } | |
151 #endif // TASKQUEUE_STATS | |
0 | 152 |
153 PSPromotionManager::PSPromotionManager() { | |
154 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
155 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
156 | |
157 // We set the old lab's start array. | |
158 _old_lab.set_start_array(old_gen()->start_array()); | |
159 | |
160 uint queue_size; | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
161 claimed_stack_depth()->initialize(); |
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
162 queue_size = claimed_stack_depth()->max_elems(); |
0 | 163 |
164 _totally_drain = (ParallelGCThreads == 1) || (GCDrainStackTargetSize == 0); | |
165 if (_totally_drain) { | |
166 _target_stack_size = 0; | |
167 } else { | |
168 // don't let the target stack size to be more than 1/4 of the entries | |
169 _target_stack_size = (uint) MIN2((uint) GCDrainStackTargetSize, | |
170 (uint) (queue_size / 4)); | |
171 } | |
172 | |
173 _array_chunk_size = ParGCArrayScanChunk; | |
174 // let's choose 1.5x the chunk size | |
175 _min_array_size_for_chunking = 3 * _array_chunk_size / 2; | |
176 | |
177 reset(); | |
178 } | |
179 | |
180 void PSPromotionManager::reset() { | |
1638 | 181 assert(stacks_empty(), "reset of non-empty stack"); |
0 | 182 |
183 // We need to get an assert in here to make sure the labs are always flushed. | |
184 | |
185 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
186 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
187 | |
188 // Do not prefill the LAB's, save heap wastage! | |
189 HeapWord* lab_base = young_space()->top(); | |
190 _young_lab.initialize(MemRegion(lab_base, (size_t)0)); | |
191 _young_gen_is_full = false; | |
192 | |
193 lab_base = old_gen()->object_space()->top(); | |
194 _old_lab.initialize(MemRegion(lab_base, (size_t)0)); | |
195 _old_gen_is_full = false; | |
196 | |
10405 | 197 _promotion_failed_info.reset(); |
198 | |
1665 | 199 TASKQUEUE_STATS_ONLY(reset_stats()); |
0 | 200 } |
201 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
202 |
0 | 203 void PSPromotionManager::drain_stacks_depth(bool totally_drain) { |
204 totally_drain = totally_drain || _totally_drain; | |
205 | |
206 #ifdef ASSERT | |
207 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
208 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
209 MutableSpace* to_space = heap->young_gen()->to_space(); | |
210 MutableSpace* old_space = heap->old_gen()->object_space(); | |
211 #endif /* ASSERT */ | |
212 | |
1638 | 213 OopStarTaskQueue* const tq = claimed_stack_depth(); |
0 | 214 do { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
215 StarTask p; |
0 | 216 |
217 // Drain overflow stack first, so other threads can steal from | |
218 // claimed stack while we work. | |
1638 | 219 while (tq->pop_overflow(p)) { |
220 process_popped_location_depth(p); | |
0 | 221 } |
222 | |
223 if (totally_drain) { | |
1638 | 224 while (tq->pop_local(p)) { |
0 | 225 process_popped_location_depth(p); |
226 } | |
227 } else { | |
1638 | 228 while (tq->size() > _target_stack_size && tq->pop_local(p)) { |
0 | 229 process_popped_location_depth(p); |
230 } | |
231 } | |
1638 | 232 } while (totally_drain && !tq->taskqueue_empty() || !tq->overflow_empty()); |
0 | 233 |
1638 | 234 assert(!totally_drain || tq->taskqueue_empty(), "Sanity"); |
235 assert(totally_drain || tq->size() <= _target_stack_size, "Sanity"); | |
236 assert(tq->overflow_empty(), "Sanity"); | |
0 | 237 } |
238 | |
239 void PSPromotionManager::flush_labs() { | |
1638 | 240 assert(stacks_empty(), "Attempt to flush lab with live stack"); |
0 | 241 |
242 // If either promotion lab fills up, we can flush the | |
243 // lab but not refill it, so check first. | |
244 assert(!_young_lab.is_flushed() || _young_gen_is_full, "Sanity"); | |
245 if (!_young_lab.is_flushed()) | |
246 _young_lab.flush(); | |
247 | |
248 assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity"); | |
249 if (!_old_lab.is_flushed()) | |
250 _old_lab.flush(); | |
251 | |
252 // Let PSScavenge know if we overflowed | |
253 if (_young_gen_is_full) { | |
254 PSScavenge::set_survivor_overflow(true); | |
255 } | |
256 } | |
257 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
258 template <class T> void PSPromotionManager::process_array_chunk_work( |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
259 oop obj, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
260 int start, int end) { |
2366
1fb790245268
6820066: Check that -XX:ParGCArrayScanChunk has a value larger than zero.
jwilhelm
parents:
1972
diff
changeset
|
261 assert(start <= end, "invariant"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
262 T* const base = (T*)objArrayOop(obj)->base(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
263 T* p = base + start; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
264 T* const chunk_end = base + end; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
265 while (p < chunk_end) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
266 if (PSScavenge::should_scavenge(p)) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
267 claim_or_forward_depth(p); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
268 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
269 ++p; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
270 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
271 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
272 |
0 | 273 void PSPromotionManager::process_array_chunk(oop old) { |
274 assert(PSChunkLargeArrays, "invariant"); | |
275 assert(old->is_objArray(), "invariant"); | |
276 assert(old->is_forwarded(), "invariant"); | |
277 | |
1665 | 278 TASKQUEUE_STATS_ONLY(++_array_chunks_processed); |
0 | 279 |
280 oop const obj = old->forwardee(); | |
281 | |
282 int start; | |
283 int const end = arrayOop(old)->length(); | |
284 if (end > (int) _min_array_size_for_chunking) { | |
285 // we'll chunk more | |
286 start = end - _array_chunk_size; | |
287 assert(start > 0, "invariant"); | |
288 arrayOop(old)->set_length(start); | |
289 push_depth(mask_chunked_array_oop(old)); | |
1665 | 290 TASKQUEUE_STATS_ONLY(++_masked_pushes); |
0 | 291 } else { |
292 // this is the final chunk for this array | |
293 start = 0; | |
294 int const actual_length = arrayOop(obj)->length(); | |
295 arrayOop(old)->set_length(actual_length); | |
296 } | |
297 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
298 if (UseCompressedOops) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
299 process_array_chunk_work<narrowOop>(obj, start, end); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
300 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
301 process_array_chunk_work<oop>(obj, start, end); |
0 | 302 } |
303 } | |
304 | |
305 oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) { | |
306 assert(_old_gen_is_full || PromotionFailureALot, "Sanity"); | |
307 | |
308 // Attempt to CAS in the header. | |
309 // This tests if the header is still the same as when | |
310 // this started. If it is the same (i.e., no forwarding | |
311 // pointer has been installed), then this thread owns | |
312 // it. | |
313 if (obj->cas_forward_to(obj, obj_mark)) { | |
314 // We won any races, we "own" this object. | |
315 assert(obj == obj->forwardee(), "Sanity"); | |
316 | |
10405 | 317 _promotion_failed_info.register_copy_failure(obj->size()); |
318 | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1665
diff
changeset
|
319 obj->push_contents(this); |
0 | 320 |
321 // Save the mark if needed | |
322 PSScavenge::oop_promotion_failed(obj, obj_mark); | |
323 } else { | |
324 // We lost, someone else "owns" this object | |
325 guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed."); | |
326 | |
327 // No unallocation to worry about. | |
328 obj = obj->forwardee(); | |
329 } | |
330 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
331 #ifndef PRODUCT |
0 | 332 if (TraceScavenge) { |
333 gclog_or_tty->print_cr("{%s %s 0x%x (%d)}", | |
334 "promotion-failure", | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
335 obj->klass()->internal_name(), |
12316
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
12029
diff
changeset
|
336 (void *)obj, obj->size()); |
0 | 337 |
338 } | |
339 #endif | |
340 | |
341 return obj; | |
342 } |