87 // we want to skip this GC attempt altogether, without doing a futile 88 // safepoint operation. 89 bool VM_GC_Operation::skip_operation() const { 90 bool skip = (_gc_count_before != Universe::heap()->total_collections()); 91 if (_full && skip) { 92 skip = (_full_gc_count_before != Universe::heap()->total_full_collections()); 93 } 94 if (!skip && GC_locker::is_active_and_needs_gc()) { 95 skip = Universe::heap()->is_maximal_no_gc(); 96 assert(!(skip && (_gc_cause == GCCause::_gc_locker)), 97 "GC_locker cannot be active when initiating GC"); 98 } 99 return skip; 100 } 101 102 bool VM_GC_Operation::doit_prologue() { 103 assert(Thread::current()->is_Java_thread(), "just checking"); 104 assert(((_gc_cause != GCCause::_no_gc) && 105 (_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause"); 106 107 acquire_pending_list_lock(); 108 // If the GC count has changed someone beat us to the collection 109 // Get the Heap_lock after the pending_list_lock. 110 Heap_lock->lock(); 111 112 // Check invocations 113 if (skip_operation()) { 114 // skip collection 115 Heap_lock->unlock(); 116 release_and_notify_pending_list_lock(); 117 _prologue_succeeded = false; 118 } else { 119 _prologue_succeeded = true; 120 SharedHeap* sh = SharedHeap::heap(); 121 if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = true; 122 } 123 return _prologue_succeeded; 124 } 125 126 | 87 // we want to skip this GC attempt altogether, without doing a futile 88 // safepoint operation. 89 bool VM_GC_Operation::skip_operation() const { 90 bool skip = (_gc_count_before != Universe::heap()->total_collections()); 91 if (_full && skip) { 92 skip = (_full_gc_count_before != Universe::heap()->total_full_collections()); 93 } 94 if (!skip && GC_locker::is_active_and_needs_gc()) { 95 skip = Universe::heap()->is_maximal_no_gc(); 96 assert(!(skip && (_gc_cause == GCCause::_gc_locker)), 97 "GC_locker cannot be active when initiating GC"); 98 } 99 return skip; 100 } 101 102 bool VM_GC_Operation::doit_prologue() { 103 assert(Thread::current()->is_Java_thread(), "just checking"); 104 assert(((_gc_cause != GCCause::_no_gc) && 105 (_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause"); 106 107 // To be able to handle a GC the VM initialization needs to be completed. 108 if (!is_init_completed()) { 109 vm_exit_during_initialization( 110 err_msg("GC triggered before VM initialization completed. Try increasing " 111 "NewSize, current value " UINTX_FORMAT "K.", NewSize / K)); 112 } 113 114 acquire_pending_list_lock(); 115 // If the GC count has changed someone beat us to the collection 116 // Get the Heap_lock after the pending_list_lock. 117 Heap_lock->lock(); 118 119 // Check invocations 120 if (skip_operation()) { 121 // skip collection 122 Heap_lock->unlock(); 123 release_and_notify_pending_list_lock(); 124 _prologue_succeeded = false; 125 } else { 126 _prologue_succeeded = true; 127 SharedHeap* sh = SharedHeap::heap(); 128 if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = true; 129 } 130 return _prologue_succeeded; 131 } 132 133 |