7033779: CodeCache::largest_free_block may need to hold the CodeCache lock

Reviewed-by: kvn
This commit is contained in:
Tom Rodriguez 2011-04-05 19:16:52 -07:00
parent 14dcde9439
commit 4f41ea7fff
2 changed files with 12 additions and 1 deletions

View file

@ -964,3 +964,14 @@ void CodeCache::log_state(outputStream* st) {
nof_blobs(), nof_nmethods(), nof_adapters(),
unallocated_capacity(), largest_free_block());
}
size_t CodeCache::largest_free_block() {
// This is called both with and without CodeCache_lock held so
// handle both cases.
if (CodeCache_lock->owned_by_self()) {
return _heap->largest_free_block();
} else {
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
return _heap->largest_free_block();
}
}