< prev index next >

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

Print this page

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










679         obj->init_mark();

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

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