Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp @ 20501:c204e2044c29
8038624: interpretedVFrame::expressions() must respect InterpreterOopMap for liveness
Reviewed-by: coleenp, minqi
author | mgronlun |
---|---|
date | Mon, 29 Sep 2014 13:12:48 +0200 |
parents | 92ef81e2f571 |
children |
rev | line source |
---|---|
0 | 1 /* |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6831
diff
changeset
|
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp" | |
28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp" | |
29 #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" | |
30 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" | |
31 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp" | |
32 #include "gc_implementation/parallelScavenge/psOldGen.hpp" | |
33 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" | |
34 #include "oops/objArrayKlass.inline.hpp" | |
35 #include "oops/oop.inline.hpp" | |
36 #include "oops/oop.pcgc.inline.hpp" | |
37 #include "utilities/stack.inline.hpp" | |
0 | 38 |
39 PSOldGen* ParCompactionManager::_old_gen = NULL; | |
40 ParCompactionManager** ParCompactionManager::_manager_array = NULL; | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
41 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
42 RegionTaskQueue** ParCompactionManager::_region_list = NULL; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
43 |
0 | 44 OopTaskQueueSet* ParCompactionManager::_stack_array = NULL; |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
45 ParCompactionManager::ObjArrayTaskQueueSet* |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
46 ParCompactionManager::_objarray_queues = NULL; |
0 | 47 ObjectStartArray* ParCompactionManager::_start_array = NULL; |
48 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL; | |
1638 | 49 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL; |
0 | 50 |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
51 uint* ParCompactionManager::_recycled_stack_index = NULL; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
52 int ParCompactionManager::_recycled_top = -1; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
53 int ParCompactionManager::_recycled_bottom = -1; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
54 |
0 | 55 ParCompactionManager::ParCompactionManager() : |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
56 _action(CopyAndUpdate), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
57 _region_stack(NULL), |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
58 _region_stack_index((uint)max_uintx) { |
0 | 59 |
60 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
61 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
62 | |
63 _old_gen = heap->old_gen(); | |
64 _start_array = old_gen()->start_array(); | |
65 | |
66 marking_stack()->initialize(); | |
1638 | 67 _objarray_stack.initialize(); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
68 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
69 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
70 ParCompactionManager::~ParCompactionManager() { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
71 delete _recycled_stack_index; |
0 | 72 } |
73 | |
74 void ParCompactionManager::initialize(ParMarkBitMap* mbm) { | |
75 assert(PSParallelCompact::gc_task_manager() != NULL, | |
76 "Needed for initialization"); | |
77 | |
78 _mark_bitmap = mbm; | |
79 | |
80 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers(); | |
81 | |
82 assert(_manager_array == NULL, "Attempt to initialize twice"); | |
6197 | 83 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
84 guarantee(_manager_array != NULL, "Could not allocate manager_array"); |
0 | 85 |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
86 _region_list = NEW_C_HEAP_ARRAY(RegionTaskQueue*, |
6197 | 87 parallel_gc_threads+1, mtGC); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
88 guarantee(_region_list != NULL, "Could not initialize promotion manager"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
89 |
6197 | 90 _recycled_stack_index = NEW_C_HEAP_ARRAY(uint, parallel_gc_threads, mtGC); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
91 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
92 // parallel_gc-threads + 1 to be consistent with the number of |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
93 // compaction managers. |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
94 for(uint i=0; i<parallel_gc_threads + 1; i++) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
95 _region_list[i] = new RegionTaskQueue(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
96 region_list(i)->initialize(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
97 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
98 |
0 | 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 | 105 |
106 // Create and register the ParCompactionManager(s) for the worker threads. | |
107 for(uint i=0; i<parallel_gc_threads; i++) { | |
108 _manager_array[i] = new ParCompactionManager(); | |
109 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager"); | |
110 stack_array()->register_queue(i, _manager_array[i]->marking_stack()); | |
1638 | 111 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack); |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
112 region_array()->register_queue(i, region_list(i)); |
0 | 113 } |
114 | |
115 // The VMThread gets its own ParCompactionManager, which is not available | |
116 // for work stealing. | |
117 _manager_array[parallel_gc_threads] = new ParCompactionManager(); | |
118 guarantee(_manager_array[parallel_gc_threads] != NULL, | |
119 "Could not create ParCompactionManager"); | |
120 assert(PSParallelCompact::gc_task_manager()->workers() != 0, | |
121 "Not initialized?"); | |
122 } | |
123 | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
124 int ParCompactionManager::pop_recycled_stack_index() { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
125 assert(_recycled_bottom <= _recycled_top, "list is empty"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
126 // Get the next available index |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
127 if (_recycled_bottom < _recycled_top) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
128 uint cur, next, last; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
129 do { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
130 cur = _recycled_bottom; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
131 next = cur + 1; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
132 last = Atomic::cmpxchg(next, &_recycled_bottom, cur); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
133 } while (cur != last); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
134 return _recycled_stack_index[next]; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
135 } else { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
136 return -1; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
137 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
138 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
139 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
140 void ParCompactionManager::push_recycled_stack_index(uint v) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
141 // Get the next available index |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
142 int cur = Atomic::add(1, &_recycled_top); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
143 _recycled_stack_index[cur] = v; |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
144 assert(_recycled_bottom <= _recycled_top, "list top and bottom are wrong"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
145 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
146 |
0 | 147 bool ParCompactionManager::should_update() { |
148 assert(action() != NotValid, "Action is not set"); | |
149 return (action() == ParCompactionManager::Update) || | |
150 (action() == ParCompactionManager::CopyAndUpdate) || | |
151 (action() == ParCompactionManager::UpdateAndCopy); | |
152 } | |
153 | |
154 bool ParCompactionManager::should_copy() { | |
155 assert(action() != NotValid, "Action is not set"); | |
156 return (action() == ParCompactionManager::Copy) || | |
157 (action() == ParCompactionManager::CopyAndUpdate) || | |
158 (action() == ParCompactionManager::UpdateAndCopy); | |
159 } | |
160 | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
161 void ParCompactionManager::region_list_push(uint list_index, |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
162 size_t region_index) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
163 region_list(list_index)->push(region_index); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
164 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
165 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
166 void ParCompactionManager::verify_region_list_empty(uint list_index) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
167 assert(region_list(list_index)->is_empty(), "Not empty"); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
168 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
1972
diff
changeset
|
169 |
0 | 170 ParCompactionManager* |
171 ParCompactionManager::gc_thread_compaction_manager(int index) { | |
172 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); | |
173 assert(_manager_array != NULL, "Sanity"); | |
174 return _manager_array[index]; | |
175 } | |
176 | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
177 void ParCompactionManager::follow_marking_stacks() { |
0 | 178 do { |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
179 // 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
|
180 oop obj; |
1638 | 181 while (marking_stack()->pop_overflow(obj)) { |
182 obj->follow_contents(this); | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
183 } |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
184 while (marking_stack()->pop_local(obj)) { |
0 | 185 obj->follow_contents(this); |
186 } | |
187 | |
1315
c385bf94cfb8
6935839: excessive marking stack growth during full gcs
jcoomes
parents:
1311
diff
changeset
|
188 // 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
|
189 ObjArrayTask task; |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6831
diff
changeset
|
190 if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) { |
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
6831
diff
changeset
|
191 ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass(); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
192 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
|
193 } |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
194 } while (!marking_stacks_empty()); |
0 | 195 |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
948
diff
changeset
|
196 assert(marking_stacks_empty(), "Sanity"); |
0 | 197 } |
198 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
199 void ParCompactionManager::drain_region_stacks() { |
0 | 200 do { |
1638 | 201 // Drain overflow stack first so other threads can steal. |
202 size_t region_index; | |
203 while (region_stack()->pop_overflow(region_index)) { | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
204 PSParallelCompact::fill_and_update_region(this, region_index); |
0 | 205 } |
206 | |
1638 | 207 while (region_stack()->pop_local(region_index)) { |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
208 PSParallelCompact::fill_and_update_region(this, region_index); |
0 | 209 } |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
210 } while (!region_stack()->is_empty()); |
0 | 211 } |