comparison src/share/vm/gc_implementation/shared/vmGCOperations.cpp @ 342:37f87013dfd8

6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
author ysr
date Thu, 05 Jun 2008 15:57:56 -0700
parents c0492d52d55b
children 1ee8caae33af
comparison
equal deleted inserted replaced
189:0b27f3512f9e 342:37f87013dfd8
72 72
73 acquire_pending_list_lock(); 73 acquire_pending_list_lock();
74 // If the GC count has changed someone beat us to the collection 74 // If the GC count has changed someone beat us to the collection
75 // Get the Heap_lock after the pending_list_lock. 75 // Get the Heap_lock after the pending_list_lock.
76 Heap_lock->lock(); 76 Heap_lock->lock();
77
77 // Check invocations 78 // Check invocations
78 if (skip_operation()) { 79 if (skip_operation()) {
79 // skip collection 80 // skip collection
80 Heap_lock->unlock(); 81 Heap_lock->unlock();
81 release_and_notify_pending_list_lock(); 82 release_and_notify_pending_list_lock();
82 _prologue_succeeded = false; 83 _prologue_succeeded = false;
83 } else { 84 } else {
84 _prologue_succeeded = true; 85 _prologue_succeeded = true;
86 SharedHeap* sh = SharedHeap::heap();
87 if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = true;
85 } 88 }
86 return _prologue_succeeded; 89 return _prologue_succeeded;
87 } 90 }
88 91
89 92
90 void VM_GC_Operation::doit_epilogue() { 93 void VM_GC_Operation::doit_epilogue() {
91 assert(Thread::current()->is_Java_thread(), "just checking"); 94 assert(Thread::current()->is_Java_thread(), "just checking");
92 // Release the Heap_lock first. 95 // Release the Heap_lock first.
96 SharedHeap* sh = SharedHeap::heap();
97 if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = false;
93 Heap_lock->unlock(); 98 Heap_lock->unlock();
94 release_and_notify_pending_list_lock(); 99 release_and_notify_pending_list_lock();
95 } 100 }
96 101
97 bool VM_GC_HeapInspection::doit_prologue() { 102 bool VM_GC_HeapInspection::doit_prologue() {
146 } 151 }
147 152
148 void VM_GenCollectForPermanentAllocation::doit() { 153 void VM_GenCollectForPermanentAllocation::doit() {
149 JvmtiGCForAllocationMarker jgcm; 154 JvmtiGCForAllocationMarker jgcm;
150 notify_gc_begin(true); 155 notify_gc_begin(true);
151 GenCollectedHeap* gch = GenCollectedHeap::heap(); 156 SharedHeap* heap = (SharedHeap*)Universe::heap();
152 GCCauseSetter gccs(gch, _gc_cause); 157 GCCauseSetter gccs(heap, _gc_cause);
153 gch->do_full_collection(gch->must_clear_all_soft_refs(), 158 switch (heap->kind()) {
154 gch->n_gens() - 1); 159 case (CollectedHeap::GenCollectedHeap): {
155 _res = gch->perm_gen()->allocate(_size, false); 160 GenCollectedHeap* gch = (GenCollectedHeap*)heap;
156 assert(gch->is_in_reserved_or_null(_res), "result not in heap"); 161 gch->do_full_collection(gch->must_clear_all_soft_refs(),
162 gch->n_gens() - 1);
163 break;
164 }
165 #ifndef SERIALGC
166 case (CollectedHeap::G1CollectedHeap): {
167 G1CollectedHeap* g1h = (G1CollectedHeap*)heap;
168 g1h->do_full_collection(_gc_cause == GCCause::_last_ditch_collection);
169 break;
170 }
171 #endif // SERIALGC
172 default:
173 ShouldNotReachHere();
174 }
175 _res = heap->perm_gen()->allocate(_size, false);
176 assert(heap->is_in_reserved_or_null(_res), "result not in heap");
157 if (_res == NULL && GC_locker::is_active_and_needs_gc()) { 177 if (_res == NULL && GC_locker::is_active_and_needs_gc()) {
158 set_gc_locked(); 178 set_gc_locked();
159 } 179 }
160 notify_gc_end(); 180 notify_gc_end();
161 } 181 }