annotate src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp @ 453:c96030fff130

6684579: SoftReference processing can be made more efficient Summary: For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not. Reviewed-by: jmasa
author ysr
date Thu, 20 Nov 2008 16:56:09 -0800
parents 81cd571500b0
children ad8c8ca4ab0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 ObjectStartArray* ParCompactionManager::_start_array = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
33 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 ParCompactionManager::ParCompactionManager() :
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _action(CopyAndUpdate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
39 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
42 _start_array = old_gen()->start_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 marking_stack()->initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // We want the overflow stack to be permanent
a61af66fc99e Initial load
duke
parents:
diff changeset
48 _overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
49 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
50 region_stack()->initialize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
52 region_stack()->initialize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // We want the overflow stack to be permanent
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
55 _region_overflow_stack =
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Note that _revisit_klass_stack is allocated out of the
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // C heap (as opposed to out of ResourceArena).
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int size =
a61af66fc99e Initial load
duke
parents:
diff changeset
62 (SystemDictionary::number_of_classes() * 2) * 2 / ParallelGCThreads;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _revisit_klass_stack = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(size, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ParCompactionManager::~ParCompactionManager() {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 delete _overflow_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 delete _revisit_klass_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // _manager_array and _stack_array are statics
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // shared with all instances of ParCompactionManager
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // should not be deallocated.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 assert(PSParallelCompact::gc_task_manager() != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 "Needed for initialization");
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _mark_bitmap = mbm;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 assert(_manager_array == NULL, "Attempt to initialize twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1 );
a61af66fc99e Initial load
duke
parents:
diff changeset
85 guarantee(_manager_array != NULL, "Could not initialize promotion manager");
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _stack_array = new OopTaskQueueSet(parallel_gc_threads);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 guarantee(_stack_array != NULL, "Count not initialize promotion manager");
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
89 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
90 guarantee(_region_array != NULL, "Count not initialize promotion manager");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Create and register the ParCompactionManager(s) for the worker threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 for(uint i=0; i<parallel_gc_threads; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _manager_array[i] = new ParCompactionManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
a61af66fc99e Initial load
duke
parents:
diff changeset
96 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
97 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
98 region_array()->register_queue(i, _manager_array[i]->region_stack()->task_queue());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
100 region_array()->register_queue(i, _manager_array[i]->region_stack());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // The VMThread gets its own ParCompactionManager, which is not available
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // for work stealing.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 _manager_array[parallel_gc_threads] = new ParCompactionManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 guarantee(_manager_array[parallel_gc_threads] != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 "Could not create ParCompactionManager");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 assert(PSParallelCompact::gc_task_manager()->workers() != 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
110 "Not initialized?");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 bool ParCompactionManager::should_update() {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return (action() == ParCompactionManager::Update) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
116 (action() == ParCompactionManager::CopyAndUpdate) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
117 (action() == ParCompactionManager::UpdateAndCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 bool ParCompactionManager::should_copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return (action() == ParCompactionManager::Copy) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
123 (action() == ParCompactionManager::CopyAndUpdate) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
124 (action() == ParCompactionManager::UpdateAndCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 bool ParCompactionManager::should_verify_only() {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return action() == ParCompactionManager::VerifyUpdate;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 bool ParCompactionManager::should_reset_only() {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert(action() != NotValid, "Action is not set");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return action() == ParCompactionManager::ResetObjects;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // For now save on a stack
a61af66fc99e Initial load
duke
parents:
diff changeset
138 void ParCompactionManager::save_for_scanning(oop m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 stack_push(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void ParCompactionManager::stack_push(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if(!marking_stack()->push(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 overflow_stack()->push(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 oop ParCompactionManager::retrieve_for_scanning() {
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Should not be used in the parallel case
a61af66fc99e Initial load
duke
parents:
diff changeset
152 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
156 // Save region on a stack
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
157 void ParCompactionManager::save_for_processing(size_t region_index) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
158 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
159 const ParallelCompactData& sd = PSParallelCompact::summary_data();
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
160 ParallelCompactData::RegionData* const region_ptr = sd.region(region_index);
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
161 assert(region_ptr->claimed(), "must be claimed");
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
162 assert(region_ptr->_pushed++ == 0, "should only be pushed once");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #endif
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
164 region_stack_push(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
167 void ParCompactionManager::region_stack_push(size_t region_index) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
169 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
170 region_stack()->save(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
171 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
172 if(!region_stack()->push(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
173 region_overflow_stack()->push(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
178 bool ParCompactionManager::retrieve_for_processing(size_t& region_index) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
179 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
180 return region_stack()->retrieve(region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
181 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Should not be used in the parallel case
a61af66fc99e Initial load
duke
parents:
diff changeset
183 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 ParCompactionManager*
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ParCompactionManager::gc_thread_compaction_manager(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 assert(_manager_array != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return _manager_array[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 void ParCompactionManager::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 for(uint i=0; i<ParallelGCThreads+1; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 manager_array(i)->revisit_klass_stack()->clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void ParCompactionManager::drain_marking_stacks(OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
203 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 MutableSpace* to_space = heap->young_gen()->to_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 MutableSpace* old_space = heap->old_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 MutableSpace* perm_space = heap->perm_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 #endif /* ASSERT */
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Drain overflow stack first, so other threads can steal from
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // claimed stack while we work.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 while(!overflow_stack()->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 oop obj = overflow_stack()->pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
217 obj->follow_contents(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // obj is a reference!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
222 while (marking_stack()->pop_local(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // It would be nice to assert about the type of objects we might
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // pop, but they can come from anywhere, unfortunately.
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 } while((marking_stack()->size() != 0) || (overflow_stack()->length() != 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 assert(marking_stack()->size() == 0, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 assert(overflow_stack()->length() == 0, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
233 void ParCompactionManager::drain_region_overflow_stack() {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
234 size_t region_index = (size_t) -1;
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
235 while(region_stack()->retrieve_from_overflow(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
236 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
240 void ParCompactionManager::drain_region_stacks() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
242 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
244 MutableSpace* to_space = heap->young_gen()->to_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 MutableSpace* old_space = heap->old_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 MutableSpace* perm_space = heap->perm_gen()->object_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 #endif /* ASSERT */
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 #if 1 // def DO_PARALLEL - the serial code hasn't been updated
a61af66fc99e Initial load
duke
parents:
diff changeset
250 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
251
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
252 #ifdef USE_RegionTaskQueueWithOverflow
0
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Drain overflow stack first, so other threads can steal from
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // claimed stack while we work.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
255 size_t region_index = (size_t) -1;
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
256 while(region_stack()->retrieve_from_overflow(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
257 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
260 while (region_stack()->retrieve_from_stealable_queue(region_index)) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
261 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
263 } while (!region_stack()->is_empty());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
264 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // Drain overflow stack first, so other threads can steal from
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // claimed stack while we work.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
267 while(!region_overflow_stack()->is_empty()) {
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
268 size_t region_index = region_overflow_stack()->pop();
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
269 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
272 size_t region_index = -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // obj is a reference!!!
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
274 while (region_stack()->pop_local(region_index)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // It would be nice to assert about the type of objects we might
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // pop, but they can come from anywhere, unfortunately.
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
277 PSParallelCompact::fill_and_update_region(this, region_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
279 } while((region_stack()->size() != 0) ||
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
280 (region_overflow_stack()->length() != 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
281 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
282
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
283 #ifdef USE_RegionTaskQueueWithOverflow
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
284 assert(region_stack()->is_empty(), "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
285 #else
375
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
286 assert(region_stack()->size() == 0, "Sanity");
81cd571500b0 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 0
diff changeset
287 assert(region_overflow_stack()->length() == 0, "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
288 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
289 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
290 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 while (obj = retrieve_for_scanning()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 obj->follow_contents(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
298 bool ParCompactionManager::stacks_have_been_allocated() {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return (revisit_klass_stack()->data_addr() != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 #endif