< prev index next >

src/hotspot/share/gc/shared/genCollectedHeap.cpp

Print this page




 350 void GenCollectedHeap::do_collection(bool           full,
 351                                      bool           clear_all_soft_refs,
 352                                      size_t         size,
 353                                      bool           is_tlab,
 354                                      GenerationType max_generation) {
 355   ResourceMark rm;
 356   DEBUG_ONLY(Thread* my_thread = Thread::current();)
 357 
 358   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 359   assert(my_thread->is_VM_thread() ||
 360          my_thread->is_ConcurrentGC_thread(),
 361          "incorrect thread type capability");
 362   assert(Heap_lock->is_locked(),
 363          "the requesting thread should have the Heap_lock");
 364   guarantee(!is_gc_active(), "collection is not reentrant");
 365 
 366   if (GCLocker::check_active_before_gc()) {
 367     return; // GC is disabled (e.g. JNI GetXXXCritical operation)
 368   }
 369 
 370   GCIdMarkAndRestore gc_id_mark;
 371 
 372   const bool do_clear_all_soft_refs = clear_all_soft_refs ||
 373                           collector_policy()->should_clear_all_soft_refs();
 374 
 375   ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
 376 
 377   const size_t metadata_prev_used = MetaspaceAux::used_bytes();
 378 
 379   print_heap_before_gc();
 380 
 381   {
 382     FlagSetting fl(_is_gc_active, true);
 383 
 384     bool complete = full && (max_generation == OldGen);
 385     bool old_collects_young = complete && !ScavengeBeforeFullGC;
 386     bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
 387 
 388     FormatBuffer<> gc_string("%s", "Pause ");
 389     if (do_young_collection) {
 390       gc_string.append("Young");


 425         // Allocation request was met by young GC.
 426         size = 0;
 427       }
 428     }
 429 
 430     bool must_restore_marks_for_biased_locking = false;
 431 
 432     if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
 433       if (!complete) {
 434         // The full_collections increment was missed above.
 435         increment_total_full_collections();
 436       }
 437 
 438       if (!prepared_for_verification && run_verification &&
 439           VerifyGCLevel <= 1 && VerifyBeforeGC) {
 440         prepare_for_verify();
 441       }
 442 
 443       if (do_young_collection) {
 444         // We did a young GC. Need a new GC id for the old GC.
 445         GCIdMarkAndRestore gc_id_mark;
 446         GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
 447         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 448       } else {
 449         // No young GC done. Use the same GC id as was set up earlier in this method.
 450         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 451       }
 452 
 453       must_restore_marks_for_biased_locking = true;
 454       collected_old = true;
 455     }
 456 
 457     // Update "complete" boolean wrt what actually transpired --
 458     // for instance, a promotion failure could have led to
 459     // a whole heap collection.
 460     complete = complete || collected_old;
 461 
 462     print_heap_change(young_prev_used, old_prev_used);
 463     MetaspaceAux::print_metaspace_change(metadata_prev_used);
 464 
 465     // Adjust generation sizes.




 350 void GenCollectedHeap::do_collection(bool           full,
 351                                      bool           clear_all_soft_refs,
 352                                      size_t         size,
 353                                      bool           is_tlab,
 354                                      GenerationType max_generation) {
 355   ResourceMark rm;
 356   DEBUG_ONLY(Thread* my_thread = Thread::current();)
 357 
 358   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 359   assert(my_thread->is_VM_thread() ||
 360          my_thread->is_ConcurrentGC_thread(),
 361          "incorrect thread type capability");
 362   assert(Heap_lock->is_locked(),
 363          "the requesting thread should have the Heap_lock");
 364   guarantee(!is_gc_active(), "collection is not reentrant");
 365 
 366   if (GCLocker::check_active_before_gc()) {
 367     return; // GC is disabled (e.g. JNI GetXXXCritical operation)
 368   }
 369 
 370   GCIdMark gc_id_mark;
 371 
 372   const bool do_clear_all_soft_refs = clear_all_soft_refs ||
 373                           collector_policy()->should_clear_all_soft_refs();
 374 
 375   ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
 376 
 377   const size_t metadata_prev_used = MetaspaceAux::used_bytes();
 378 
 379   print_heap_before_gc();
 380 
 381   {
 382     FlagSetting fl(_is_gc_active, true);
 383 
 384     bool complete = full && (max_generation == OldGen);
 385     bool old_collects_young = complete && !ScavengeBeforeFullGC;
 386     bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
 387 
 388     FormatBuffer<> gc_string("%s", "Pause ");
 389     if (do_young_collection) {
 390       gc_string.append("Young");


 425         // Allocation request was met by young GC.
 426         size = 0;
 427       }
 428     }
 429 
 430     bool must_restore_marks_for_biased_locking = false;
 431 
 432     if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
 433       if (!complete) {
 434         // The full_collections increment was missed above.
 435         increment_total_full_collections();
 436       }
 437 
 438       if (!prepared_for_verification && run_verification &&
 439           VerifyGCLevel <= 1 && VerifyBeforeGC) {
 440         prepare_for_verify();
 441       }
 442 
 443       if (do_young_collection) {
 444         // We did a young GC. Need a new GC id for the old GC.
 445         GCIdMark gc_id_mark;
 446         GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
 447         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 448       } else {
 449         // No young GC done. Use the same GC id as was set up earlier in this method.
 450         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 451       }
 452 
 453       must_restore_marks_for_biased_locking = true;
 454       collected_old = true;
 455     }
 456 
 457     // Update "complete" boolean wrt what actually transpired --
 458     // for instance, a promotion failure could have led to
 459     // a whole heap collection.
 460     complete = complete || collected_old;
 461 
 462     print_heap_change(young_prev_used, old_prev_used);
 463     MetaspaceAux::print_metaspace_change(metadata_prev_used);
 464 
 465     // Adjust generation sizes.


< prev index next >