1 /* |
1 /* |
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.inline.hpp" |
26 #include "classfile/javaClasses.inline.hpp" |
27 #include "gc/parallel/gcTaskManager.hpp" |
|
28 #include "gc/parallel/mutableSpace.hpp" |
27 #include "gc/parallel/mutableSpace.hpp" |
29 #include "gc/parallel/parallelScavengeHeap.hpp" |
28 #include "gc/parallel/parallelScavengeHeap.hpp" |
30 #include "gc/parallel/psOldGen.hpp" |
29 #include "gc/parallel/psOldGen.hpp" |
31 #include "gc/parallel/psPromotionManager.inline.hpp" |
30 #include "gc/parallel/psPromotionManager.inline.hpp" |
32 #include "gc/parallel/psScavenge.inline.hpp" |
31 #include "gc/parallel/psScavenge.inline.hpp" |
238 void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_marks) { |
237 void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_marks) { |
239 assert(_preserved_marks == NULL, "do not set it twice"); |
238 assert(_preserved_marks == NULL, "do not set it twice"); |
240 _preserved_marks = preserved_marks; |
239 _preserved_marks = preserved_marks; |
241 } |
240 } |
242 |
241 |
243 class ParRestoreGCTask : public GCTask { |
|
244 private: |
|
245 const uint _id; |
|
246 PreservedMarksSet* const _preserved_marks_set; |
|
247 volatile size_t* const _total_size_addr; |
|
248 |
|
249 public: |
|
250 virtual char* name() { |
|
251 return (char*) "preserved mark restoration task"; |
|
252 } |
|
253 |
|
254 virtual void do_it(GCTaskManager* manager, uint which){ |
|
255 _preserved_marks_set->get(_id)->restore_and_increment(_total_size_addr); |
|
256 } |
|
257 |
|
258 ParRestoreGCTask(uint id, |
|
259 PreservedMarksSet* preserved_marks_set, |
|
260 volatile size_t* total_size_addr) |
|
261 : _id(id), |
|
262 _preserved_marks_set(preserved_marks_set), |
|
263 _total_size_addr(total_size_addr) { } |
|
264 }; |
|
265 |
|
266 class PSRestorePreservedMarksTaskExecutor : public RestorePreservedMarksTaskExecutor { |
|
267 private: |
|
268 GCTaskManager* _gc_task_manager; |
|
269 |
|
270 public: |
|
271 PSRestorePreservedMarksTaskExecutor(GCTaskManager* gc_task_manager) |
|
272 : _gc_task_manager(gc_task_manager) { } |
|
273 |
|
274 void restore(PreservedMarksSet* preserved_marks_set, |
|
275 volatile size_t* total_size_addr) { |
|
276 // GCTask / GCTaskQueue are ResourceObjs |
|
277 ResourceMark rm; |
|
278 |
|
279 GCTaskQueue* q = GCTaskQueue::create(); |
|
280 for (uint i = 0; i < preserved_marks_set->num(); i += 1) { |
|
281 q->enqueue(new ParRestoreGCTask(i, preserved_marks_set, total_size_addr)); |
|
282 } |
|
283 _gc_task_manager->execute_and_wait(q); |
|
284 } |
|
285 }; |
|
286 |
|
287 void PSPromotionManager::restore_preserved_marks() { |
242 void PSPromotionManager::restore_preserved_marks() { |
288 PSRestorePreservedMarksTaskExecutor task_executor(PSScavenge::gc_task_manager()); |
243 SharedRestorePreservedMarksTaskExecutor task_executor(&ParallelScavengeHeap::heap()->workers()); |
289 _preserved_marks_set->restore(&task_executor); |
244 _preserved_marks_set->restore(&task_executor); |
290 } |
245 } |
291 |
246 |
292 void PSPromotionManager::drain_stacks_depth(bool totally_drain) { |
247 void PSPromotionManager::drain_stacks_depth(bool totally_drain) { |
293 totally_drain = totally_drain || _totally_drain; |
248 totally_drain = totally_drain || _totally_drain; |
388 } else { |
343 } else { |
389 process_array_chunk_work<oop>(obj, start, end); |
344 process_array_chunk_work<oop>(obj, start, end); |
390 } |
345 } |
391 } |
346 } |
392 |
347 |
393 oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) { |
348 oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) { |
394 assert(_old_gen_is_full || PromotionFailureALot, "Sanity"); |
349 assert(_old_gen_is_full || PromotionFailureALot, "Sanity"); |
395 |
350 |
396 // Attempt to CAS in the header. |
351 // Attempt to CAS in the header. |
397 // This tests if the header is still the same as when |
352 // This tests if the header is still the same as when |
398 // this started. If it is the same (i.e., no forwarding |
353 // this started. If it is the same (i.e., no forwarding |