196 } |
196 } |
197 current = old; |
197 current = old; |
198 } |
198 } |
199 Atomic::add(-context->_num_removed, &_number_of_entries); |
199 Atomic::add(-context->_num_removed, &_number_of_entries); |
200 } |
200 } |
201 |
|
202 // Copy the table to the shared space. |
201 // Copy the table to the shared space. |
203 |
202 template <MEMFLAGS F> size_t BasicHashtable<F>::count_bytes_for_table() { |
204 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char** top, char* end) { |
203 size_t bytes = 0; |
205 |
204 bytes += sizeof(intptr_t); // len |
206 // Dump the hash table entries. |
205 |
207 |
206 for (int i = 0; i < _table_size; ++i) { |
208 intptr_t *plen = (intptr_t*)(*top); |
207 for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr(); |
209 *top += sizeof(*plen); |
208 *p != NULL; |
|
209 p = (*p)->next_addr()) { |
|
210 bytes += entry_size(); |
|
211 } |
|
212 } |
|
213 |
|
214 return bytes; |
|
215 } |
|
216 |
|
217 // Dump the hash table entries (into CDS archive) |
|
218 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char* top, char* end) { |
|
219 assert(is_aligned(top, sizeof(intptr_t)), "bad alignment"); |
|
220 intptr_t *plen = (intptr_t*)(top); |
|
221 top += sizeof(*plen); |
210 |
222 |
211 int i; |
223 int i; |
212 for (i = 0; i < _table_size; ++i) { |
224 for (i = 0; i < _table_size; ++i) { |
213 for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr(); |
225 for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr(); |
214 *p != NULL; |
226 *p != NULL; |
215 p = (*p)->next_addr()) { |
227 p = (*p)->next_addr()) { |
216 if (*top + entry_size() > end) { |
228 *p = (BasicHashtableEntry<F>*)memcpy(top, (void*)*p, entry_size()); |
217 report_out_of_shared_space(SharedMiscData); |
229 top += entry_size(); |
218 } |
230 } |
219 *p = (BasicHashtableEntry<F>*)memcpy(*top, (void*)*p, entry_size()); |
231 } |
220 *top += entry_size(); |
232 *plen = (char*)(top) - (char*)plen - sizeof(*plen); |
221 } |
233 assert(top == end, "count_bytes_for_table is wrong"); |
222 } |
|
223 *plen = (char*)(*top) - (char*)plen - sizeof(*plen); |
|
224 |
|
225 // Set the shared bit. |
234 // Set the shared bit. |
226 |
235 |
227 for (i = 0; i < _table_size; ++i) { |
236 for (i = 0; i < _table_size; ++i) { |
228 for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) { |
237 for (BasicHashtableEntry<F>* p = bucket(i); p != NULL; p = p->next()) { |
229 p->set_shared(); |
238 p->set_shared(); |
270 NumberSeq summary; |
279 NumberSeq summary; |
271 int literal_bytes = 0; |
280 int literal_bytes = 0; |
272 for (int i = 0; i < this->table_size(); ++i) { |
281 for (int i = 0; i < this->table_size(); ++i) { |
273 int count = 0; |
282 int count = 0; |
274 for (HashtableEntry<T, F>* e = this->bucket(i); |
283 for (HashtableEntry<T, F>* e = this->bucket(i); |
275 e != NULL; e = e->next()) { |
284 e != NULL; e = e->next()) { |
276 count++; |
285 count++; |
277 literal_bytes += literal_size(e->literal()); |
286 literal_bytes += literal_size(e->literal()); |
278 } |
287 } |
279 summary.add((double)count); |
288 summary.add((double)count); |
280 } |
289 } |
303 } |
312 } |
304 |
313 |
305 |
314 |
306 // Dump the hash table buckets. |
315 // Dump the hash table buckets. |
307 |
316 |
308 template <MEMFLAGS F> void BasicHashtable<F>::copy_buckets(char** top, char* end) { |
317 template <MEMFLAGS F> size_t BasicHashtable<F>::count_bytes_for_buckets() { |
|
318 size_t bytes = 0; |
|
319 bytes += sizeof(intptr_t); // len |
|
320 bytes += sizeof(intptr_t); // _number_of_entries |
|
321 bytes += _table_size * sizeof(HashtableBucket<F>); // the buckets |
|
322 |
|
323 return bytes; |
|
324 } |
|
325 |
|
326 // Dump the buckets (into CDS archive) |
|
327 template <MEMFLAGS F> void BasicHashtable<F>::copy_buckets(char* top, char* end) { |
|
328 assert(is_aligned(top, sizeof(intptr_t)), "bad alignment"); |
309 intptr_t len = _table_size * sizeof(HashtableBucket<F>); |
329 intptr_t len = _table_size * sizeof(HashtableBucket<F>); |
310 *(intptr_t*)(*top) = len; |
330 *(intptr_t*)(top) = len; |
311 *top += sizeof(intptr_t); |
331 top += sizeof(intptr_t); |
312 |
332 |
313 *(intptr_t*)(*top) = _number_of_entries; |
333 *(intptr_t*)(top) = _number_of_entries; |
314 *top += sizeof(intptr_t); |
334 top += sizeof(intptr_t); |
315 |
335 |
316 if (*top + len > end) { |
336 _buckets = (HashtableBucket<F>*)memcpy(top, (void*)_buckets, len); |
317 report_out_of_shared_space(SharedMiscData); |
337 top += len; |
318 } |
338 |
319 _buckets = (HashtableBucket<F>*)memcpy(*top, (void*)_buckets, len); |
339 assert(top == end, "count_bytes_for_buckets is wrong"); |
320 *top += len; |
|
321 } |
340 } |
322 |
341 |
323 #ifndef PRODUCT |
342 #ifndef PRODUCT |
324 |
343 |
325 template <class T, MEMFLAGS F> void Hashtable<T, F>::print() { |
344 template <class T, MEMFLAGS F> void Hashtable<T, F>::print() { |
395 template class Hashtable<oopDesc*, mtSymbol>; |
414 template class Hashtable<oopDesc*, mtSymbol>; |
396 template class Hashtable<Symbol*, mtClass>; |
415 template class Hashtable<Symbol*, mtClass>; |
397 template class HashtableEntry<Symbol*, mtSymbol>; |
416 template class HashtableEntry<Symbol*, mtSymbol>; |
398 template class HashtableEntry<Symbol*, mtClass>; |
417 template class HashtableEntry<Symbol*, mtClass>; |
399 template class HashtableEntry<oop, mtSymbol>; |
418 template class HashtableEntry<oop, mtSymbol>; |
|
419 template class HashtableBucket<mtClass>; |
400 template class BasicHashtableEntry<mtSymbol>; |
420 template class BasicHashtableEntry<mtSymbol>; |
401 template class BasicHashtableEntry<mtCode>; |
421 template class BasicHashtableEntry<mtCode>; |
402 template class BasicHashtable<mtClass>; |
422 template class BasicHashtable<mtClass>; |
403 template class BasicHashtable<mtClassShared>; |
423 template class BasicHashtable<mtClassShared>; |
404 template class BasicHashtable<mtSymbol>; |
424 template class BasicHashtable<mtSymbol>; |