diff src/share/vm/code/codeCache.cpp @ 2457:527977d4f740

7033779: CodeCache::largest_free_block may need to hold the CodeCache lock Reviewed-by: kvn
author never
date Tue, 05 Apr 2011 19:16:52 -0700
parents c7f3d0b4570f
children 3f49d30f8184
line wrap: on
line diff
--- 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();
+  }
+}