Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/collectionSetChooser.hpp @ 3927:f1b4e0e0bdad
7089625: G1: policy for how many old regions to add to the CSet (when young gen is fixed) is broken
Summary: When refactoring the code for a previous fix, a condition was not correctly negated which prevents the G1 policy from adding the correct number of old regions to the CSet when the young gen size is fixed. The changeset also fixes a small syntactical issue in g1ErgoVerbose.hpp which is causing compiler warnings.
Reviewed-by: brutisso, ysr
author | tonyp |
---|---|
date | Tue, 13 Sep 2011 12:40:14 -0400 |
parents | 371bbc844bf1 |
children | b9390528617c |
rev | line source |
---|---|
342 | 1 /* |
1972 | 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
342 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 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 | |
342 | 31 // We need to sort heap regions by collection desirability. |
32 | |
549
fe3d7c11b4b7
6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents:
342
diff
changeset
|
33 class CSetChooserCache VALUE_OBJ_CLASS_SPEC { |
342 | 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 } | |
51 inline int get_index(int sort_index) { | |
52 return -sort_index-2; | |
53 } | |
54 | |
55 public: | |
56 CSetChooserCache(void); | |
57 | |
58 inline int occupancy(void) { return _occupancy; } | |
59 inline bool is_full() { return _occupancy == CacheLength; } | |
60 inline bool is_empty() { return _occupancy == 0; } | |
61 | |
62 void clear(void); | |
63 void insert(HeapRegion *hr); | |
64 HeapRegion *remove_first(void); | |
65 void remove (HeapRegion *hr); | |
66 inline HeapRegion *get_first(void) { | |
67 return _cache[_first]; | |
68 } | |
69 | |
70 #ifndef PRODUCT | |
71 bool verify (void); | |
72 bool region_in_cache(HeapRegion *hr) { | |
73 int sort_index = hr->sort_index(); | |
74 if (sort_index < -1) { | |
75 int index = get_index(sort_index); | |
76 guarantee(index < CacheLength, "should be within bounds"); | |
77 return _cache[index] == hr; | |
78 } else | |
79 return 0; | |
80 } | |
81 #endif // PRODUCT | |
82 }; | |
83 | |
84 class CollectionSetChooser: public CHeapObj { | |
85 | |
86 GrowableArray<HeapRegion*> _markedRegions; | |
87 int _curMarkedIndex; | |
88 int _numMarkedRegions; | |
89 CSetChooserCache _cache; | |
90 | |
91 // True iff last collection pause ran of out new "age 0" regions, and | |
92 // returned an "age 1" region. | |
93 bool _unmarked_age_1_returned_as_new; | |
94 | |
95 jint _first_par_unreserved_idx; | |
96 | |
97 public: | |
98 | |
99 HeapRegion* getNextMarkedRegion(double time_so_far, double avg_prediction); | |
100 | |
101 CollectionSetChooser(); | |
102 | |
103 void sortMarkedHeapRegions(); | |
104 void fillCache(); | |
105 bool addRegionToCache(void); | |
106 void addMarkedHeapRegion(HeapRegion *hr); | |
107 | |
108 // Must be called before calls to getParMarkedHeapRegionChunk. | |
109 // "n_regions" is the number of regions, "chunkSize" the chunk size. | |
110 void prepareForAddMarkedHeapRegionsPar(size_t n_regions, size_t chunkSize); | |
111 // Returns the first index in a contiguous chunk of "n_regions" indexes | |
112 // that the calling thread has reserved. These must be set by the | |
113 // calling thread using "setMarkedHeapRegion" (to NULL if necessary). | |
114 jint getParMarkedHeapRegionChunk(jint n_regions); | |
115 // Set the marked array entry at index to hr. Careful to claim the index | |
116 // first if in parallel. | |
117 void setMarkedHeapRegion(jint index, HeapRegion* hr); | |
118 // Atomically increment the number of claimed regions by "inc_by". | |
119 void incNumMarkedHeapRegions(jint inc_by); | |
120 | |
121 void clearMarkedHeapRegions(); | |
122 | |
123 void updateAfterFullCollection(); | |
124 | |
125 // Ensure that "hr" is not a member of the marked region array or the cache | |
126 void removeRegion(HeapRegion* hr); | |
127 | |
128 bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; } | |
129 | |
130 // Returns true if the used portion of "_markedRegions" is properly | |
131 // sorted, otherwise asserts false. | |
132 #ifndef PRODUCT | |
133 bool verify(void); | |
134 bool regionProperlyOrdered(HeapRegion* r) { | |
135 int si = r->sort_index(); | |
136 return (si == -1) || | |
137 (si > -1 && _markedRegions.at(si) == r) || | |
138 (si < -1 && _cache.region_in_cache(r)); | |
139 } | |
140 #endif | |
141 | |
142 }; | |
1972 | 143 |
144 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP |