author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49722 | a47d1e21b3f1 |
child 50113 | caf115bb98ad |
permissions | -rw-r--r-- |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
1 |
/* |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48969
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
4 |
* |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
8 |
* |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
13 |
* accompanied this code). |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
14 |
* |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
18 |
* |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
21 |
* questions. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
22 |
* |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
23 |
*/ |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
24 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
26 |
#include "gc/g1/g1CollectedHeap.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
27 |
#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
28 |
#include "gc/g1/g1FullCollector.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
29 |
#include "gc/g1/g1FullGCCompactionPoint.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
30 |
#include "gc/g1/g1FullGCMarker.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
31 |
#include "gc/g1/g1FullGCOopClosures.inline.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
32 |
#include "gc/g1/g1FullGCPrepareTask.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
33 |
#include "gc/g1/g1HotCardCache.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
34 |
#include "gc/g1/heapRegion.inline.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
35 |
#include "gc/shared/gcTraceTime.inline.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
36 |
#include "gc/shared/referenceProcessor.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
37 |
#include "logging/log.hpp" |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49635
diff
changeset
|
38 |
#include "oops/oop.inline.hpp" |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
39 |
#include "utilities/ticks.inline.hpp" |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
40 |
|
48969 | 41 |
bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion* hr) { |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
42 |
if (hr->is_humongous()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
43 |
oop obj = oop(hr->humongous_start_region()->bottom()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
44 |
if (_bitmap->is_marked(obj)) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
45 |
if (hr->is_starts_humongous()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
46 |
obj->forward_to(obj); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
47 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
48 |
} else { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
49 |
free_humongous_region(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
50 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
51 |
} else if (!hr->is_pinned()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
52 |
prepare_for_compaction(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
53 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
54 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
55 |
// Reset data structures not valid after Full GC. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
56 |
reset_region_metadata(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
57 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
58 |
return false; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
59 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
60 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
61 |
G1FullGCPrepareTask::G1FullGCPrepareTask(G1FullCollector* collector) : |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
62 |
G1FullGCTask("G1 Prepare Compact Task", collector), |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
63 |
_hrclaimer(collector->workers()), |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
64 |
_freed_regions(false) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
65 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
66 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
67 |
void G1FullGCPrepareTask::set_freed_regions() { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
68 |
if (!_freed_regions) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
69 |
_freed_regions = true; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
70 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
71 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
72 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
73 |
bool G1FullGCPrepareTask::has_freed_regions() { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
74 |
return _freed_regions; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
75 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
76 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
77 |
void G1FullGCPrepareTask::work(uint worker_id) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
78 |
Ticks start = Ticks::now(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
79 |
G1FullGCCompactionPoint* compaction_point = collector()->compaction_point(worker_id); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
80 |
G1CalculatePointersClosure closure(collector()->mark_bitmap(), compaction_point); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
81 |
G1CollectedHeap::heap()->heap_region_par_iterate_from_start(&closure, &_hrclaimer); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
82 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
83 |
// Update humongous region sets |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
84 |
closure.update_sets(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
85 |
compaction_point->update(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
86 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
87 |
// Check if any regions was freed by this worker and store in task. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
88 |
if (closure.freed_regions()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
89 |
set_freed_regions(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
90 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
91 |
log_task("Prepare compaction task", worker_id, start); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
92 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
93 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
94 |
G1FullGCPrepareTask::G1CalculatePointersClosure::G1CalculatePointersClosure(G1CMBitMap* bitmap, |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
95 |
G1FullGCCompactionPoint* cp) : |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
96 |
_g1h(G1CollectedHeap::heap()), |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
97 |
_bitmap(bitmap), |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
98 |
_cp(cp), |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
99 |
_humongous_regions_removed(0) { } |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
100 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
101 |
void G1FullGCPrepareTask::G1CalculatePointersClosure::free_humongous_region(HeapRegion* hr) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
102 |
FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep"); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
103 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
104 |
hr->set_containing_set(NULL); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
105 |
_humongous_regions_removed++; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
106 |
|
49632
64f9ebc85e67
8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents:
49164
diff
changeset
|
107 |
_g1h->free_humongous_region(hr, &dummy_free_list); |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
108 |
prepare_for_compaction(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
109 |
dummy_free_list.remove_all(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
110 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
111 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
112 |
void G1FullGCPrepareTask::G1CalculatePointersClosure::reset_region_metadata(HeapRegion* hr) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
113 |
hr->rem_set()->clear(); |
49632
64f9ebc85e67
8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents:
49164
diff
changeset
|
114 |
hr->clear_cardtable(); |
47885
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
115 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
116 |
if (_g1h->g1_hot_card_cache()->use_cache()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
117 |
_g1h->g1_hot_card_cache()->reset_card_counts(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
118 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
119 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
120 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
121 |
G1FullGCPrepareTask::G1PrepareCompactLiveClosure::G1PrepareCompactLiveClosure(G1FullGCCompactionPoint* cp) : |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
122 |
_cp(cp) { } |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
123 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
124 |
size_t G1FullGCPrepareTask::G1PrepareCompactLiveClosure::apply(oop object) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
125 |
size_t size = object->size(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
126 |
_cp->forward(object, size); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
127 |
return size; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
128 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
129 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
130 |
size_t G1FullGCPrepareTask::G1RePrepareClosure::apply(oop obj) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
131 |
// We only re-prepare objects forwarded within the current region, so |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
132 |
// skip objects that are already forwarded to another region. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
133 |
oop forwarded_to = obj->forwardee(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
134 |
if (forwarded_to != NULL && !_current->is_in(forwarded_to)) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
135 |
return obj->size(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
136 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
137 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
138 |
// Get size and forward. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
139 |
size_t size = obj->size(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
140 |
_cp->forward(obj, size); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
141 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
142 |
return size; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
143 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
144 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
145 |
void G1FullGCPrepareTask::G1CalculatePointersClosure::prepare_for_compaction_work(G1FullGCCompactionPoint* cp, |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
146 |
HeapRegion* hr) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
147 |
G1PrepareCompactLiveClosure prepare_compact(cp); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
148 |
hr->set_compaction_top(hr->bottom()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
149 |
hr->apply_to_marked_objects(_bitmap, &prepare_compact); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
150 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
151 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
152 |
void G1FullGCPrepareTask::G1CalculatePointersClosure::prepare_for_compaction(HeapRegion* hr) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
153 |
if (!_cp->is_initialized()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
154 |
hr->set_compaction_top(hr->bottom()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
155 |
_cp->initialize(hr, true); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
156 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
157 |
// Add region to the compaction queue and prepare it. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
158 |
_cp->add(hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
159 |
prepare_for_compaction_work(_cp, hr); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
160 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
161 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
162 |
void G1FullGCPrepareTask::prepare_serial_compaction() { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
163 |
GCTraceTime(Debug, gc, phases) debug("Phase 2: Prepare Serial Compaction", collector()->scope()->timer()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
164 |
// At this point we know that no regions were completely freed by |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
165 |
// the parallel compaction. That means that the last region of |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
166 |
// all compaction queues still have data in them. We try to compact |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
167 |
// these regions in serial to avoid a premature OOM. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
168 |
for (uint i = 0; i < collector()->workers(); i++) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
169 |
G1FullGCCompactionPoint* cp = collector()->compaction_point(i); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
170 |
if (cp->has_regions()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
171 |
collector()->serial_compaction_point()->add(cp->remove_last()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
172 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
173 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
174 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
175 |
// Update the forwarding information for the regions in the serial |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
176 |
// compaction point. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
177 |
G1FullGCCompactionPoint* cp = collector()->serial_compaction_point(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
178 |
for (GrowableArrayIterator<HeapRegion*> it = cp->regions()->begin(); it != cp->regions()->end(); ++it) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
179 |
HeapRegion* current = *it; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
180 |
if (!cp->is_initialized()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
181 |
// Initialize the compaction point. Nothing more is needed for the first heap region |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
182 |
// since it is already prepared for compaction. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
183 |
cp->initialize(current, false); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
184 |
} else { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
185 |
assert(!current->is_humongous(), "Should be no humongous regions in compaction queue"); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
186 |
G1RePrepareClosure re_prepare(cp, current); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
187 |
current->set_compaction_top(current->bottom()); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
188 |
current->apply_to_marked_objects(collector()->mark_bitmap(), &re_prepare); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
189 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
190 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
191 |
cp->update(); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
192 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
193 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
194 |
void G1FullGCPrepareTask::G1CalculatePointersClosure::update_sets() { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
195 |
// We'll recalculate total used bytes and recreate the free list |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
196 |
// at the end of the GC, so no point in updating those values here. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
197 |
_g1h->remove_from_old_sets(0, _humongous_regions_removed); |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
198 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
199 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
200 |
bool G1FullGCPrepareTask::G1CalculatePointersClosure::freed_regions() { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
201 |
if (_humongous_regions_removed > 0) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
202 |
// Free regions from dead humongous regions. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
203 |
return true; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
204 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
205 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
206 |
if (!_cp->has_regions()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
207 |
// No regions in queue, so no free ones either. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
208 |
return false; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
209 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
210 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
211 |
if (_cp->current_region() != _cp->regions()->last()) { |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
212 |
// The current region used for compaction is not the last in the |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
213 |
// queue. That means there is at least one free region in the queue. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
214 |
return true; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
215 |
} |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
216 |
|
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
217 |
// No free regions in the queue. |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
218 |
return false; |
5caa1d5f74c1
8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents:
diff
changeset
|
219 |
} |