annotate src/share/vm/gc_implementation/g1/collectionSetChooser.hpp @ 6010:720b6a76dd9d

7157073: G1: type change size_t -> uint for region counts / indexes Summary: Change the type of fields / variables / etc. that represent region counts and indeces from size_t to uint. Reviewed-by: iveresov, brutisso, jmasa, jwilhelm
author tonyp
date Wed, 18 Apr 2012 07:21:15 -0400
parents a9647476d1a4
children f7a8920427a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
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: 579
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/g1/heapRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "utilities/growableArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
31 class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32 private:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 enum {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 CacheLength = 16
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 } PrivateConstants;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 HeapRegion* _cache[CacheLength];
3989
b9390528617c 7095236: G1: _markedRegions never contains NULL regions
ysr
parents: 2435
diff changeset
38 int _occupancy; // number of regions in cache
b9390528617c 7095236: G1: _markedRegions never contains NULL regions
ysr
parents: 2435
diff changeset
39 int _first; // (index of) "first" region in the cache
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 // adding CacheLength to deal with negative values
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 inline int trim_index(int index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 return (index + CacheLength) % CacheLength;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 inline int get_sort_index(int index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 return -index-2;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
48 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
49 inline int get_index(int sort_index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 return -sort_index-2;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54 CSetChooserCache(void);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
55
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
56 inline int occupancy(void) { return _occupancy; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
57 inline bool is_full() { return _occupancy == CacheLength; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58 inline bool is_empty() { return _occupancy == 0; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
59
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
60 void clear(void);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
61 void insert(HeapRegion *hr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
62 HeapRegion *remove_first(void);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
63 inline HeapRegion *get_first(void) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
64 return _cache[_first];
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
65 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
66
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67 #ifndef PRODUCT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
68 bool verify (void);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 bool region_in_cache(HeapRegion *hr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
70 int sort_index = hr->sort_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71 if (sort_index < -1) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 int index = get_index(sort_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73 guarantee(index < CacheLength, "should be within bounds");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 return _cache[index] == hr;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 } else
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76 return 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
77 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78 #endif // PRODUCT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
81 class CollectionSetChooser: public CHeapObj {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
82
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 GrowableArray<HeapRegion*> _markedRegions;
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
84
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
85 // The index of the next candidate old region to be considered for
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
86 // addition to the CSet.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
87 int _curr_index;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
88
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
89 // The number of candidate old regions added to the CSet chooser.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
90 int _length;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
92 CSetChooserCache _cache;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
93 jint _first_par_unreserved_idx;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
95 // If a region has more live bytes than this threshold, it will not
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
96 // be added to the CSet chooser and will not be a candidate for
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
97 // collection.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
98 size_t _regionLiveThresholdBytes;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
99
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
100 // The sum of reclaimable bytes over all the regions in the CSet chooser.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
101 size_t _remainingReclaimableBytes;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
105 // Return the current candidate region to be considered for
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
106 // collection without removing it from the CSet chooser.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
107 HeapRegion* peek() {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
108 HeapRegion* res = NULL;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
109 if (_curr_index < _length) {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
110 res = _markedRegions.at(_curr_index);
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
111 assert(res != NULL,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
112 err_msg("Unexpected NULL hr in _markedRegions at index %d",
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
113 _curr_index));
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
114 }
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
115 return res;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
116 }
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
117
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
118 // Remove the given region from the CSet chooser and move to the
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
119 // next one. The given region should be the current candidate region
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
120 // in the CSet chooser.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
121 void remove_and_move_to_next(HeapRegion* hr) {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
122 assert(hr != NULL, "pre-condition");
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
123 assert(_curr_index < _length, "pre-condition");
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
124 assert(_markedRegions.at(_curr_index) == hr, "pre-condition");
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
125 hr->set_sort_index(-1);
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
126 _markedRegions.at_put(_curr_index, NULL);
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
127 assert(hr->reclaimable_bytes() <= _remainingReclaimableBytes,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
128 err_msg("remaining reclaimable bytes inconsistent "
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
129 "from region: "SIZE_FORMAT" remaining: "SIZE_FORMAT,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
130 hr->reclaimable_bytes(), _remainingReclaimableBytes));
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
131 _remainingReclaimableBytes -= hr->reclaimable_bytes();
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
132 _curr_index += 1;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
133 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 CollectionSetChooser();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137 void sortMarkedHeapRegions();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 void fillCache();
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
139
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
140 // Determine whether to add the given region to the CSet chooser or
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
141 // not. Currently, we skip humongous regions (we never add them to
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
142 // the CSet, we only reclaim them during cleanup) and regions whose
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
143 // live bytes are over the threshold.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
144 bool shouldAdd(HeapRegion* hr) {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
145 assert(hr->is_marked(), "pre-condition");
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
146 assert(!hr->is_young(), "should never consider young regions");
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
147 return !hr->isHumongous() &&
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
148 hr->live_bytes() < _regionLiveThresholdBytes;
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
149 }
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
150
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
151 // Calculate the minimum number of old regions we'll add to the CSet
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
152 // during a mixed GC.
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 4912
diff changeset
153 uint calcMinOldCSetLength();
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
154
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
155 // Calculate the maximum number of old regions we'll add to the CSet
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
156 // during a mixed GC.
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 4912
diff changeset
157 uint calcMaxOldCSetLength();
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
158
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
159 // Serial version.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 void addMarkedHeapRegion(HeapRegion *hr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
162 // Must be called before calls to getParMarkedHeapRegionChunk.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 // "n_regions" is the number of regions, "chunkSize" the chunk size.
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 4912
diff changeset
164 void prepareForAddMarkedHeapRegionsPar(uint n_regions, uint chunkSize);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165 // Returns the first index in a contiguous chunk of "n_regions" indexes
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 // that the calling thread has reserved. These must be set by the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 // calling thread using "setMarkedHeapRegion" (to NULL if necessary).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 jint getParMarkedHeapRegionChunk(jint n_regions);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 // Set the marked array entry at index to hr. Careful to claim the index
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 // first if in parallel.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171 void setMarkedHeapRegion(jint index, HeapRegion* hr);
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
172 // Atomically increment the number of added regions by region_num
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
173 // and the amount of reclaimable bytes by reclaimable_bytes.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
174 void updateTotals(jint region_num, size_t reclaimable_bytes);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 void clearMarkedHeapRegions();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
178 // Return the number of candidate regions that remain to be collected.
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 4912
diff changeset
179 uint remainingRegions() { return (uint) (_length - _curr_index); }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
181 // Determine whether the CSet chooser has more candidate regions or not.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
182 bool isEmpty() { return remainingRegions() == 0; }
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
183
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
184 // Return the reclaimable bytes that remain to be collected on
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
185 // all the candidate regions in the CSet chooser.
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
186 size_t remainingReclaimableBytes () { return _remainingReclaimableBytes; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188 // Returns true if the used portion of "_markedRegions" is properly
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 // sorted, otherwise asserts false.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
190 #ifndef PRODUCT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
191 bool verify(void);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
192 bool regionProperlyOrdered(HeapRegion* r) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 int si = r->sort_index();
4912
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
194 if (si > -1) {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
195 guarantee(_curr_index <= si && si < _length,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
196 err_msg("curr: %d sort index: %d: length: %d",
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
197 _curr_index, si, _length));
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
198 guarantee(_markedRegions.at(si) == r,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
199 err_msg("sort index: %d at: "PTR_FORMAT" r: "PTR_FORMAT,
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
200 si, _markedRegions.at(si), r));
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
201 } else {
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
202 guarantee(si == -1, err_msg("sort index: %d", si));
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
203 }
a9647476d1a4 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 3989
diff changeset
204 return true;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
208 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
209
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
210 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP