108 used_in_bytes() + (size_t) policy->avg_promoted()->padded_average(); 109 const size_t working_aligned = align_size_up(working_size, gen_alignment); 110 const size_t working_or_min = MAX2(working_aligned, min_gen_size()); 111 if (working_or_min > reserved().byte_size()) { 112 // If the used or minimum gen size (aligned up) is greater 113 // than the total reserved size, then the space available 114 // for contraction should (after proper alignment) be 0 115 return 0; 116 } 117 const size_t max_contraction = 118 reserved().byte_size() - working_or_min; 119 120 // Use the "increment" fraction instead of the "decrement" fraction 121 // to allow the other gen to expand more aggressively. The 122 // "decrement" fraction is conservative because its intent is to 123 // only reduce the footprint. 124 125 size_t result = policy->promo_increment_aligned_down(max_contraction); 126 // Also adjust for inter-generational alignment 127 size_t result_aligned = align_size_down(result, gen_alignment); 128 if (PrintAdaptiveSizePolicy && Verbose) { 129 gclog_or_tty->print_cr("\nASPSOldGen::available_for_contraction:" 130 " " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, result_aligned/K, result_aligned); 131 gclog_or_tty->print_cr(" reserved().byte_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 132 reserved().byte_size()/K, reserved().byte_size()); 133 size_t working_promoted = (size_t) policy->avg_promoted()->padded_average(); 134 gclog_or_tty->print_cr(" padded promoted " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 135 working_promoted/K, working_promoted); 136 gclog_or_tty->print_cr(" used " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 137 used_in_bytes()/K, used_in_bytes()); 138 gclog_or_tty->print_cr(" min_gen_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 139 min_gen_size()/K, min_gen_size()); 140 gclog_or_tty->print_cr(" max_contraction " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 141 max_contraction/K, max_contraction); 142 gclog_or_tty->print_cr(" without alignment " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, 143 policy->promo_increment(max_contraction)/K, 144 policy->promo_increment(max_contraction)); 145 gclog_or_tty->print_cr(" alignment " SIZE_FORMAT_HEX, gen_alignment); 146 } 147 assert(result_aligned <= max_contraction, "arithmetic is wrong"); 148 return result_aligned; 149 } | 108 used_in_bytes() + (size_t) policy->avg_promoted()->padded_average(); 109 const size_t working_aligned = align_size_up(working_size, gen_alignment); 110 const size_t working_or_min = MAX2(working_aligned, min_gen_size()); 111 if (working_or_min > reserved().byte_size()) { 112 // If the used or minimum gen size (aligned up) is greater 113 // than the total reserved size, then the space available 114 // for contraction should (after proper alignment) be 0 115 return 0; 116 } 117 const size_t max_contraction = 118 reserved().byte_size() - working_or_min; 119 120 // Use the "increment" fraction instead of the "decrement" fraction 121 // to allow the other gen to expand more aggressively. The 122 // "decrement" fraction is conservative because its intent is to 123 // only reduce the footprint. 124 125 size_t result = policy->promo_increment_aligned_down(max_contraction); 126 // Also adjust for inter-generational alignment 127 size_t result_aligned = align_size_down(result, gen_alignment); 128 129 LogHandle(gc, ergo) log; 130 if (log.is_trace()) { 131 size_t working_promoted = (size_t) policy->avg_promoted()->padded_average(); 132 size_t promo_increment = policy->promo_increment(max_contraction); 133 log.trace("ASPSOldGen::available_for_contraction: " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, result_aligned/K, result_aligned); 134 log.trace(" reserved().byte_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, reserved().byte_size()/K, reserved().byte_size()); 135 log.trace(" padded promoted " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, working_promoted/K, working_promoted); 136 log.trace(" used " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, used_in_bytes()/K, used_in_bytes()); 137 log.trace(" min_gen_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, min_gen_size()/K, min_gen_size()); 138 log.trace(" max_contraction " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, max_contraction/K, max_contraction); 139 log.trace(" without alignment " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, promo_increment/K, promo_increment); 140 log.trace(" alignment " SIZE_FORMAT_HEX, gen_alignment); 141 } 142 143 assert(result_aligned <= max_contraction, "arithmetic is wrong"); 144 return result_aligned; 145 } |