< prev index next >

src/hotspot/share/gc/serial/defNewGeneration.cpp

Print this page

658   _gc_timer->register_gc_end();
659 
660   gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
661 }
662 
663 void DefNewGeneration::init_assuming_no_promotion_failure() {
664   _promotion_failed = false;
665   _promotion_failed_info.reset();
666   from()->set_next_compaction_space(NULL);
667 }
668 
669 void DefNewGeneration::remove_forwarding_pointers() {
670   assert(_promotion_failed, "precondition");
671 
672   // Will enter Full GC soon due to failed promotion. Must reset the mark word
673   // of objs in young-gen so that no objs are marked (forwarded) when Full GC
674   // starts. (The mark word is overloaded: `is_marked()` == `is_forwarded()`.)
675   struct ResetForwardedMarkWord : ObjectClosure {
676     void do_object(oop obj) override {
677       if (obj->is_forwarded()) {










678         obj->init_mark();

679       }
680     }
681   } cl;
682   eden()->object_iterate(&cl);
683   from()->object_iterate(&cl);
684 
685   restore_preserved_marks();
686 }
687 
688 void DefNewGeneration::restore_preserved_marks() {
689   _preserved_marks_set.restore(NULL);
690 }
691 
692 void DefNewGeneration::handle_promotion_failure(oop old) {
693   log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size());
694 
695   _promotion_failed = true;
696   _promotion_failed_info.register_copy_failure(old->size());
697   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
698 
699   ContinuationGCSupport::transform_stack_chunk(old);
700 
701   // forward to self
702   old->forward_to(old);
703 
704   _promo_failure_scan_stack.push(old);
705 
706   if (!_promo_failure_drain_in_progress) {
707     // prevent recursion in copy_to_survivor_space()
708     _promo_failure_drain_in_progress = true;
709     drain_promo_failure_scan_stack();
710     _promo_failure_drain_in_progress = false;
711   }
712 }
713 
714 oop DefNewGeneration::copy_to_survivor_space(oop old) {
715   assert(is_in_reserved(old) && !old->is_forwarded(),
716          "shouldn't be scavenging this oop");
717   size_t s = old->size();
718   oop obj = NULL;
719 
720   // Try allocating obj in to-space (unless too old)
721   if (old->age() < tenuring_threshold()) {
722     obj = cast_to_oop(to()->allocate(s));

658   _gc_timer->register_gc_end();
659 
660   gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
661 }
662 
663 void DefNewGeneration::init_assuming_no_promotion_failure() {
664   _promotion_failed = false;
665   _promotion_failed_info.reset();
666   from()->set_next_compaction_space(NULL);
667 }
668 
669 void DefNewGeneration::remove_forwarding_pointers() {
670   assert(_promotion_failed, "precondition");
671 
672   // Will enter Full GC soon due to failed promotion. Must reset the mark word
673   // of objs in young-gen so that no objs are marked (forwarded) when Full GC
674   // starts. (The mark word is overloaded: `is_marked()` == `is_forwarded()`.)
675   struct ResetForwardedMarkWord : ObjectClosure {
676     void do_object(oop obj) override {
677       if (obj->is_forwarded()) {
678 #ifdef _LP64
679         oop forwardee = obj->forwardee();
680         markWord header = forwardee->mark();
681         if (header.has_displaced_mark_helper()) {
682           header = header.displaced_mark_helper();
683         }
684         assert(UseCompressedClassPointers, "assume +UseCompressedClassPointers");
685         narrowKlass nklass = header.narrow_klass();
686         obj->set_mark(markWord::prototype().set_narrow_klass(nklass));
687 #else
688         obj->init_mark();
689 #endif
690       }
691     }
692   } cl;
693   eden()->object_iterate(&cl);
694   from()->object_iterate(&cl);
695 
696   restore_preserved_marks();
697 }
698 
699 void DefNewGeneration::restore_preserved_marks() {
700   _preserved_marks_set.restore(NULL);
701 }
702 
703 void DefNewGeneration::handle_promotion_failure(oop old) {
704   log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size());
705 
706   _promotion_failed = true;
707   _promotion_failed_info.register_copy_failure(old->size());
708   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
709 
710   ContinuationGCSupport::transform_stack_chunk(old);
711 
712   // forward to self
713   old->forward_to_self();
714 
715   _promo_failure_scan_stack.push(old);
716 
717   if (!_promo_failure_drain_in_progress) {
718     // prevent recursion in copy_to_survivor_space()
719     _promo_failure_drain_in_progress = true;
720     drain_promo_failure_scan_stack();
721     _promo_failure_drain_in_progress = false;
722   }
723 }
724 
725 oop DefNewGeneration::copy_to_survivor_space(oop old) {
726   assert(is_in_reserved(old) && !old->is_forwarded(),
727          "shouldn't be scavenging this oop");
728   size_t s = old->size();
729   oop obj = NULL;
730 
731   // Try allocating obj in to-space (unless too old)
732   if (old->age() < tenuring_threshold()) {
733     obj = cast_to_oop(to()->allocate(s));
< prev index next >