Mon, 26 Jan 2009 12:47:21 -0800
6786503: Overflow list performance can be improved
Summary: Avoid overflow list walk in CMS & ParNew when it is unnecessary. Fix a couple of correctness issues, including a C-heap leak, in ParNew at the intersection of promotion failure, work queue overflow and object array chunking. Add stress testing option and related assertion checking.
Reviewed-by: jmasa
duke@435 | 1 | /* |
xdono@631 | 2 | * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | # include "incls/_precompiled.incl" |
duke@435 | 26 | # include "incls/_tenuredGeneration.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | TenuredGeneration::TenuredGeneration(ReservedSpace rs, |
duke@435 | 29 | size_t initial_byte_size, int level, |
duke@435 | 30 | GenRemSet* remset) : |
duke@435 | 31 | OneContigSpaceCardGeneration(rs, initial_byte_size, |
duke@435 | 32 | MinHeapDeltaBytes, level, remset, NULL) |
duke@435 | 33 | { |
duke@435 | 34 | HeapWord* bottom = (HeapWord*) _virtual_space.low(); |
duke@435 | 35 | HeapWord* end = (HeapWord*) _virtual_space.high(); |
duke@435 | 36 | _the_space = new TenuredSpace(_bts, MemRegion(bottom, end)); |
duke@435 | 37 | _the_space->reset_saved_mark(); |
duke@435 | 38 | _shrink_factor = 0; |
duke@435 | 39 | _capacity_at_prologue = 0; |
duke@435 | 40 | |
duke@435 | 41 | _gc_stats = new GCStats(); |
duke@435 | 42 | |
duke@435 | 43 | // initialize performance counters |
duke@435 | 44 | |
duke@435 | 45 | const char* gen_name = "old"; |
duke@435 | 46 | |
duke@435 | 47 | // Generation Counters -- generation 1, 1 subspace |
duke@435 | 48 | _gen_counters = new GenerationCounters(gen_name, 1, 1, &_virtual_space); |
duke@435 | 49 | |
duke@435 | 50 | _gc_counters = new CollectorCounters("MSC", 1); |
duke@435 | 51 | |
duke@435 | 52 | _space_counters = new CSpaceCounters(gen_name, 0, |
duke@435 | 53 | _virtual_space.reserved_size(), |
duke@435 | 54 | _the_space, _gen_counters); |
duke@435 | 55 | #ifndef SERIALGC |
duke@435 | 56 | if (UseParNewGC && ParallelGCThreads > 0) { |
duke@435 | 57 | typedef ParGCAllocBufferWithBOT* ParGCAllocBufferWithBOTPtr; |
duke@435 | 58 | _alloc_buffers = NEW_C_HEAP_ARRAY(ParGCAllocBufferWithBOTPtr, |
duke@435 | 59 | ParallelGCThreads); |
duke@435 | 60 | if (_alloc_buffers == NULL) |
duke@435 | 61 | vm_exit_during_initialization("Could not allocate alloc_buffers"); |
duke@435 | 62 | for (uint i = 0; i < ParallelGCThreads; i++) { |
duke@435 | 63 | _alloc_buffers[i] = |
duke@435 | 64 | new ParGCAllocBufferWithBOT(OldPLABSize, _bts); |
duke@435 | 65 | if (_alloc_buffers[i] == NULL) |
duke@435 | 66 | vm_exit_during_initialization("Could not allocate alloc_buffers"); |
duke@435 | 67 | } |
duke@435 | 68 | } else { |
duke@435 | 69 | _alloc_buffers = NULL; |
duke@435 | 70 | } |
duke@435 | 71 | #endif // SERIALGC |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | |
duke@435 | 75 | const char* TenuredGeneration::name() const { |
duke@435 | 76 | return "tenured generation"; |
duke@435 | 77 | } |
duke@435 | 78 | |
duke@435 | 79 | void TenuredGeneration::compute_new_size() { |
duke@435 | 80 | assert(_shrink_factor <= 100, "invalid shrink factor"); |
duke@435 | 81 | size_t current_shrink_factor = _shrink_factor; |
duke@435 | 82 | _shrink_factor = 0; |
duke@435 | 83 | |
duke@435 | 84 | // We don't have floating point command-line arguments |
duke@435 | 85 | // Note: argument processing ensures that MinHeapFreeRatio < 100. |
duke@435 | 86 | const double minimum_free_percentage = MinHeapFreeRatio / 100.0; |
duke@435 | 87 | const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
duke@435 | 88 | |
duke@435 | 89 | // Compute some numbers about the state of the heap. |
duke@435 | 90 | const size_t used_after_gc = used(); |
duke@435 | 91 | const size_t capacity_after_gc = capacity(); |
duke@435 | 92 | |
duke@435 | 93 | const double min_tmp = used_after_gc / maximum_used_percentage; |
duke@435 | 94 | size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx)); |
duke@435 | 95 | // Don't shrink less than the initial generation size |
duke@435 | 96 | minimum_desired_capacity = MAX2(minimum_desired_capacity, |
duke@435 | 97 | spec()->init_size()); |
duke@435 | 98 | assert(used_after_gc <= minimum_desired_capacity, "sanity check"); |
duke@435 | 99 | |
duke@435 | 100 | if (PrintGC && Verbose) { |
duke@435 | 101 | const size_t free_after_gc = free(); |
duke@435 | 102 | const double free_percentage = ((double)free_after_gc) / capacity_after_gc; |
duke@435 | 103 | gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: "); |
duke@435 | 104 | gclog_or_tty->print_cr(" " |
duke@435 | 105 | " minimum_free_percentage: %6.2f" |
duke@435 | 106 | " maximum_used_percentage: %6.2f", |
duke@435 | 107 | minimum_free_percentage, |
duke@435 | 108 | maximum_used_percentage); |
duke@435 | 109 | gclog_or_tty->print_cr(" " |
duke@435 | 110 | " free_after_gc : %6.1fK" |
duke@435 | 111 | " used_after_gc : %6.1fK" |
duke@435 | 112 | " capacity_after_gc : %6.1fK", |
duke@435 | 113 | free_after_gc / (double) K, |
duke@435 | 114 | used_after_gc / (double) K, |
duke@435 | 115 | capacity_after_gc / (double) K); |
duke@435 | 116 | gclog_or_tty->print_cr(" " |
duke@435 | 117 | " free_percentage: %6.2f", |
duke@435 | 118 | free_percentage); |
duke@435 | 119 | } |
duke@435 | 120 | |
duke@435 | 121 | if (capacity_after_gc < minimum_desired_capacity) { |
duke@435 | 122 | // If we have less free space than we want then expand |
duke@435 | 123 | size_t expand_bytes = minimum_desired_capacity - capacity_after_gc; |
duke@435 | 124 | // Don't expand unless it's significant |
duke@435 | 125 | if (expand_bytes >= _min_heap_delta_bytes) { |
duke@435 | 126 | expand(expand_bytes, 0); // safe if expansion fails |
duke@435 | 127 | } |
duke@435 | 128 | if (PrintGC && Verbose) { |
duke@435 | 129 | gclog_or_tty->print_cr(" expanding:" |
duke@435 | 130 | " minimum_desired_capacity: %6.1fK" |
duke@435 | 131 | " expand_bytes: %6.1fK" |
duke@435 | 132 | " _min_heap_delta_bytes: %6.1fK", |
duke@435 | 133 | minimum_desired_capacity / (double) K, |
duke@435 | 134 | expand_bytes / (double) K, |
duke@435 | 135 | _min_heap_delta_bytes / (double) K); |
duke@435 | 136 | } |
duke@435 | 137 | return; |
duke@435 | 138 | } |
duke@435 | 139 | |
duke@435 | 140 | // No expansion, now see if we want to shrink |
duke@435 | 141 | size_t shrink_bytes = 0; |
duke@435 | 142 | // We would never want to shrink more than this |
duke@435 | 143 | size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity; |
duke@435 | 144 | |
duke@435 | 145 | if (MaxHeapFreeRatio < 100) { |
duke@435 | 146 | const double maximum_free_percentage = MaxHeapFreeRatio / 100.0; |
duke@435 | 147 | const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
duke@435 | 148 | const double max_tmp = used_after_gc / minimum_used_percentage; |
duke@435 | 149 | size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); |
duke@435 | 150 | maximum_desired_capacity = MAX2(maximum_desired_capacity, |
duke@435 | 151 | spec()->init_size()); |
duke@435 | 152 | if (PrintGC && Verbose) { |
duke@435 | 153 | gclog_or_tty->print_cr(" " |
duke@435 | 154 | " maximum_free_percentage: %6.2f" |
duke@435 | 155 | " minimum_used_percentage: %6.2f", |
duke@435 | 156 | maximum_free_percentage, |
duke@435 | 157 | minimum_used_percentage); |
duke@435 | 158 | gclog_or_tty->print_cr(" " |
duke@435 | 159 | " _capacity_at_prologue: %6.1fK" |
duke@435 | 160 | " minimum_desired_capacity: %6.1fK" |
duke@435 | 161 | " maximum_desired_capacity: %6.1fK", |
duke@435 | 162 | _capacity_at_prologue / (double) K, |
duke@435 | 163 | minimum_desired_capacity / (double) K, |
duke@435 | 164 | maximum_desired_capacity / (double) K); |
duke@435 | 165 | } |
duke@435 | 166 | assert(minimum_desired_capacity <= maximum_desired_capacity, |
duke@435 | 167 | "sanity check"); |
duke@435 | 168 | |
duke@435 | 169 | if (capacity_after_gc > maximum_desired_capacity) { |
duke@435 | 170 | // Capacity too large, compute shrinking size |
duke@435 | 171 | shrink_bytes = capacity_after_gc - maximum_desired_capacity; |
duke@435 | 172 | // We don't want shrink all the way back to initSize if people call |
duke@435 | 173 | // System.gc(), because some programs do that between "phases" and then |
duke@435 | 174 | // we'd just have to grow the heap up again for the next phase. So we |
duke@435 | 175 | // damp the shrinking: 0% on the first call, 10% on the second call, 40% |
duke@435 | 176 | // on the third call, and 100% by the fourth call. But if we recompute |
duke@435 | 177 | // size without shrinking, it goes back to 0%. |
duke@435 | 178 | shrink_bytes = shrink_bytes / 100 * current_shrink_factor; |
duke@435 | 179 | assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size"); |
duke@435 | 180 | if (current_shrink_factor == 0) { |
duke@435 | 181 | _shrink_factor = 10; |
duke@435 | 182 | } else { |
duke@435 | 183 | _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100); |
duke@435 | 184 | } |
duke@435 | 185 | if (PrintGC && Verbose) { |
duke@435 | 186 | gclog_or_tty->print_cr(" " |
duke@435 | 187 | " shrinking:" |
duke@435 | 188 | " initSize: %.1fK" |
duke@435 | 189 | " maximum_desired_capacity: %.1fK", |
duke@435 | 190 | spec()->init_size() / (double) K, |
duke@435 | 191 | maximum_desired_capacity / (double) K); |
duke@435 | 192 | gclog_or_tty->print_cr(" " |
duke@435 | 193 | " shrink_bytes: %.1fK" |
duke@435 | 194 | " current_shrink_factor: %d" |
duke@435 | 195 | " new shrink factor: %d" |
duke@435 | 196 | " _min_heap_delta_bytes: %.1fK", |
duke@435 | 197 | shrink_bytes / (double) K, |
duke@435 | 198 | current_shrink_factor, |
duke@435 | 199 | _shrink_factor, |
duke@435 | 200 | _min_heap_delta_bytes / (double) K); |
duke@435 | 201 | } |
duke@435 | 202 | } |
duke@435 | 203 | } |
duke@435 | 204 | |
duke@435 | 205 | if (capacity_after_gc > _capacity_at_prologue) { |
duke@435 | 206 | // We might have expanded for promotions, in which case we might want to |
duke@435 | 207 | // take back that expansion if there's room after GC. That keeps us from |
duke@435 | 208 | // stretching the heap with promotions when there's plenty of room. |
duke@435 | 209 | size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue; |
duke@435 | 210 | expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes); |
duke@435 | 211 | // We have two shrinking computations, take the largest |
duke@435 | 212 | shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion); |
duke@435 | 213 | assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size"); |
duke@435 | 214 | if (PrintGC && Verbose) { |
duke@435 | 215 | gclog_or_tty->print_cr(" " |
duke@435 | 216 | " aggressive shrinking:" |
duke@435 | 217 | " _capacity_at_prologue: %.1fK" |
duke@435 | 218 | " capacity_after_gc: %.1fK" |
duke@435 | 219 | " expansion_for_promotion: %.1fK" |
duke@435 | 220 | " shrink_bytes: %.1fK", |
duke@435 | 221 | capacity_after_gc / (double) K, |
duke@435 | 222 | _capacity_at_prologue / (double) K, |
duke@435 | 223 | expansion_for_promotion / (double) K, |
duke@435 | 224 | shrink_bytes / (double) K); |
duke@435 | 225 | } |
duke@435 | 226 | } |
duke@435 | 227 | // Don't shrink unless it's significant |
duke@435 | 228 | if (shrink_bytes >= _min_heap_delta_bytes) { |
duke@435 | 229 | shrink(shrink_bytes); |
duke@435 | 230 | } |
duke@435 | 231 | assert(used() == used_after_gc && used_after_gc <= capacity(), |
duke@435 | 232 | "sanity check"); |
duke@435 | 233 | } |
duke@435 | 234 | |
duke@435 | 235 | void TenuredGeneration::gc_prologue(bool full) { |
duke@435 | 236 | _capacity_at_prologue = capacity(); |
duke@435 | 237 | _used_at_prologue = used(); |
duke@435 | 238 | if (VerifyBeforeGC) { |
duke@435 | 239 | verify_alloc_buffers_clean(); |
duke@435 | 240 | } |
duke@435 | 241 | } |
duke@435 | 242 | |
duke@435 | 243 | void TenuredGeneration::gc_epilogue(bool full) { |
duke@435 | 244 | if (VerifyAfterGC) { |
duke@435 | 245 | verify_alloc_buffers_clean(); |
duke@435 | 246 | } |
duke@435 | 247 | OneContigSpaceCardGeneration::gc_epilogue(full); |
duke@435 | 248 | } |
duke@435 | 249 | |
duke@435 | 250 | |
duke@435 | 251 | bool TenuredGeneration::should_collect(bool full, |
duke@435 | 252 | size_t size, |
duke@435 | 253 | bool is_tlab) { |
duke@435 | 254 | // This should be one big conditional or (||), but I want to be able to tell |
duke@435 | 255 | // why it returns what it returns (without re-evaluating the conditionals |
duke@435 | 256 | // in case they aren't idempotent), so I'm doing it this way. |
duke@435 | 257 | // DeMorgan says it's okay. |
duke@435 | 258 | bool result = false; |
duke@435 | 259 | if (!result && full) { |
duke@435 | 260 | result = true; |
duke@435 | 261 | if (PrintGC && Verbose) { |
duke@435 | 262 | gclog_or_tty->print_cr("TenuredGeneration::should_collect: because" |
duke@435 | 263 | " full"); |
duke@435 | 264 | } |
duke@435 | 265 | } |
duke@435 | 266 | if (!result && should_allocate(size, is_tlab)) { |
duke@435 | 267 | result = true; |
duke@435 | 268 | if (PrintGC && Verbose) { |
duke@435 | 269 | gclog_or_tty->print_cr("TenuredGeneration::should_collect: because" |
duke@435 | 270 | " should_allocate(" SIZE_FORMAT ")", |
duke@435 | 271 | size); |
duke@435 | 272 | } |
duke@435 | 273 | } |
duke@435 | 274 | // If we don't have very much free space. |
duke@435 | 275 | // XXX: 10000 should be a percentage of the capacity!!! |
duke@435 | 276 | if (!result && free() < 10000) { |
duke@435 | 277 | result = true; |
duke@435 | 278 | if (PrintGC && Verbose) { |
duke@435 | 279 | gclog_or_tty->print_cr("TenuredGeneration::should_collect: because" |
duke@435 | 280 | " free(): " SIZE_FORMAT, |
duke@435 | 281 | free()); |
duke@435 | 282 | } |
duke@435 | 283 | } |
duke@435 | 284 | // If we had to expand to accomodate promotions from younger generations |
duke@435 | 285 | if (!result && _capacity_at_prologue < capacity()) { |
duke@435 | 286 | result = true; |
duke@435 | 287 | if (PrintGC && Verbose) { |
duke@435 | 288 | gclog_or_tty->print_cr("TenuredGeneration::should_collect: because" |
duke@435 | 289 | "_capacity_at_prologue: " SIZE_FORMAT " < capacity(): " SIZE_FORMAT, |
duke@435 | 290 | _capacity_at_prologue, capacity()); |
duke@435 | 291 | } |
duke@435 | 292 | } |
duke@435 | 293 | return result; |
duke@435 | 294 | } |
duke@435 | 295 | |
duke@435 | 296 | void TenuredGeneration::collect(bool full, |
duke@435 | 297 | bool clear_all_soft_refs, |
duke@435 | 298 | size_t size, |
duke@435 | 299 | bool is_tlab) { |
duke@435 | 300 | retire_alloc_buffers_before_full_gc(); |
duke@435 | 301 | OneContigSpaceCardGeneration::collect(full, clear_all_soft_refs, |
duke@435 | 302 | size, is_tlab); |
duke@435 | 303 | } |
duke@435 | 304 | |
duke@435 | 305 | void TenuredGeneration::update_gc_stats(int current_level, |
duke@435 | 306 | bool full) { |
duke@435 | 307 | // If the next lower level(s) has been collected, gather any statistics |
duke@435 | 308 | // that are of interest at this point. |
duke@435 | 309 | if (!full && (current_level + 1) == level()) { |
duke@435 | 310 | // Calculate size of data promoted from the younger generations |
duke@435 | 311 | // before doing the collection. |
duke@435 | 312 | size_t used_before_gc = used(); |
duke@435 | 313 | |
duke@435 | 314 | // If the younger gen collections were skipped, then the |
duke@435 | 315 | // number of promoted bytes will be 0 and adding it to the |
duke@435 | 316 | // average will incorrectly lessen the average. It is, however, |
duke@435 | 317 | // also possible that no promotion was needed. |
duke@435 | 318 | if (used_before_gc >= _used_at_prologue) { |
duke@435 | 319 | size_t promoted_in_bytes = used_before_gc - _used_at_prologue; |
duke@435 | 320 | gc_stats()->avg_promoted()->sample(promoted_in_bytes); |
duke@435 | 321 | } |
duke@435 | 322 | } |
duke@435 | 323 | } |
duke@435 | 324 | |
duke@435 | 325 | void TenuredGeneration::update_counters() { |
duke@435 | 326 | if (UsePerfData) { |
duke@435 | 327 | _space_counters->update_all(); |
duke@435 | 328 | _gen_counters->update_all(); |
duke@435 | 329 | } |
duke@435 | 330 | } |
duke@435 | 331 | |
duke@435 | 332 | |
duke@435 | 333 | #ifndef SERIALGC |
duke@435 | 334 | oop TenuredGeneration::par_promote(int thread_num, |
duke@435 | 335 | oop old, markOop m, size_t word_sz) { |
duke@435 | 336 | |
duke@435 | 337 | ParGCAllocBufferWithBOT* buf = _alloc_buffers[thread_num]; |
duke@435 | 338 | HeapWord* obj_ptr = buf->allocate(word_sz); |
duke@435 | 339 | bool is_lab = true; |
duke@435 | 340 | if (obj_ptr == NULL) { |
duke@435 | 341 | #ifndef PRODUCT |
duke@435 | 342 | if (Universe::heap()->promotion_should_fail()) { |
duke@435 | 343 | return NULL; |
duke@435 | 344 | } |
duke@435 | 345 | #endif // #ifndef PRODUCT |
duke@435 | 346 | |
duke@435 | 347 | // Slow path: |
duke@435 | 348 | if (word_sz * 100 < ParallelGCBufferWastePct * buf->word_sz()) { |
duke@435 | 349 | // Is small enough; abandon this buffer and start a new one. |
duke@435 | 350 | size_t buf_size = buf->word_sz(); |
duke@435 | 351 | HeapWord* buf_space = |
duke@435 | 352 | TenuredGeneration::par_allocate(buf_size, false); |
duke@435 | 353 | if (buf_space == NULL) { |
duke@435 | 354 | buf_space = expand_and_allocate(buf_size, false, true /* parallel*/); |
duke@435 | 355 | } |
duke@435 | 356 | if (buf_space != NULL) { |
duke@435 | 357 | buf->retire(false, false); |
duke@435 | 358 | buf->set_buf(buf_space); |
duke@435 | 359 | obj_ptr = buf->allocate(word_sz); |
duke@435 | 360 | assert(obj_ptr != NULL, "Buffer was definitely big enough..."); |
duke@435 | 361 | } |
duke@435 | 362 | }; |
duke@435 | 363 | // Otherwise, buffer allocation failed; try allocating object |
duke@435 | 364 | // individually. |
duke@435 | 365 | if (obj_ptr == NULL) { |
duke@435 | 366 | obj_ptr = TenuredGeneration::par_allocate(word_sz, false); |
duke@435 | 367 | if (obj_ptr == NULL) { |
duke@435 | 368 | obj_ptr = expand_and_allocate(word_sz, false, true /* parallel */); |
duke@435 | 369 | } |
duke@435 | 370 | } |
duke@435 | 371 | if (obj_ptr == NULL) return NULL; |
duke@435 | 372 | } |
duke@435 | 373 | assert(obj_ptr != NULL, "program logic"); |
duke@435 | 374 | Copy::aligned_disjoint_words((HeapWord*)old, obj_ptr, word_sz); |
duke@435 | 375 | oop obj = oop(obj_ptr); |
duke@435 | 376 | // Restore the mark word copied above. |
duke@435 | 377 | obj->set_mark(m); |
duke@435 | 378 | return obj; |
duke@435 | 379 | } |
duke@435 | 380 | |
duke@435 | 381 | void TenuredGeneration::par_promote_alloc_undo(int thread_num, |
duke@435 | 382 | HeapWord* obj, |
duke@435 | 383 | size_t word_sz) { |
duke@435 | 384 | ParGCAllocBufferWithBOT* buf = _alloc_buffers[thread_num]; |
duke@435 | 385 | if (buf->contains(obj)) { |
duke@435 | 386 | guarantee(buf->contains(obj + word_sz - 1), |
duke@435 | 387 | "should contain whole object"); |
duke@435 | 388 | buf->undo_allocation(obj, word_sz); |
duke@435 | 389 | } else { |
jcoomes@916 | 390 | CollectedHeap::fill_with_object(obj, word_sz); |
duke@435 | 391 | } |
duke@435 | 392 | } |
duke@435 | 393 | |
duke@435 | 394 | void TenuredGeneration::par_promote_alloc_done(int thread_num) { |
duke@435 | 395 | ParGCAllocBufferWithBOT* buf = _alloc_buffers[thread_num]; |
duke@435 | 396 | buf->retire(true, ParallelGCRetainPLAB); |
duke@435 | 397 | } |
duke@435 | 398 | |
duke@435 | 399 | void TenuredGeneration::retire_alloc_buffers_before_full_gc() { |
duke@435 | 400 | if (UseParNewGC) { |
duke@435 | 401 | for (uint i = 0; i < ParallelGCThreads; i++) { |
duke@435 | 402 | _alloc_buffers[i]->retire(true /*end_of_gc*/, false /*retain*/); |
duke@435 | 403 | } |
duke@435 | 404 | } |
duke@435 | 405 | } |
duke@435 | 406 | |
duke@435 | 407 | // Verify that any retained parallel allocation buffers do not |
duke@435 | 408 | // intersect with dirty cards. |
duke@435 | 409 | void TenuredGeneration::verify_alloc_buffers_clean() { |
duke@435 | 410 | if (UseParNewGC) { |
duke@435 | 411 | for (uint i = 0; i < ParallelGCThreads; i++) { |
jmasa@441 | 412 | _rs->verify_aligned_region_empty(_alloc_buffers[i]->range()); |
duke@435 | 413 | } |
duke@435 | 414 | } |
duke@435 | 415 | } |
jmasa@441 | 416 | |
duke@435 | 417 | #else // SERIALGC |
duke@435 | 418 | void TenuredGeneration::retire_alloc_buffers_before_full_gc() {} |
duke@435 | 419 | void TenuredGeneration::verify_alloc_buffers_clean() {} |
duke@435 | 420 | #endif // SERIALGC |
duke@435 | 421 | |
duke@435 | 422 | bool TenuredGeneration::promotion_attempt_is_safe( |
duke@435 | 423 | size_t max_promotion_in_bytes, |
duke@435 | 424 | bool younger_handles_promotion_failure) const { |
duke@435 | 425 | |
duke@435 | 426 | bool result = max_contiguous_available() >= max_promotion_in_bytes; |
duke@435 | 427 | |
duke@435 | 428 | if (younger_handles_promotion_failure && !result) { |
duke@435 | 429 | result = max_contiguous_available() >= |
duke@435 | 430 | (size_t) gc_stats()->avg_promoted()->padded_average(); |
duke@435 | 431 | if (PrintGC && Verbose && result) { |
duke@435 | 432 | gclog_or_tty->print_cr("TenuredGeneration::promotion_attempt_is_safe" |
duke@435 | 433 | " contiguous_available: " SIZE_FORMAT |
duke@435 | 434 | " avg_promoted: " SIZE_FORMAT, |
duke@435 | 435 | max_contiguous_available(), |
duke@435 | 436 | gc_stats()->avg_promoted()->padded_average()); |
duke@435 | 437 | } |
duke@435 | 438 | } else { |
duke@435 | 439 | if (PrintGC && Verbose) { |
duke@435 | 440 | gclog_or_tty->print_cr("TenuredGeneration::promotion_attempt_is_safe" |
duke@435 | 441 | " contiguous_available: " SIZE_FORMAT |
duke@435 | 442 | " promotion_in_bytes: " SIZE_FORMAT, |
duke@435 | 443 | max_contiguous_available(), max_promotion_in_bytes); |
duke@435 | 444 | } |
duke@435 | 445 | } |
duke@435 | 446 | return result; |
duke@435 | 447 | } |