annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp @ 17937:78bbf4d43a14

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