hotspot/src/share/vm/gc/shared/vmGCOperations.cpp
changeset 40892 330a02d935ad
parent 37985 539c597ee0fa
child 46996 9cbcd7082efe
equal deleted inserted replaced
40891:8010999ff6d0 40892:330a02d935ad
    60 void VM_GC_Operation::notify_gc_end() {
    60 void VM_GC_Operation::notify_gc_end() {
    61   HOTSPOT_GC_END();
    61   HOTSPOT_GC_END();
    62   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
    62   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
    63 }
    63 }
    64 
    64 
    65 void VM_GC_Operation::acquire_pending_list_lock() {
       
    66   _pending_list_locker.lock();
       
    67 }
       
    68 
       
    69 void VM_GC_Operation::release_and_notify_pending_list_lock() {
       
    70   _pending_list_locker.unlock();
       
    71 }
       
    72 
       
    73 // Allocations may fail in several threads at about the same time,
    65 // Allocations may fail in several threads at about the same time,
    74 // resulting in multiple gc requests.  We only want to do one of them.
    66 // resulting in multiple gc requests.  We only want to do one of them.
    75 // In case a GC locker is active and the need for a GC is already signaled,
    67 // In case a GC locker is active and the need for a GC is already signaled,
    76 // we want to skip this GC attempt altogether, without doing a futile
    68 // we want to skip this GC attempt altogether, without doing a futile
    77 // safepoint operation.
    69 // safepoint operation.
   100               "NewSize, current value " SIZE_FORMAT "%s.",
    92               "NewSize, current value " SIZE_FORMAT "%s.",
   101               byte_size_in_proper_unit(NewSize),
    93               byte_size_in_proper_unit(NewSize),
   102               proper_unit_for_byte_size(NewSize)));
    94               proper_unit_for_byte_size(NewSize)));
   103   }
    95   }
   104 
    96 
   105   acquire_pending_list_lock();
       
   106   // If the GC count has changed someone beat us to the collection
    97   // If the GC count has changed someone beat us to the collection
   107   // Get the Heap_lock after the pending_list_lock.
       
   108   Heap_lock->lock();
    98   Heap_lock->lock();
   109 
    99 
   110   // Check invocations
   100   // Check invocations
   111   if (skip_operation()) {
   101   if (skip_operation()) {
   112     // skip collection
   102     // skip collection
   113     Heap_lock->unlock();
   103     Heap_lock->unlock();
   114     release_and_notify_pending_list_lock();
       
   115     _prologue_succeeded = false;
   104     _prologue_succeeded = false;
   116   } else {
   105   } else {
   117     _prologue_succeeded = true;
   106     _prologue_succeeded = true;
   118   }
   107   }
   119   return _prologue_succeeded;
   108   return _prologue_succeeded;
   120 }
   109 }
   121 
   110 
   122 
   111 
   123 void VM_GC_Operation::doit_epilogue() {
   112 void VM_GC_Operation::doit_epilogue() {
   124   assert(Thread::current()->is_Java_thread(), "just checking");
   113   assert(Thread::current()->is_Java_thread(), "just checking");
   125   // Release the Heap_lock first.
   114   if (Universe::has_reference_pending_list()) {
       
   115     Heap_lock->notify_all();
       
   116   }
   126   Heap_lock->unlock();
   117   Heap_lock->unlock();
   127   release_and_notify_pending_list_lock();
       
   128 }
   118 }
   129 
   119 
   130 bool VM_GC_HeapInspection::skip_operation() const {
   120 bool VM_GC_HeapInspection::skip_operation() const {
   131   return false;
   121   return false;
   132 }
   122 }