author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57777 | 90ead0febf56 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
57770
b5ca334ed54c
8224662: Parallel GC: Use WorkGang (4: SharedRestorePreservedMarksTaskExecutor)
lkorinth
parents:
52117
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
50752 | 26 |
#include "classfile/javaClasses.inline.hpp" |
30764 | 27 |
#include "gc/parallel/mutableSpace.hpp" |
28 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
|
29 |
#include "gc/parallel/psOldGen.hpp" |
|
30 |
#include "gc/parallel/psPromotionManager.inline.hpp" |
|
31 |
#include "gc/parallel/psScavenge.inline.hpp" |
|
32 |
#include "gc/shared/gcTrace.hpp" |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
33 |
#include "gc/shared/preservedMarks.inline.hpp" |
30764 | 34 |
#include "gc/shared/taskqueue.inline.hpp" |
35061 | 35 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
36 |
#include "logging/logStream.hpp" |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
37 |
#include "memory/allocation.inline.hpp" |
50752 | 38 |
#include "memory/iterator.inline.hpp" |
7397 | 39 |
#include "memory/memRegion.hpp" |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
40 |
#include "memory/padded.inline.hpp" |
37248 | 41 |
#include "memory/resourceArea.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49041
diff
changeset
|
42 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49041
diff
changeset
|
43 |
#include "oops/compressedOops.inline.hpp" |
1 | 44 |
|
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
45 |
PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL; |
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
46 |
OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; |
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
47 |
PreservedMarksSet* PSPromotionManager::_preserved_marks_set = NULL; |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
48 |
PSOldGen* PSPromotionManager::_old_gen = NULL; |
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
49 |
MutableSpace* PSPromotionManager::_young_space = NULL; |
1 | 50 |
|
51 |
void PSPromotionManager::initialize() { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
52 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 53 |
|
54 |
_old_gen = heap->old_gen(); |
|
55 |
_young_space = heap->young_gen()->to_space(); |
|
56 |
||
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
57 |
const uint promotion_manager_num = ParallelGCThreads + 1; |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
58 |
|
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
59 |
// To prevent false sharing, we pad the PSPromotionManagers |
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
60 |
// and make sure that the first instance starts at a cache line. |
1 | 61 |
assert(_manager_array == NULL, "Attempt to initialize twice"); |
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
62 |
_manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(promotion_manager_num); |
1 | 63 |
guarantee(_manager_array != NULL, "Could not initialize promotion manager"); |
64 |
||
6248
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
6067
diff
changeset
|
65 |
_stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); |
18025 | 66 |
guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager"); |
1 | 67 |
|
68 |
// Create and register the PSPromotionManager(s) for the worker threads. |
|
69 |
for(uint i=0; i<ParallelGCThreads; i++) { |
|
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
70 |
stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth()); |
1 | 71 |
} |
72 |
// The VMThread gets its own PSPromotionManager, which is not available |
|
73 |
// for work stealing. |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
74 |
|
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
75 |
assert(_preserved_marks_set == NULL, "Attempt to initialize twice"); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
76 |
_preserved_marks_set = new PreservedMarksSet(true /* in_c_heap */); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
77 |
guarantee(_preserved_marks_set != NULL, "Could not initialize preserved marks set"); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
78 |
_preserved_marks_set->init(promotion_manager_num); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
79 |
for (uint i = 0; i < promotion_manager_num; i += 1) { |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
80 |
_manager_array[i].register_preserved_marks(_preserved_marks_set->get(i)); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
81 |
} |
1 | 82 |
} |
83 |
||
29208
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
84 |
// Helper functions to get around the circular dependency between |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
85 |
// psScavenge.inline.hpp and psPromotionManager.inline.hpp. |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
86 |
bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) { |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
87 |
return PSScavenge::should_scavenge(p, check_to_space); |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
88 |
} |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
89 |
bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) { |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
90 |
return PSScavenge::should_scavenge(p, check_to_space); |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
91 |
} |
b570d043f295
8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp
stefank
parents:
27154
diff
changeset
|
92 |
|
31330
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
30764
diff
changeset
|
93 |
PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) { |
77061bb01b18
8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint
david
parents:
30764
diff
changeset
|
94 |
assert(index < ParallelGCThreads, "index out of range"); |
1 | 95 |
assert(_manager_array != NULL, "Sanity"); |
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
96 |
return &_manager_array[index]; |
1 | 97 |
} |
98 |
||
99 |
PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { |
|
100 |
assert(_manager_array != NULL, "Sanity"); |
|
19285
0a3b3f115402
8022880: False sharing between PSPromotionManager instances
stefank
parents:
18025
diff
changeset
|
101 |
return &_manager_array[ParallelGCThreads]; |
1 | 102 |
} |
103 |
||
104 |
void PSPromotionManager::pre_scavenge() { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
105 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 106 |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
107 |
_preserved_marks_set->assert_empty(); |
1 | 108 |
_young_space = heap->young_gen()->to_space(); |
109 |
||
110 |
for(uint i=0; i<ParallelGCThreads+1; i++) { |
|
111 |
manager_array(i)->reset(); |
|
112 |
} |
|
113 |
} |
|
114 |
||
18025 | 115 |
bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) { |
116 |
bool promotion_failure_occurred = false; |
|
117 |
||
35061 | 118 |
TASKQUEUE_STATS_ONLY(print_taskqueue_stats()); |
5918 | 119 |
for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
1 | 120 |
PSPromotionManager* manager = manager_array(i); |
6248
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
6067
diff
changeset
|
121 |
assert(manager->claimed_stack_depth()->is_empty(), "should be empty"); |
18025 | 122 |
if (manager->_promotion_failed_info.has_failed()) { |
123 |
gc_tracer.report_promotion_failed(manager->_promotion_failed_info); |
|
124 |
promotion_failure_occurred = true; |
|
125 |
} |
|
1 | 126 |
manager->flush_labs(); |
127 |
} |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
128 |
if (!promotion_failure_occurred) { |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
129 |
// If there was no promotion failure, the preserved mark stacks |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
130 |
// should be empty. |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
131 |
_preserved_marks_set->assert_empty(); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
132 |
} |
18025 | 133 |
return promotion_failure_occurred; |
1 | 134 |
} |
135 |
||
6067 | 136 |
#if TASKQUEUE_STATS |
1 | 137 |
void |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
138 |
PSPromotionManager::print_local_stats(outputStream* const out, uint i) const { |
6067 | 139 |
#define FMT " " SIZE_FORMAT_W(10) |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
140 |
out->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals, |
6067 | 141 |
_arrays_chunked, _array_chunks_processed); |
142 |
#undef FMT |
|
143 |
} |
|
144 |
||
145 |
static const char* const pm_stats_hdr[] = { |
|
146 |
" --------masked------- arrays array", |
|
147 |
"thr push steal chunked chunks", |
|
148 |
"--- ---------- ---------- ---------- ----------" |
|
149 |
}; |
|
150 |
||
151 |
void |
|
35061 | 152 |
PSPromotionManager::print_taskqueue_stats() { |
51256
604581924221
8208297: Allow printing of taskqueue stats if compiled in in product builds
tschatzl
parents:
50752
diff
changeset
|
153 |
if (!log_is_enabled(Trace, gc, task, stats)) { |
35061 | 154 |
return; |
155 |
} |
|
37242 | 156 |
Log(gc, task, stats) log; |
35061 | 157 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
158 |
LogStream ls(log.trace()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
159 |
outputStream* out = &ls; |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
160 |
out->print_cr("== GC Tasks Stats, GC %3d", |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
161 |
ParallelScavengeHeap::heap()->total_collections()); |
1 | 162 |
|
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
163 |
TaskQueueStats totals; |
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
164 |
out->print("thr "); TaskQueueStats::print_header(1, out); out->cr(); |
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
165 |
out->print("--- "); TaskQueueStats::print_header(2, out); out->cr(); |
6067 | 166 |
for (uint i = 0; i < ParallelGCThreads + 1; ++i) { |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
167 |
TaskQueueStats& next = manager_array(i)->_claimed_stack_depth.stats; |
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
168 |
out->print("%3d ", i); next.print(out); out->cr(); |
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
169 |
totals += next; |
6067 | 170 |
} |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
171 |
out->print("tot "); totals.print(out); out->cr(); |
6067 | 172 |
|
173 |
const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]); |
|
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
174 |
for (uint i = 0; i < hlines; ++i) out->print_cr("%s", pm_stats_hdr[i]); |
6067 | 175 |
for (uint i = 0; i < ParallelGCThreads + 1; ++i) { |
27154
ccf8883e01be
8027428: Different conditions for printing taskqueue statistics for parallel gc, parNew and G1
jwilhelm
parents:
24424
diff
changeset
|
176 |
manager_array(i)->print_local_stats(out, i); |
1 | 177 |
} |
178 |
} |
|
179 |
||
6067 | 180 |
void |
181 |
PSPromotionManager::reset_stats() { |
|
6248
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
6067
diff
changeset
|
182 |
claimed_stack_depth()->stats.reset(); |
6067 | 183 |
_masked_pushes = _masked_steals = 0; |
184 |
_arrays_chunked = _array_chunks_processed = 0; |
|
185 |
} |
|
186 |
#endif // TASKQUEUE_STATS |
|
1 | 187 |
|
188 |
PSPromotionManager::PSPromotionManager() { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
189 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 190 |
|
191 |
// We set the old lab's start array. |
|
192 |
_old_lab.set_start_array(old_gen()->start_array()); |
|
193 |
||
194 |
uint queue_size; |
|
6248
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
6067
diff
changeset
|
195 |
claimed_stack_depth()->initialize(); |
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
6067
diff
changeset
|
196 |
queue_size = claimed_stack_depth()->max_elems(); |
1 | 197 |
|
198 |
_totally_drain = (ParallelGCThreads == 1) || (GCDrainStackTargetSize == 0); |
|
199 |
if (_totally_drain) { |
|
200 |
_target_stack_size = 0; |
|
201 |
} else { |
|
202 |
// don't let the target stack size to be more than 1/4 of the entries |
|
203 |
_target_stack_size = (uint) MIN2((uint) GCDrainStackTargetSize, |
|
204 |
(uint) (queue_size / 4)); |
|
205 |
} |
|
206 |
||
207 |
_array_chunk_size = ParGCArrayScanChunk; |
|
208 |
// let's choose 1.5x the chunk size |
|
209 |
_min_array_size_for_chunking = 3 * _array_chunk_size / 2; |
|
210 |
||
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
211 |
_preserved_marks = NULL; |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
212 |
|
1 | 213 |
reset(); |
214 |
} |
|
215 |
||
216 |
void PSPromotionManager::reset() { |
|
5918 | 217 |
assert(stacks_empty(), "reset of non-empty stack"); |
1 | 218 |
|
219 |
// We need to get an assert in here to make sure the labs are always flushed. |
|
220 |
||
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
221 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 222 |
|
223 |
// Do not prefill the LAB's, save heap wastage! |
|
224 |
HeapWord* lab_base = young_space()->top(); |
|
225 |
_young_lab.initialize(MemRegion(lab_base, (size_t)0)); |
|
226 |
_young_gen_is_full = false; |
|
227 |
||
228 |
lab_base = old_gen()->object_space()->top(); |
|
229 |
_old_lab.initialize(MemRegion(lab_base, (size_t)0)); |
|
230 |
_old_gen_is_full = false; |
|
231 |
||
18025 | 232 |
_promotion_failed_info.reset(); |
233 |
||
6067 | 234 |
TASKQUEUE_STATS_ONLY(reset_stats()); |
1 | 235 |
} |
236 |
||
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
237 |
void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_marks) { |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
238 |
assert(_preserved_marks == NULL, "do not set it twice"); |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
239 |
_preserved_marks = preserved_marks; |
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
240 |
} |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
241 |
|
38080 | 242 |
void PSPromotionManager::restore_preserved_marks() { |
57770
b5ca334ed54c
8224662: Parallel GC: Use WorkGang (4: SharedRestorePreservedMarksTaskExecutor)
lkorinth
parents:
52117
diff
changeset
|
243 |
SharedRestorePreservedMarksTaskExecutor task_executor(&ParallelScavengeHeap::heap()->workers()); |
39228
32ce84798166
8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp
lmesnik
parents:
38080
diff
changeset
|
244 |
_preserved_marks_set->restore(&task_executor); |
38080 | 245 |
} |
246 |
||
1 | 247 |
void PSPromotionManager::drain_stacks_depth(bool totally_drain) { |
248 |
totally_drain = totally_drain || _totally_drain; |
|
249 |
||
250 |
#ifdef ASSERT |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
30150
diff
changeset
|
251 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 252 |
MutableSpace* to_space = heap->young_gen()->to_space(); |
253 |
MutableSpace* old_space = heap->old_gen()->object_space(); |
|
254 |
#endif /* ASSERT */ |
|
255 |
||
5918 | 256 |
OopStarTaskQueue* const tq = claimed_stack_depth(); |
1 | 257 |
do { |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
258 |
StarTask p; |
1 | 259 |
|
260 |
// Drain overflow stack first, so other threads can steal from |
|
261 |
// claimed stack while we work. |
|
5918 | 262 |
while (tq->pop_overflow(p)) { |
263 |
process_popped_location_depth(p); |
|
1 | 264 |
} |
265 |
||
266 |
if (totally_drain) { |
|
5918 | 267 |
while (tq->pop_local(p)) { |
1 | 268 |
process_popped_location_depth(p); |
269 |
} |
|
270 |
} else { |
|
5918 | 271 |
while (tq->size() > _target_stack_size && tq->pop_local(p)) { |
1 | 272 |
process_popped_location_depth(p); |
273 |
} |
|
274 |
} |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
39228
diff
changeset
|
275 |
} while ((totally_drain && !tq->taskqueue_empty()) || !tq->overflow_empty()); |
1 | 276 |
|
5918 | 277 |
assert(!totally_drain || tq->taskqueue_empty(), "Sanity"); |
278 |
assert(totally_drain || tq->size() <= _target_stack_size, "Sanity"); |
|
279 |
assert(tq->overflow_empty(), "Sanity"); |
|
1 | 280 |
} |
281 |
||
282 |
void PSPromotionManager::flush_labs() { |
|
5918 | 283 |
assert(stacks_empty(), "Attempt to flush lab with live stack"); |
1 | 284 |
|
285 |
// If either promotion lab fills up, we can flush the |
|
286 |
// lab but not refill it, so check first. |
|
287 |
assert(!_young_lab.is_flushed() || _young_gen_is_full, "Sanity"); |
|
288 |
if (!_young_lab.is_flushed()) |
|
289 |
_young_lab.flush(); |
|
290 |
||
291 |
assert(!_old_lab.is_flushed() || _old_gen_is_full, "Sanity"); |
|
292 |
if (!_old_lab.is_flushed()) |
|
293 |
_old_lab.flush(); |
|
294 |
||
295 |
// Let PSScavenge know if we overflowed |
|
296 |
if (_young_gen_is_full) { |
|
297 |
PSScavenge::set_survivor_overflow(true); |
|
298 |
} |
|
299 |
} |
|
300 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
301 |
template <class T> void PSPromotionManager::process_array_chunk_work( |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
302 |
oop obj, |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
303 |
int start, int end) { |
8685
f8edcc58cca7
6820066: Check that -XX:ParGCArrayScanChunk has a value larger than zero.
jwilhelm
parents:
7397
diff
changeset
|
304 |
assert(start <= end, "invariant"); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
305 |
T* const base = (T*)objArrayOop(obj)->base(); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
306 |
T* p = base + start; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
307 |
T* const chunk_end = base + end; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
308 |
while (p < chunk_end) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
309 |
if (PSScavenge::should_scavenge(p)) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
310 |
claim_or_forward_depth(p); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
311 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
312 |
++p; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
313 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
314 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
315 |
|
1 | 316 |
void PSPromotionManager::process_array_chunk(oop old) { |
317 |
assert(PSChunkLargeArrays, "invariant"); |
|
318 |
assert(old->is_objArray(), "invariant"); |
|
319 |
assert(old->is_forwarded(), "invariant"); |
|
320 |
||
6067 | 321 |
TASKQUEUE_STATS_ONLY(++_array_chunks_processed); |
1 | 322 |
|
323 |
oop const obj = old->forwardee(); |
|
324 |
||
325 |
int start; |
|
326 |
int const end = arrayOop(old)->length(); |
|
327 |
if (end > (int) _min_array_size_for_chunking) { |
|
328 |
// we'll chunk more |
|
329 |
start = end - _array_chunk_size; |
|
330 |
assert(start > 0, "invariant"); |
|
331 |
arrayOop(old)->set_length(start); |
|
332 |
push_depth(mask_chunked_array_oop(old)); |
|
6067 | 333 |
TASKQUEUE_STATS_ONLY(++_masked_pushes); |
1 | 334 |
} else { |
335 |
// this is the final chunk for this array |
|
336 |
start = 0; |
|
337 |
int const actual_length = arrayOop(obj)->length(); |
|
338 |
arrayOop(old)->set_length(actual_length); |
|
339 |
} |
|
340 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
341 |
if (UseCompressedOops) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
342 |
process_array_chunk_work<narrowOop>(obj, start, end); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
343 |
} else { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
344 |
process_array_chunk_work<oop>(obj, start, end); |
1 | 345 |
} |
346 |
} |
|
347 |
||
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
57773
diff
changeset
|
348 |
oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) { |
1 | 349 |
assert(_old_gen_is_full || PromotionFailureALot, "Sanity"); |
350 |
||
351 |
// Attempt to CAS in the header. |
|
352 |
// This tests if the header is still the same as when |
|
353 |
// this started. If it is the same (i.e., no forwarding |
|
354 |
// pointer has been installed), then this thread owns |
|
355 |
// it. |
|
356 |
if (obj->cas_forward_to(obj, obj_mark)) { |
|
357 |
// We won any races, we "own" this object. |
|
358 |
assert(obj == obj->forwardee(), "Sanity"); |
|
359 |
||
18025 | 360 |
_promotion_failed_info.register_copy_failure(obj->size()); |
361 |
||
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29702
diff
changeset
|
362 |
push_contents(obj); |
1 | 363 |
|
37045
41e3f98fa3dc
8146991: Introduce per-worker preserved mark stacks in ParallelGC
tonyp
parents:
35901
diff
changeset
|
364 |
_preserved_marks->push_if_necessary(obj, obj_mark); |
1 | 365 |
} else { |
366 |
// We lost, someone else "owns" this object |
|
367 |
guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed."); |
|
368 |
||
369 |
// No unallocation to worry about. |
|
370 |
obj = obj->forwardee(); |
|
371 |
} |
|
372 |
||
35061 | 373 |
log_develop_trace(gc, scavenge)("{promotion-failure %s " PTR_FORMAT " (%d)}", obj->klass()->internal_name(), p2i(obj), obj->size()); |
1 | 374 |
|
375 |
return obj; |
|
376 |
} |