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. |
92 typedef struct { |
92 typedef struct { |
93 julong _value; // | card_num | epoch | |
93 julong _value; // | card_num | epoch | |
94 } CardEpochCacheEntry; |
94 } CardEpochCacheEntry; |
95 |
95 |
96 julong make_epoch_entry(unsigned int card_num, unsigned int epoch) { |
96 julong make_epoch_entry(unsigned int card_num, unsigned int epoch) { |
97 assert(0 <= card_num && card_num < _max_n_card_counts, "Bounds"); |
97 assert(0 <= card_num && card_num < _max_cards, "Bounds"); |
98 assert(0 <= epoch && epoch <= _n_periods, "must be"); |
98 assert(0 <= epoch && epoch <= _n_periods, "must be"); |
99 |
99 |
100 return ((julong) card_num << card_num_shift) | epoch; |
100 return ((julong) card_num << card_num_shift) | epoch; |
101 } |
101 } |
102 |
102 |
115 |
115 |
116 CardCountCacheEntry* _card_counts; |
116 CardCountCacheEntry* _card_counts; |
117 CardEpochCacheEntry* _card_epochs; |
117 CardEpochCacheEntry* _card_epochs; |
118 |
118 |
119 // The current number of buckets in the card count cache |
119 // The current number of buckets in the card count cache |
120 unsigned _n_card_counts; |
120 size_t _n_card_counts; |
121 |
121 |
122 // The max number of buckets required for the number of |
122 // The number of cards for the entire reserved heap |
123 // cards for the entire reserved heap |
123 size_t _max_cards; |
124 unsigned _max_n_card_counts; |
124 |
|
125 // The max number of buckets for the card counts and epochs caches. |
|
126 // This is the maximum that the counts and epochs will grow to. |
|
127 // It is specified as a fraction or percentage of _max_cards using |
|
128 // G1MaxHotCardCountSizePercent. |
|
129 size_t _max_n_card_counts; |
125 |
130 |
126 // Possible sizes of the cache: odd primes that roughly double in size. |
131 // Possible sizes of the cache: odd primes that roughly double in size. |
127 // (See jvmtiTagMap.cpp). |
132 // (See jvmtiTagMap.cpp). |
128 static int _cc_cache_sizes[]; |
133 enum { |
|
134 MAX_CC_CACHE_INDEX = 15 // maximum index into the cache size array. |
|
135 }; |
|
136 |
|
137 static size_t _cc_cache_sizes[MAX_CC_CACHE_INDEX]; |
129 |
138 |
130 // The index in _cc_cache_sizes corresponding to the size of |
139 // The index in _cc_cache_sizes corresponding to the size of |
131 // _card_counts. |
140 // _card_counts. |
132 int _cache_size_index; |
141 int _cache_size_index; |
133 |
142 |
145 |
154 |
146 // Needed to workaround 6817995 |
155 // Needed to workaround 6817995 |
147 CardTableModRefBS* _ct_bs; |
156 CardTableModRefBS* _ct_bs; |
148 G1CollectedHeap* _g1h; |
157 G1CollectedHeap* _g1h; |
149 |
158 |
150 // Expands the array that holds the card counts to the next size up |
159 // Helper routine for expand_card_count_cache(). |
151 void expand_card_count_cache(); |
160 // The arrays used to hold the card counts and the epochs must have |
|
161 // a 1:1 correspondence. Hence they are allocated and freed together. |
|
162 // Returns true if the allocations of both the counts and epochs |
|
163 // were successful; false otherwise. |
|
164 bool allocate_card_count_cache(size_t n, |
|
165 CardCountCacheEntry** counts, |
|
166 CardEpochCacheEntry** epochs); |
|
167 |
|
168 // Expands the arrays that hold the card counts and epochs |
|
169 // to the cache size at index. Returns true if the expansion/ |
|
170 // allocation was successful; false otherwise. |
|
171 bool expand_card_count_cache(int index); |
152 |
172 |
153 // hash a given key (index of card_ptr) with the specified size |
173 // hash a given key (index of card_ptr) with the specified size |
154 static unsigned int hash(size_t key, int size) { |
174 static unsigned int hash(size_t key, size_t size) { |
155 return (unsigned int) key % size; |
175 return (unsigned int) key % size; |
156 } |
176 } |
157 |
177 |
158 // hash a given key (index of card_ptr) |
178 // hash a given key (index of card_ptr) |
159 unsigned int hash(size_t key) { |
179 unsigned int hash(size_t key) { |