annotate src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents c385bf94cfb8
children b2a00dd3117c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1315
diff changeset
2 * Copyright (c) 2005, 2009, 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: 1315
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1315
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: 1315
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
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_psCompactionManager.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 PSOldGen* ParCompactionManager::_old_gen = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 ParCompactionManager** ParCompactionManager::_manager_array = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 OopTaskQueueSet* ParCompactionManager::_stack_array = NULL;
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
31 ParCompactionManager::ObjArrayTaskQueueSet*
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
32 ParCompactionManager::_objarray_queues = NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 ObjectStartArray* ParCompactionManager::_start_array = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
35 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 ParCompactionManager::ParCompactionManager() :
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _action(CopyAndUpdate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _start_array = old_gen()->start_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 marking_stack()->initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // We want the overflow stack to be permanent
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
51
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
52 _objarray_queue.initialize();
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
53 _objarray_overflow_stack =
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
54 new (ResourceObj::C_HEAP) ObjArrayOverflowStack(10, true);
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
55
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
56 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
57 region_stack()->initialize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
59 region_stack()->initialize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // We want the overflow stack to be permanent
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
62 _region_overflow_stack =
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Note that _revisit_klass_stack is allocated out of the
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // C heap (as opposed to out of ResourceArena).
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int size =
a61af66fc99e Initial load
duke
parents:
diff changeset
69 (SystemDictionary::number_of_classes() * 2) * 2 / ParallelGCThreads;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _revisit_klass_stack = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(size, true);
941
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
71 // From some experiments (#klass/k)^2 for k = 10 seems a better fit, but this will
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
72 // have to do for now until we are able to investigate a more optimal setting.
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
73 _revisit_mdo_stack = new (ResourceObj::C_HEAP) GrowableArray<DataLayout*>(size*2, true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 ParCompactionManager::~ParCompactionManager() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 delete _overflow_stack;
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
79 delete _objarray_overflow_stack;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80 delete _revisit_klass_stack;
941
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
81 delete _revisit_mdo_stack;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // _manager_array and _stack_array are statics
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // shared with all instances of ParCompactionManager
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // should not be deallocated.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert(PSParallelCompact::gc_task_manager() != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 "Needed for initialization");
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 _mark_bitmap = mbm;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 assert(_manager_array == NULL, "Attempt to initialize twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1 );
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
97 guarantee(_manager_array != NULL, "Could not allocate manager_array");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _stack_array = new OopTaskQueueSet(parallel_gc_threads);
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
100 guarantee(_stack_array != NULL, "Could not allocate stack_array");
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
101 _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads);
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
102 guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
103 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
104 guarantee(_region_array != NULL, "Could not allocate region_array");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Create and register the ParCompactionManager(s) for the worker threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 for(uint i=0; i<parallel_gc_threads; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _manager_array[i] = new ParCompactionManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
111 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_queue);
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
112 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
113 region_array()->register_queue(i, _manager_array[i]->region_stack()->task_queue());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
115 region_array()->register_queue(i, _manager_array[i]->region_stack());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // The VMThread gets its own ParCompactionManager, which is not available
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // for work stealing.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _manager_array[parallel_gc_threads] = new ParCompactionManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 guarantee(_manager_array[parallel_gc_threads] != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 "Could not create ParCompactionManager");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 assert(PSParallelCompact::gc_task_manager()->workers() != 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
125 "Not initialized?");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 bool ParCompactionManager::should_update() {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return (action() == ParCompactionManager::Update) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
131 (action() == ParCompactionManager::CopyAndUpdate) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
132 (action() == ParCompactionManager::UpdateAndCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 bool ParCompactionManager::should_copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 return (action() == ParCompactionManager::Copy) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
138 (action() == ParCompactionManager::CopyAndUpdate) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
139 (action() == ParCompactionManager::UpdateAndCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 bool ParCompactionManager::should_verify_only() {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return action() == ParCompactionManager::VerifyUpdate;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 bool ParCompactionManager::should_reset_only() {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return action() == ParCompactionManager::ResetObjects;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // For now save on a stack
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void ParCompactionManager::save_for_scanning(oop m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 stack_push(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 void ParCompactionManager::stack_push(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if(!marking_stack()->push(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 overflow_stack()->push(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 oop ParCompactionManager::retrieve_for_scanning() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Should not be used in the parallel case
a61af66fc99e Initial load
duke
parents:
diff changeset
167 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
171 // Save region on a stack
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
172 void ParCompactionManager::save_for_processing(size_t region_index) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
173 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
174 const ParallelCompactData& sd = PSParallelCompact::summary_data();
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
175 ParallelCompactData::RegionData* const region_ptr = sd.region(region_index);
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
176 assert(region_ptr->claimed(), "must be claimed");
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
177 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #endif
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
179 region_stack_push(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
182 void ParCompactionManager::region_stack_push(size_t region_index) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
184 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
185 region_stack()->save(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
187 if(!region_stack()->push(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
188 region_overflow_stack()->push(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
193 bool ParCompactionManager::retrieve_for_processing(size_t& region_index) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
194 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
195 return region_stack()->retrieve(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Should not be used in the parallel case
a61af66fc99e Initial load
duke
parents:
diff changeset
198 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 ParCompactionManager*
a61af66fc99e Initial load
duke
parents:
diff changeset
204 ParCompactionManager::gc_thread_compaction_manager(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(_manager_array != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return _manager_array[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 void ParCompactionManager::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 for(uint i=0; i<ParallelGCThreads+1; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 manager_array(i)->revisit_klass_stack()->clear();
941
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
213 manager_array(i)->revisit_mdo_stack()->clear();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
217 void ParCompactionManager::follow_marking_stacks() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 do {
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
219 // Drain the overflow stack first, to allow stealing from the marking stack.
1315
c385bf94cfb8 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 1311
diff changeset
220 oop obj;
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
221 while (!overflow_stack()->is_empty()) {
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
222 overflow_stack()->pop()->follow_contents(this);
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
223 }
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
224 while (marking_stack()->pop_local(obj)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
225 obj->follow_contents(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
1315
c385bf94cfb8 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 1311
diff changeset
228 // Process ObjArrays one at a time to avoid marking stack bloat.
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
229 ObjArrayTask task;
1315
c385bf94cfb8 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 1311
diff changeset
230 if (!_objarray_overflow_stack->is_empty()) {
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
231 task = _objarray_overflow_stack->pop();
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
232 objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint();
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
233 k->oop_follow_contents(this, task.obj(), task.index());
1315
c385bf94cfb8 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 1311
diff changeset
234 } else if (_objarray_queue.pop_local(task)) {
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
235 objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint();
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
236 k->oop_follow_contents(this, task.obj(), task.index());
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
237 }
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
238 } while (!marking_stacks_empty());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
239
1311
2a1472c30599 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 948
diff changeset
240 assert(marking_stacks_empty(), "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
243 void ParCompactionManager::drain_region_overflow_stack() {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
244 size_t region_index = (size_t) -1;
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
245 while(region_stack()->retrieve_from_overflow(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
246 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
250 void ParCompactionManager::drain_region_stacks() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
252 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
254 MutableSpace* to_space = heap->young_gen()->to_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
255 MutableSpace* old_space = heap->old_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
256 MutableSpace* perm_space = heap->perm_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 #endif /* ASSERT */
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 #if 1 // def DO_PARALLEL - the serial code hasn't been updated
a61af66fc99e Initial load
duke
parents:
diff changeset
260 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
261
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
262 #ifdef USE_RegionTaskQueueWithOverflow
0
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Drain overflow stack first, so other threads can steal from
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // claimed stack while we work.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
265 size_t region_index = (size_t) -1;
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
266 while(region_stack()->retrieve_from_overflow(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
267 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
270 while (region_stack()->retrieve_from_stealable_queue(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
271 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
273 } while (!region_stack()->is_empty());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
274 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // Drain overflow stack first, so other threads can steal from
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // claimed stack while we work.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
277 while(!region_overflow_stack()->is_empty()) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
278 size_t region_index = region_overflow_stack()->pop();
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
279 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
282 size_t region_index = -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // obj is a reference!!!
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
284 while (region_stack()->pop_local(region_index)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // It would be nice to assert about the type of objects we might
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // pop, but they can come from anywhere, unfortunately.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
287 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
289 } while((region_stack()->size() != 0) ||
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
290 (region_overflow_stack()->length() != 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
291 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
292
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
293 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
294 assert(region_stack()->is_empty(), "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
295 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
296 assert(region_stack()->size() == 0, "Sanity");
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
297 assert(region_overflow_stack()->length() == 0, "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
298 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
299 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
300 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 while (obj = retrieve_for_scanning()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 obj->follow_contents(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
308 bool ParCompactionManager::stacks_have_been_allocated() {
941
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
309 return (revisit_klass_stack()->data_addr() != NULL &&
8b46c4d82093 4957990: Perm heap bloat in JVM
ysr
parents: 470
diff changeset
310 revisit_mdo_stack()->data_addr() != NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 #endif