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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/mutableSpace.hpp"
27 #include "gc/parallel/parallelScavengeHeap.hpp"
28 #include "gc/parallel/psOldGen.hpp"
29 #include "gc/parallel/psPromotionManager.inline.hpp"
30 #include "gc/parallel/psScavenge.inline.hpp"
31 #include "gc/shared/gcTrace.hpp"
32 #include "gc/shared/preservedMarks.inline.hpp"
33 #include "gc/shared/taskqueue.inline.hpp"
34 #include "logging/log.hpp"
35 #include "memory/allocation.inline.hpp"
36 #include "memory/memRegion.hpp"
37 #include "memory/padded.inline.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "oops/instanceKlass.inline.hpp"
40 #include "oops/instanceMirrorKlass.inline.hpp"
41 #include "oops/objArrayKlass.inline.hpp"
42 #include "oops/oop.inline.hpp"
43
44 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
45 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
220
221 // Do not prefill the LAB's, save heap wastage!
222 HeapWord* lab_base = young_space()->top();
223 _young_lab.initialize(MemRegion(lab_base, (size_t)0));
224 _young_gen_is_full = false;
225
226 lab_base = old_gen()->object_space()->top();
227 _old_lab.initialize(MemRegion(lab_base, (size_t)0));
228 _old_gen_is_full = false;
229
230 _promotion_failed_info.reset();
231
232 TASKQUEUE_STATS_ONLY(reset_stats());
233 }
234
235 void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_marks) {
236 assert(_preserved_marks == NULL, "do not set it twice");
237 _preserved_marks = preserved_marks;
238 }
239
240 void PSPromotionManager::restore_preserved_marks() {
241 _preserved_marks_set->restore(PSScavenge::gc_task_manager());
242 }
243
244 void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
245 totally_drain = totally_drain || _totally_drain;
246
247 #ifdef ASSERT
248 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
249 MutableSpace* to_space = heap->young_gen()->to_space();
250 MutableSpace* old_space = heap->old_gen()->object_space();
251 #endif /* ASSERT */
252
253 OopStarTaskQueue* const tq = claimed_stack_depth();
254 do {
255 StarTask p;
256
257 // Drain overflow stack first, so other threads can steal from
258 // claimed stack while we work.
259 while (tq->pop_overflow(p)) {
260 process_popped_location_depth(p);
261 }
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
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"
33 #include "gc/shared/preservedMarks.inline.hpp"
34 #include "gc/shared/taskqueue.inline.hpp"
35 #include "logging/log.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/memRegion.hpp"
38 #include "memory/padded.inline.hpp"
39 #include "memory/resourceArea.hpp"
40 #include "oops/instanceKlass.inline.hpp"
41 #include "oops/instanceMirrorKlass.inline.hpp"
42 #include "oops/objArrayKlass.inline.hpp"
43 #include "oops/oop.inline.hpp"
44
45 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
46 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
221
222 // Do not prefill the LAB's, save heap wastage!
223 HeapWord* lab_base = young_space()->top();
224 _young_lab.initialize(MemRegion(lab_base, (size_t)0));
225 _young_gen_is_full = false;
226
227 lab_base = old_gen()->object_space()->top();
228 _old_lab.initialize(MemRegion(lab_base, (size_t)0));
229 _old_gen_is_full = false;
230
231 _promotion_failed_info.reset();
232
233 TASKQUEUE_STATS_ONLY(reset_stats());
234 }
235
236 void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_marks) {
237 assert(_preserved_marks == NULL, "do not set it twice");
238 _preserved_marks = preserved_marks;
239 }
240
241 class ParRestoreGCTask : public GCTask {
242 private:
243 const uint _id;
244 PreservedMarksSet* const _preserved_marks_set;
245 volatile size_t* const _total_size_addr;
246
247 public:
248 virtual char* name() {
249 return (char*) "preserved mark restoration task";
250 }
251
252 virtual void do_it(GCTaskManager* manager, uint which){
253 _preserved_marks_set->get(_id)->restore_and_increment(_total_size_addr);
254 }
255
256 ParRestoreGCTask(uint id,
257 PreservedMarksSet* preserved_marks_set,
258 volatile size_t* total_size_addr)
259 : _id(id),
260 _preserved_marks_set(preserved_marks_set),
261 _total_size_addr(total_size_addr) { }
262 };
263
264 class PSRestorePreservedMarksTaskExecutor : public RestorePreservedMarksTaskExecutor {
265 private:
266 GCTaskManager* _gc_task_manager;
267
268 public:
269 PSRestorePreservedMarksTaskExecutor(GCTaskManager* gc_task_manager)
270 : _gc_task_manager(gc_task_manager) { }
271
272 void restore(PreservedMarksSet* preserved_marks_set,
273 volatile size_t* total_size_addr) {
274 // GCTask / GCTaskQueue are ResourceObjs
275 ResourceMark rm;
276
277 GCTaskQueue* q = GCTaskQueue::create();
278 for (uint i = 0; i < preserved_marks_set->num(); i += 1) {
279 q->enqueue(new ParRestoreGCTask(i, preserved_marks_set, total_size_addr));
280 }
281 _gc_task_manager->execute_and_wait(q);
282 }
283 };
284
285 void PSPromotionManager::restore_preserved_marks() {
286 PSRestorePreservedMarksTaskExecutor task_executor(PSScavenge::gc_task_manager());
287 _preserved_marks_set->restore(&task_executor);
288 }
289
290 void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
291 totally_drain = totally_drain || _totally_drain;
292
293 #ifdef ASSERT
294 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
295 MutableSpace* to_space = heap->young_gen()->to_space();
296 MutableSpace* old_space = heap->old_gen()->object_space();
297 #endif /* ASSERT */
298
299 OopStarTaskQueue* const tq = claimed_stack_depth();
300 do {
301 StarTask p;
302
303 // Drain overflow stack first, so other threads can steal from
304 // claimed stack while we work.
305 while (tq->pop_overflow(p)) {
306 process_popped_location_depth(p);
307 }
|