author | tschatzl |
Fri, 08 Feb 2019 12:55:20 +0100 | |
changeset 53704 | ef72c85a0534 |
parent 53703 | 24341625d8f2 |
child 54465 | c4f16445675a |
permissions | -rw-r--r-- |
53703
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
1 |
/* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
4 |
* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
8 |
* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
14 |
* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
18 |
* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
22 |
* |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
23 |
*/ |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
24 |
|
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
26 |
#include "gc/g1/g1CollectionSetCandidates.hpp" |
53704
ef72c85a0534
8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
53703
diff
changeset
|
27 |
#include "gc/g1/g1CollectionSetChooser.hpp" |
53703
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
28 |
#include "gc/g1/heapRegion.inline.hpp" |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
29 |
|
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
30 |
HeapRegion* G1CollectionSetCandidates::pop_front() { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
31 |
assert(_front_idx < _num_regions, "pre-condition"); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
32 |
HeapRegion* hr = _regions[_front_idx]; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
33 |
assert(hr != NULL, "pre-condition"); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
34 |
_regions[_front_idx] = NULL; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
35 |
assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes, |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
36 |
"Remaining reclaimable bytes inconsistent " |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
37 |
"from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT, |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
38 |
hr->reclaimable_bytes(), _remaining_reclaimable_bytes); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
39 |
_remaining_reclaimable_bytes -= hr->reclaimable_bytes(); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
40 |
_front_idx++; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
41 |
return hr; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
42 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
43 |
|
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
44 |
void G1CollectionSetCandidates::push_front(HeapRegion* hr) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
45 |
assert(hr != NULL, "Can't put back a NULL region"); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
46 |
assert(_front_idx >= 1, "Too many regions have been put back."); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
47 |
_front_idx--; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
48 |
_regions[_front_idx] = hr; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
49 |
_remaining_reclaimable_bytes += hr->reclaimable_bytes(); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
50 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
51 |
|
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
52 |
void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
53 |
for (uint i = _front_idx; i < _num_regions; i++) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
54 |
HeapRegion* r = _regions[i]; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
55 |
if (cl->do_heap_region(r)) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
56 |
cl->set_incomplete(); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
57 |
break; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
58 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
59 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
60 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
61 |
|
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
62 |
#ifndef PRODUCT |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
63 |
void G1CollectionSetCandidates::verify() const { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
64 |
guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
65 |
uint idx = 0; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
66 |
size_t sum_of_reclaimable_bytes = 0; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
67 |
while (idx < _front_idx) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
68 |
guarantee(_regions[idx] == NULL, "All entries before _front_idx %u should be NULL, but %u is not", |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
69 |
_front_idx, idx); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
70 |
idx++; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
71 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
72 |
HeapRegion *prev = NULL; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
73 |
for (; idx < _num_regions; idx++) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
74 |
HeapRegion *cur = _regions[idx]; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
75 |
guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx); |
53704
ef72c85a0534
8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
53703
diff
changeset
|
76 |
guarantee(G1CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index()); |
53703
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
77 |
if (prev != NULL) { |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
78 |
guarantee(prev->gc_efficiency() >= cur->gc_efficiency(), |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
79 |
"GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f", |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
80 |
prev->hrm_index(), prev->gc_efficiency(), cur->hrm_index(), cur->gc_efficiency()); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
81 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
82 |
sum_of_reclaimable_bytes += cur->reclaimable_bytes(); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
83 |
prev = cur; |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
84 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
85 |
guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes, |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
86 |
"Inconsistent remaining_reclaimable bytes, remaining " SIZE_FORMAT " calculated " SIZE_FORMAT, |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
87 |
_remaining_reclaimable_bytes, sum_of_reclaimable_bytes); |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
88 |
} |
24341625d8f2
8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents:
diff
changeset
|
89 |
#endif // !PRODUCT |