# HG changeset patch # User never # Date 1302056212 25200 # Node ID 527977d4f740456a7cc0ec2ac677e333107a76df # Parent 8e77e1f261884c35e6004be05f31057137a8c2bf 7033779: CodeCache::largest_free_block may need to hold the CodeCache lock Reviewed-by: kvn diff -r 8e77e1f26188 -r 527977d4f740 src/share/vm/code/codeCache.cpp --- a/src/share/vm/code/codeCache.cpp Tue Apr 05 02:31:46 2011 -0700 +++ b/src/share/vm/code/codeCache.cpp Tue Apr 05 19:16:52 2011 -0700 @@ -964,3 +964,14 @@ 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(); + } +} diff -r 8e77e1f26188 -r 527977d4f740 src/share/vm/code/codeCache.hpp --- a/src/share/vm/code/codeCache.hpp Tue Apr 05 02:31:46 2011 -0700 +++ b/src/share/vm/code/codeCache.hpp Tue Apr 05 19:16:52 2011 -0700 @@ -160,7 +160,7 @@ static size_t capacity() { return _heap->capacity(); } static size_t max_capacity() { return _heap->max_capacity(); } static size_t unallocated_capacity() { return _heap->unallocated_capacity(); } - static size_t largest_free_block() { return _heap->largest_free_block(); } + static size_t largest_free_block(); static bool needs_flushing() { return largest_free_block() < CodeCacheFlushingMinimumFreeSpace; } static bool needs_cache_clean() { return _needs_cache_clean; }