< prev index next >

src/hotspot/share/memory/heap.cpp

Print this page
rev 54099 : 8219586: CodeHeap State Analytics processes dead nmethods
Reviewed-by: thartmann, eosterlund

@@ -202,10 +202,11 @@
 
 bool CodeHeap::reserve(ReservedSpace rs, size_t committed_size, size_t segment_size) {
   assert(rs.size() >= committed_size, "reserved < committed");
   assert(segment_size >= sizeof(FreeBlock), "segment size is too small");
   assert(is_power_of_2(segment_size), "segment_size must be a power of 2");
+  assert_locked_or_safepoint(CodeCache_lock);
 
   _segment_size      = segment_size;
   _log2_segment_size = exact_log2(segment_size);
 
   // Reserve and initialize space for _memory.

@@ -250,10 +251,12 @@
   return true;
 }
 
 
 bool CodeHeap::expand_by(size_t size) {
+  assert_locked_or_safepoint(CodeCache_lock);
+
   // expand _memory space
   size_t dm = align_to_page_size(_memory.committed_size() + size) - _memory.committed_size();
   if (dm > 0) {
     // Use at least the available uncommitted space if 'size' is larger
     if (_memory.uncommitted_size() != 0 && dm > _memory.uncommitted_size()) {

@@ -280,10 +283,11 @@
 
 
 void* CodeHeap::allocate(size_t instance_size) {
   size_t number_of_segments = size_to_segments(instance_size + header_size());
   assert(segments_to_size(number_of_segments) >= sizeof(FreeBlock), "not enough room for FreeList");
+  assert_locked_or_safepoint(CodeCache_lock);
 
   // First check if we can satisfy request from freelist
   NOT_PRODUCT(verify());
   HeapBlock* block = search_freelist(number_of_segments);
   NOT_PRODUCT(verify());

@@ -344,10 +348,12 @@
   return newb;
 }
 
 void CodeHeap::deallocate_tail(void* p, size_t used_size) {
   assert(p == find_start(p), "illegal deallocation");
+  assert_locked_or_safepoint(CodeCache_lock);
+
   // Find start of HeapBlock
   HeapBlock* b = (((HeapBlock *)p) - 1);
   assert(b->allocated_space() == p, "sanity check");
 
   size_t actual_number_of_segments = b->length();

@@ -360,10 +366,12 @@
   NOT_PRODUCT(verify());
 }
 
 void CodeHeap::deallocate(void* p) {
   assert(p == find_start(p), "illegal deallocation");
+  assert_locked_or_safepoint(CodeCache_lock);
+
   // Find start of HeapBlock
   HeapBlock* b = (((HeapBlock *)p) - 1);
   assert(b->allocated_space() == p, "sanity check");
   guarantee((char*) b >= _memory.low_boundary() && (char*) b < _memory.high(),
             "The block to be deallocated " INTPTR_FORMAT " is not within the heap "

@@ -787,10 +795,11 @@
   tty->print_cr("The Heap");
 }
 
 void CodeHeap::verify() {
   if (VerifyCodeCache) {
+    assert_locked_or_safepoint(CodeCache_lock);
     size_t len = 0;
     int count = 0;
     for(FreeBlock* b = _freelist; b != NULL; b = b->link()) {
       len += b->length();
       count++;
< prev index next >