8180048: Interned string and symbol table leak memory during parallel unlinking

Make appending found dead BasicHashtableEntrys to the free list atomic.

Reviewed-by: ehelin, shade, coleenp
This commit is contained in:
Thomas Schatzl 2017-05-15 12:20:15 +02:00
parent 8e28d5772d
commit c775f6f58b
7 changed files with 97 additions and 29 deletions

View file

@ -314,7 +314,11 @@ oop StringTable::intern(const char* utf8_string, TRAPS) {
}
void StringTable::unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int* processed, int* removed) {
buckets_unlink_or_oops_do(is_alive, f, 0, the_table()->table_size(), processed, removed);
BucketUnlinkContext context;
buckets_unlink_or_oops_do(is_alive, f, 0, the_table()->table_size(), &context);
_the_table->bulk_free_entries(&context);
*processed = context._num_processed;
*removed = context._num_removed;
}
void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int* processed, int* removed) {
@ -323,6 +327,7 @@ void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_aliv
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
const int limit = the_table()->table_size();
BucketUnlinkContext context;
for (;;) {
// Grab next set of buckets to scan
int start_idx = Atomic::add(ClaimChunkSize, &_parallel_claimed_idx) - ClaimChunkSize;
@ -332,8 +337,11 @@ void StringTable::possibly_parallel_unlink_or_oops_do(BoolObjectClosure* is_aliv
}
int end_idx = MIN2(limit, start_idx + ClaimChunkSize);
buckets_unlink_or_oops_do(is_alive, f, start_idx, end_idx, processed, removed);
buckets_unlink_or_oops_do(is_alive, f, start_idx, end_idx, &context);
}
_the_table->bulk_free_entries(&context);
*processed = context._num_processed;
*removed = context._num_removed;
}
void StringTable::buckets_oops_do(OopClosure* f, int start_idx, int end_idx) {
@ -359,7 +367,7 @@ void StringTable::buckets_oops_do(OopClosure* f, int start_idx, int end_idx) {
}
}
void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed) {
void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, BucketUnlinkContext* context) {
const int limit = the_table()->table_size();
assert(0 <= start_idx && start_idx <= limit,
@ -383,10 +391,9 @@ void StringTable::buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClos
p = entry->next_addr();
} else {
*p = entry->next();
the_table()->free_entry(entry);
(*removed)++;
context->free_entry(entry);
}
(*processed)++;
context->_num_processed++;
entry = *p;
}
}