1 /*
2 * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 // We need to sort heap regions by collection desirability.
26
27 class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
28 private:
29 enum {
30 CacheLength = 16
31 } PrivateConstants;
32
33 HeapRegion* _cache[CacheLength];
34 int _occupancy; // number of region in cache
35 int _first; // "first" region in the cache
36
37 // adding CacheLength to deal with negative values
38 inline int trim_index(int index) {
39 return (index + CacheLength) % CacheLength;
40 }
41
42 inline int get_sort_index(int index) {
43 return -index-2;
44 }
119 void updateAfterFullCollection();
120
121 // Ensure that "hr" is not a member of the marked region array or the cache
122 void removeRegion(HeapRegion* hr);
123
124 bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; }
125
126 // Returns true if the used portion of "_markedRegions" is properly
127 // sorted, otherwise asserts false.
128 #ifndef PRODUCT
129 bool verify(void);
130 bool regionProperlyOrdered(HeapRegion* r) {
131 int si = r->sort_index();
132 return (si == -1) ||
133 (si > -1 && _markedRegions.at(si) == r) ||
134 (si < -1 && _cache.region_in_cache(r));
135 }
136 #endif
137
138 };
|
1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
27
28 #include "gc_implementation/g1/heapRegion.hpp"
29 #include "utilities/growableArray.hpp"
30
31 // We need to sort heap regions by collection desirability.
32
33 class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
34 private:
35 enum {
36 CacheLength = 16
37 } PrivateConstants;
38
39 HeapRegion* _cache[CacheLength];
40 int _occupancy; // number of region in cache
41 int _first; // "first" region in the cache
42
43 // adding CacheLength to deal with negative values
44 inline int trim_index(int index) {
45 return (index + CacheLength) % CacheLength;
46 }
47
48 inline int get_sort_index(int index) {
49 return -index-2;
50 }
125 void updateAfterFullCollection();
126
127 // Ensure that "hr" is not a member of the marked region array or the cache
128 void removeRegion(HeapRegion* hr);
129
130 bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; }
131
132 // Returns true if the used portion of "_markedRegions" is properly
133 // sorted, otherwise asserts false.
134 #ifndef PRODUCT
135 bool verify(void);
136 bool regionProperlyOrdered(HeapRegion* r) {
137 int si = r->sort_index();
138 return (si == -1) ||
139 (si > -1 && _markedRegions.at(si) == r) ||
140 (si < -1 && _cache.region_in_cache(r));
141 }
142 #endif
143
144 };
145
146 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
|