comparison src/share/vm/gc_implementation/g1/collectionSetChooser.hpp @ 3989:b9390528617c

7095236: G1: _markedRegions never contains NULL regions Summary: Removed the code for skipping over NULL regions in _markedRegions, replacing it with an assertion that a NULL region is never encountered; removed dead methods, remove() and remove_region(), and inlined a simplified addRegion() directly into fillCache(). Reviewed-by: brutisso, tonyp
author ysr
date Thu, 06 Oct 2011 18:56:47 -0700
parents 371bbc844bf1
children a9647476d1a4
comparison
equal deleted inserted replaced
3987:fd65bc7c09b6 3989:b9390528617c
1 /* 1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
27 27
28 #include "gc_implementation/g1/heapRegion.hpp" 28 #include "gc_implementation/g1/heapRegion.hpp"
29 #include "utilities/growableArray.hpp" 29 #include "utilities/growableArray.hpp"
30 30
31 // We need to sort heap regions by collection desirability. 31 // We need to sort heap regions by collection desirability.
32 // This sorting is currently done in two "stages". An initial sort is
33 // done following a cleanup pause as soon as all of the marked but
34 // non-empty regions have been identified and the completely empty
35 // ones reclaimed.
36 // This gives us a global sort on a GC efficiency metric
37 // based on predictive data available at that time. However,
38 // any of these regions that are collected will only be collected
39 // during a future GC pause, by which time it is possible that newer
40 // data might allow us to revise and/or refine the earlier
41 // pause predictions, leading to changes in expected gc efficiency
42 // order. To somewhat mitigate this obsolescence, more so in the
43 // case of regions towards the end of the list, which will be
44 // picked later, these pre-sorted regions from the _markedRegions
45 // array are not used as is, but a small prefix thereof is
46 // insertion-sorted again into a small cache, based on more
47 // recent remembered set information. Regions are then drawn
48 // from this cache to construct the collection set at each
49 // incremental GC.
50 // This scheme and/or its implementation may be subject to
51 // revision in the future.
32 52
33 class CSetChooserCache VALUE_OBJ_CLASS_SPEC { 53 class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
34 private: 54 private:
35 enum { 55 enum {
36 CacheLength = 16 56 CacheLength = 16
37 } PrivateConstants; 57 } PrivateConstants;
38 58
39 HeapRegion* _cache[CacheLength]; 59 HeapRegion* _cache[CacheLength];
40 int _occupancy; // number of region in cache 60 int _occupancy; // number of regions in cache
41 int _first; // "first" region in the cache 61 int _first; // (index of) "first" region in the cache
42 62
43 // adding CacheLength to deal with negative values 63 // adding CacheLength to deal with negative values
44 inline int trim_index(int index) { 64 inline int trim_index(int index) {
45 return (index + CacheLength) % CacheLength; 65 return (index + CacheLength) % CacheLength;
46 } 66 }
60 inline bool is_empty() { return _occupancy == 0; } 80 inline bool is_empty() { return _occupancy == 0; }
61 81
62 void clear(void); 82 void clear(void);
63 void insert(HeapRegion *hr); 83 void insert(HeapRegion *hr);
64 HeapRegion *remove_first(void); 84 HeapRegion *remove_first(void);
65 void remove (HeapRegion *hr);
66 inline HeapRegion *get_first(void) { 85 inline HeapRegion *get_first(void) {
67 return _cache[_first]; 86 return _cache[_first];
68 } 87 }
69 88
70 #ifndef PRODUCT 89 #ifndef PRODUCT
100 119
101 CollectionSetChooser(); 120 CollectionSetChooser();
102 121
103 void sortMarkedHeapRegions(); 122 void sortMarkedHeapRegions();
104 void fillCache(); 123 void fillCache();
105 bool addRegionToCache(void);
106 void addMarkedHeapRegion(HeapRegion *hr); 124 void addMarkedHeapRegion(HeapRegion *hr);
107 125
108 // Must be called before calls to getParMarkedHeapRegionChunk. 126 // Must be called before calls to getParMarkedHeapRegionChunk.
109 // "n_regions" is the number of regions, "chunkSize" the chunk size. 127 // "n_regions" is the number of regions, "chunkSize" the chunk size.
110 void prepareForAddMarkedHeapRegionsPar(size_t n_regions, size_t chunkSize); 128 void prepareForAddMarkedHeapRegionsPar(size_t n_regions, size_t chunkSize);
120 138
121 void clearMarkedHeapRegions(); 139 void clearMarkedHeapRegions();
122 140
123 void updateAfterFullCollection(); 141 void updateAfterFullCollection();
124 142
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; } 143 bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; }
129 144
130 // Returns true if the used portion of "_markedRegions" is properly 145 // Returns true if the used portion of "_markedRegions" is properly
131 // sorted, otherwise asserts false. 146 // sorted, otherwise asserts false.
132 #ifndef PRODUCT 147 #ifndef PRODUCT