844 |
844 |
845 // If the next generation is too full to accomodate worst-case promotion |
845 // If the next generation is too full to accomodate worst-case promotion |
846 // from this generation, pass on collection; let the next generation |
846 // from this generation, pass on collection; let the next generation |
847 // do it. |
847 // do it. |
848 if (!collection_attempt_is_safe()) { |
848 if (!collection_attempt_is_safe()) { |
849 gch->set_incremental_collection_will_fail(); |
849 gch->set_incremental_collection_failed(); // slight lie, in that we did not even attempt one |
850 return; |
850 return; |
851 } |
851 } |
852 assert(to()->is_empty(), "Else not collection_attempt_is_safe"); |
852 assert(to()->is_empty(), "Else not collection_attempt_is_safe"); |
853 |
853 |
854 init_assuming_no_promotion_failure(); |
854 init_assuming_no_promotion_failure(); |
933 // for full GC's. |
933 // for full GC's. |
934 size_policy->reset_gc_overhead_limit_count(); |
934 size_policy->reset_gc_overhead_limit_count(); |
935 |
935 |
936 assert(to()->is_empty(), "to space should be empty now"); |
936 assert(to()->is_empty(), "to space should be empty now"); |
937 } else { |
937 } else { |
938 assert(HandlePromotionFailure, |
|
939 "Should only be here if promotion failure handling is on"); |
|
940 assert(_promo_failure_scan_stack.is_empty(), "post condition"); |
938 assert(_promo_failure_scan_stack.is_empty(), "post condition"); |
941 _promo_failure_scan_stack.clear(true); // Clear cached segments. |
939 _promo_failure_scan_stack.clear(true); // Clear cached segments. |
942 |
940 |
943 remove_forwarding_pointers(); |
941 remove_forwarding_pointers(); |
944 if (PrintGCDetails) { |
942 if (PrintGCDetails) { |
945 gclog_or_tty->print(" (promotion failed)"); |
943 gclog_or_tty->print(" (promotion failed)"); |
946 } |
944 } |
947 // All the spaces are in play for mark-sweep. |
945 // All the spaces are in play for mark-sweep. |
948 swap_spaces(); // Make life simpler for CMS || rescan; see 6483690. |
946 swap_spaces(); // Make life simpler for CMS || rescan; see 6483690. |
949 from()->set_next_compaction_space(to()); |
947 from()->set_next_compaction_space(to()); |
950 gch->set_incremental_collection_will_fail(); |
948 gch->set_incremental_collection_failed(); |
951 // Inform the next generation that a promotion failure occurred. |
949 // Inform the next generation that a promotion failure occurred. |
952 _next_gen->promotion_failure_occurred(); |
950 _next_gen->promotion_failure_occurred(); |
953 |
951 |
954 // Reset the PromotionFailureALot counters. |
952 // Reset the PromotionFailureALot counters. |
955 NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();) |
953 NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();) |
1090 |
1088 |
1091 new_obj = _next_gen->par_promote(par_scan_state->thread_num(), |
1089 new_obj = _next_gen->par_promote(par_scan_state->thread_num(), |
1092 old, m, sz); |
1090 old, m, sz); |
1093 |
1091 |
1094 if (new_obj == NULL) { |
1092 if (new_obj == NULL) { |
1095 if (!HandlePromotionFailure) { |
|
1096 // A failed promotion likely means the MaxLiveObjectEvacuationRatio flag |
|
1097 // is incorrectly set. In any case, its seriously wrong to be here! |
|
1098 vm_exit_out_of_memory(sz*wordSize, "promotion"); |
|
1099 } |
|
1100 // promotion failed, forward to self |
1093 // promotion failed, forward to self |
1101 _promotion_failed = true; |
1094 _promotion_failed = true; |
1102 new_obj = old; |
1095 new_obj = old; |
1103 |
1096 |
1104 preserve_mark_if_necessary(old, m); |
1097 preserve_mark_if_necessary(old, m); |
1204 // try allocating obj tenured |
1197 // try allocating obj tenured |
1205 new_obj = _next_gen->par_promote(par_scan_state->thread_num(), |
1198 new_obj = _next_gen->par_promote(par_scan_state->thread_num(), |
1206 old, m, sz); |
1199 old, m, sz); |
1207 |
1200 |
1208 if (new_obj == NULL) { |
1201 if (new_obj == NULL) { |
1209 if (!HandlePromotionFailure) { |
|
1210 // A failed promotion likely means the MaxLiveObjectEvacuationRatio |
|
1211 // flag is incorrectly set. In any case, its seriously wrong to be |
|
1212 // here! |
|
1213 vm_exit_out_of_memory(sz*wordSize, "promotion"); |
|
1214 } |
|
1215 // promotion failed, forward to self |
1202 // promotion failed, forward to self |
1216 forward_ptr = old->forward_to_atomic(old); |
1203 forward_ptr = old->forward_to_atomic(old); |
1217 new_obj = old; |
1204 new_obj = old; |
1218 |
1205 |
1219 if (forward_ptr != NULL) { |
1206 if (forward_ptr != NULL) { |