< prev index next >

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

Print this page

 865   _gc_timer->register_gc_end();
 866 
 867   _gc_tracer->report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
 868 }
 869 
 870 void DefNewGeneration::init_assuming_no_promotion_failure() {
 871   _promotion_failed = false;
 872   _promotion_failed_info.reset();
 873   from()->set_next_compaction_space(nullptr);
 874 }
 875 
 876 void DefNewGeneration::remove_forwarding_pointers() {
 877   assert(_promotion_failed, "precondition");
 878 
 879   // Will enter Full GC soon due to failed promotion. Must reset the mark word
 880   // of objs in young-gen so that no objs are marked (forwarded) when Full GC
 881   // starts. (The mark word is overloaded: `is_marked()` == `is_forwarded()`.)
 882   struct ResetForwardedMarkWord : ObjectClosure {
 883     void do_object(oop obj) override {
 884       if (obj->is_forwarded()) {
 885         obj->init_mark();
 886       }
 887     }
 888   } cl;
 889   eden()->object_iterate(&cl);
 890   from()->object_iterate(&cl);
 891 
 892   restore_preserved_marks();
 893 }
 894 
 895 void DefNewGeneration::restore_preserved_marks() {
 896   _preserved_marks_set.restore(nullptr);
 897 }
 898 
 899 void DefNewGeneration::handle_promotion_failure(oop old) {
 900   log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size());
 901 
 902   _promotion_failed = true;
 903   _promotion_failed_info.register_copy_failure(old->size());
 904   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
 905 
 906   ContinuationGCSupport::transform_stack_chunk(old);
 907 
 908   // forward to self
 909   old->forward_to(old);
 910 
 911   _promo_failure_scan_stack.push(old);
 912 
 913   if (!_promo_failure_drain_in_progress) {
 914     // prevent recursion in copy_to_survivor_space()
 915     _promo_failure_drain_in_progress = true;
 916     drain_promo_failure_scan_stack();
 917     _promo_failure_drain_in_progress = false;
 918   }
 919 }
 920 
 921 oop DefNewGeneration::copy_to_survivor_space(oop old) {
 922   assert(is_in_reserved(old) && !old->is_forwarded(),
 923          "shouldn't be scavenging this oop");
 924   size_t s = old->size();
 925   oop obj = nullptr;
 926 
 927   // Try allocating obj in to-space (unless too old)
 928   if (old->age() < tenuring_threshold()) {
 929     obj = cast_to_oop(to()->allocate(s));

 865   _gc_timer->register_gc_end();
 866 
 867   _gc_tracer->report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
 868 }
 869 
 870 void DefNewGeneration::init_assuming_no_promotion_failure() {
 871   _promotion_failed = false;
 872   _promotion_failed_info.reset();
 873   from()->set_next_compaction_space(nullptr);
 874 }
 875 
 876 void DefNewGeneration::remove_forwarding_pointers() {
 877   assert(_promotion_failed, "precondition");
 878 
 879   // Will enter Full GC soon due to failed promotion. Must reset the mark word
 880   // of objs in young-gen so that no objs are marked (forwarded) when Full GC
 881   // starts. (The mark word is overloaded: `is_marked()` == `is_forwarded()`.)
 882   struct ResetForwardedMarkWord : ObjectClosure {
 883     void do_object(oop obj) override {
 884       if (obj->is_forwarded()) {
 885         obj->forward_safe_init_mark();
 886       }
 887     }
 888   } cl;
 889   eden()->object_iterate(&cl);
 890   from()->object_iterate(&cl);
 891 
 892   restore_preserved_marks();
 893 }
 894 
 895 void DefNewGeneration::restore_preserved_marks() {
 896   _preserved_marks_set.restore(nullptr);
 897 }
 898 
 899 void DefNewGeneration::handle_promotion_failure(oop old) {
 900   log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size());
 901 
 902   _promotion_failed = true;
 903   _promotion_failed_info.register_copy_failure(old->size());
 904   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
 905 
 906   ContinuationGCSupport::transform_stack_chunk(old);
 907 
 908   old->forward_to_self();

 909 
 910   _promo_failure_scan_stack.push(old);
 911 
 912   if (!_promo_failure_drain_in_progress) {
 913     // prevent recursion in copy_to_survivor_space()
 914     _promo_failure_drain_in_progress = true;
 915     drain_promo_failure_scan_stack();
 916     _promo_failure_drain_in_progress = false;
 917   }
 918 }
 919 
 920 oop DefNewGeneration::copy_to_survivor_space(oop old) {
 921   assert(is_in_reserved(old) && !old->is_forwarded(),
 922          "shouldn't be scavenging this oop");
 923   size_t s = old->size();
 924   oop obj = nullptr;
 925 
 926   // Try allocating obj in to-space (unless too old)
 927   if (old->age() < tenuring_threshold()) {
 928     obj = cast_to_oop(to()->allocate(s));
< prev index next >