17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" 27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 28 #include "gc_implementation/g1/g1CollectorPolicy.hpp" 29 #include "gc_implementation/g1/g1Log.hpp" 30 #include "gc_implementation/g1/vm_operations_g1.hpp" 31 #include "gc_implementation/shared/gcTimer.hpp" 32 #include "gc_implementation/shared/gcTraceTime.hpp" 33 #include "gc_implementation/shared/isGCActiveMark.hpp" 34 #include "gc_implementation/g1/vm_operations_g1.hpp" 35 #include "runtime/interfaceSupport.hpp" 36 37 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before, 38 size_t word_size) 39 : VM_G1OperationWithAllocRequest(gc_count_before, word_size, 40 GCCause::_allocation_failure) { 41 guarantee(word_size != 0, "An allocation should always be requested with this operation."); 42 } 43 44 void VM_G1CollectForAllocation::doit() { 45 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 46 GCCauseSetter x(g1h, _gc_cause); 47 48 _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded); 49 assert(_result == NULL || _pause_succeeded, 50 "if we get back a result, the pause should have succeeded"); 51 } 52 53 void VM_G1CollectFull::doit() { 54 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 55 GCCauseSetter x(g1h, _gc_cause); 56 g1h->do_full_collection(false /* clear_all_soft_refs */); 208 // The caller may block while communicating 209 // with the SLT thread in order to acquire/release the PLL. 210 SurrogateLockerThread* slt = ConcurrentMarkThread::slt(); 211 if (slt != NULL) { 212 slt->manipulatePLL(SurrogateLockerThread::acquirePLL); 213 } else { 214 SurrogateLockerThread::report_missing_slt(); 215 } 216 } 217 218 void VM_CGC_Operation::release_and_notify_pending_list_lock() { 219 assert(_needs_pll, "don't call this otherwise"); 220 // The caller may block while communicating 221 // with the SLT thread in order to acquire/release the PLL. 222 ConcurrentMarkThread::slt()-> 223 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL); 224 } 225 226 void VM_CGC_Operation::doit() { 227 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); 228 GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm(), G1CollectedHeap::heap()->concurrent_mark()->concurrent_gc_id()); 229 SharedHeap* sh = SharedHeap::heap(); 230 // This could go away if CollectedHeap gave access to _gc_is_active... 231 if (sh != NULL) { 232 IsGCActiveMark x; 233 _cl->do_void(); 234 } else { 235 _cl->do_void(); 236 } 237 } 238 239 bool VM_CGC_Operation::doit_prologue() { 240 // Note the relative order of the locks must match that in 241 // VM_GC_Operation::doit_prologue() or deadlocks can occur 242 if (_needs_pll) { 243 acquire_pending_list_lock(); 244 } 245 246 Heap_lock->lock(); 247 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true; 248 return true; 249 } 250 251 void VM_CGC_Operation::doit_epilogue() { 252 // Note the relative order of the unlocks must match that in 253 // VM_GC_Operation::doit_epilogue() 254 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false; 255 Heap_lock->unlock(); 256 if (_needs_pll) { 257 release_and_notify_pending_list_lock(); 258 } 259 } | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" 27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 28 #include "gc_implementation/g1/g1CollectorPolicy.hpp" 29 #include "gc_implementation/g1/g1Log.hpp" 30 #include "gc_implementation/g1/vm_operations_g1.hpp" 31 #include "gc_implementation/shared/gcTimer.hpp" 32 #include "gc_implementation/shared/gcTraceTime.hpp" 33 #include "gc_implementation/shared/isGCActiveMark.hpp" 34 #include "gc_implementation/g1/vm_operations_g1.hpp" 35 #include "runtime/interfaceSupport.hpp" 36 37 bool VM_G1OperationWithAllocRequest::doit_prologue() { 38 bool succeeded = VM_CollectForAllocation::doit_prologue(); 39 if (succeeded) { 40 G1CollectedHeap::heap()->set_heap_lock_held_for_gc(true); 41 } 42 return succeeded; 43 } 44 45 void VM_G1OperationWithAllocRequest::doit_epilogue() { 46 G1CollectedHeap::heap()->set_heap_lock_held_for_gc(false); 47 VM_CollectForAllocation::doit_epilogue(); 48 } 49 50 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before, 51 size_t word_size) 52 : VM_G1OperationWithAllocRequest(gc_count_before, word_size, 53 GCCause::_allocation_failure) { 54 guarantee(word_size != 0, "An allocation should always be requested with this operation."); 55 } 56 57 void VM_G1CollectForAllocation::doit() { 58 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 59 GCCauseSetter x(g1h, _gc_cause); 60 61 _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded); 62 assert(_result == NULL || _pause_succeeded, 63 "if we get back a result, the pause should have succeeded"); 64 } 65 66 void VM_G1CollectFull::doit() { 67 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 68 GCCauseSetter x(g1h, _gc_cause); 69 g1h->do_full_collection(false /* clear_all_soft_refs */); 221 // The caller may block while communicating 222 // with the SLT thread in order to acquire/release the PLL. 223 SurrogateLockerThread* slt = ConcurrentMarkThread::slt(); 224 if (slt != NULL) { 225 slt->manipulatePLL(SurrogateLockerThread::acquirePLL); 226 } else { 227 SurrogateLockerThread::report_missing_slt(); 228 } 229 } 230 231 void VM_CGC_Operation::release_and_notify_pending_list_lock() { 232 assert(_needs_pll, "don't call this otherwise"); 233 // The caller may block while communicating 234 // with the SLT thread in order to acquire/release the PLL. 235 ConcurrentMarkThread::slt()-> 236 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL); 237 } 238 239 void VM_CGC_Operation::doit() { 240 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); 241 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 242 GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm(), g1h->concurrent_mark()->concurrent_gc_id()); 243 IsGCActiveMark x; 244 _cl->do_void(); 245 } 246 247 bool VM_CGC_Operation::doit_prologue() { 248 // Note the relative order of the locks must match that in 249 // VM_GC_Operation::doit_prologue() or deadlocks can occur 250 if (_needs_pll) { 251 acquire_pending_list_lock(); 252 } 253 254 Heap_lock->lock(); 255 G1CollectedHeap::heap()->set_heap_lock_held_for_gc(true); 256 return true; 257 } 258 259 void VM_CGC_Operation::doit_epilogue() { 260 // Note the relative order of the unlocks must match that in 261 // VM_GC_Operation::doit_epilogue() 262 G1CollectedHeap::heap()->set_heap_lock_held_for_gc(false); 263 Heap_lock->unlock(); 264 if (_needs_pll) { 265 release_and_notify_pending_list_lock(); 266 } 267 } |