Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp @ 356:1ee8caae33af
Merge
author | tonyp |
---|---|
date | Thu, 21 Aug 2008 23:36:31 -0400 |
parents | 850fdf70db2b |
children | cff162798819 |
comparison
equal
deleted
inserted
replaced
355:0edda524b58c | 356:1ee8caae33af |
---|---|
1 /* | 1 /* |
2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
168 assert(desired_size <= gen_size_limit(), "just checking"); | 168 assert(desired_size <= gen_size_limit(), "just checking"); |
169 | 169 |
170 if (desired_size > orig_size) { | 170 if (desired_size > orig_size) { |
171 // Grow the generation | 171 // Grow the generation |
172 size_t change = desired_size - orig_size; | 172 size_t change = desired_size - orig_size; |
173 HeapWord* prev_low = (HeapWord*) virtual_space()->low(); | |
173 if (!virtual_space()->expand_by(change)) { | 174 if (!virtual_space()->expand_by(change)) { |
174 return false; | 175 return false; |
176 } | |
177 if (ZapUnusedHeapArea) { | |
178 // Mangle newly committed space immediately because it | |
179 // can be done here more simply that after the new | |
180 // spaces have been computed. | |
181 HeapWord* new_low = (HeapWord*) virtual_space()->low(); | |
182 assert(new_low < prev_low, "Did not grow"); | |
183 | |
184 MemRegion mangle_region(new_low, prev_low); | |
185 SpaceMangler::mangle_region(mangle_region); | |
175 } | 186 } |
176 size_changed = true; | 187 size_changed = true; |
177 } else if (desired_size < orig_size) { | 188 } else if (desired_size < orig_size) { |
178 size_t desired_change = orig_size - desired_size; | 189 size_t desired_change = orig_size - desired_size; |
179 | 190 |
213 // Similar to PSYoungGen::resize_spaces() but | 224 // Similar to PSYoungGen::resize_spaces() but |
214 // eden always starts at the low end of the committed virtual space | 225 // eden always starts at the low end of the committed virtual space |
215 // current implementation does not allow holes between the spaces | 226 // current implementation does not allow holes between the spaces |
216 // _young_generation_boundary has to be reset because it changes. | 227 // _young_generation_boundary has to be reset because it changes. |
217 // so additional verification | 228 // so additional verification |
229 | |
218 void ASPSYoungGen::resize_spaces(size_t requested_eden_size, | 230 void ASPSYoungGen::resize_spaces(size_t requested_eden_size, |
219 size_t requested_survivor_size) { | 231 size_t requested_survivor_size) { |
232 assert(UseAdaptiveSizePolicy, "sanity check"); | |
220 assert(requested_eden_size > 0 && requested_survivor_size > 0, | 233 assert(requested_eden_size > 0 && requested_survivor_size > 0, |
221 "just checking"); | 234 "just checking"); |
222 | 235 |
223 space_invariants(); | 236 space_invariants(); |
224 | 237 |
274 | 287 |
275 assert(eden_start < from_start, "Cannot push into from_space"); | 288 assert(eden_start < from_start, "Cannot push into from_space"); |
276 | 289 |
277 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | 290 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
278 const size_t alignment = heap->intra_heap_alignment(); | 291 const size_t alignment = heap->intra_heap_alignment(); |
279 | 292 const bool maintain_minimum = |
293 (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size(); | |
294 | |
295 bool eden_from_to_order = from_start < to_start; | |
280 // Check whether from space is below to space | 296 // Check whether from space is below to space |
281 if (from_start < to_start) { | 297 if (eden_from_to_order) { |
282 // Eden, from, to | 298 // Eden, from, to |
299 | |
283 if (PrintAdaptiveSizePolicy && Verbose) { | 300 if (PrintAdaptiveSizePolicy && Verbose) { |
284 gclog_or_tty->print_cr(" Eden, from, to:"); | 301 gclog_or_tty->print_cr(" Eden, from, to:"); |
285 } | 302 } |
286 | 303 |
287 // Set eden | 304 // Set eden |
288 // Compute how big eden can be, then adjust end. | 305 // "requested_eden_size" is a goal for the size of eden |
289 // See comment in PSYoungGen::resize_spaces() on | 306 // and may not be attainable. "eden_size" below is |
290 // calculating eden_end. | 307 // calculated based on the location of from-space and |
291 const size_t eden_size = MIN2(requested_eden_size, | 308 // the goal for the size of eden. from-space is |
292 pointer_delta(from_start, | 309 // fixed in place because it contains live data. |
293 eden_start, | 310 // The calculation is done this way to avoid 32bit |
294 sizeof(char))); | 311 // overflow (i.e., eden_start + requested_eden_size |
312 // may too large for representation in 32bits). | |
313 size_t eden_size; | |
314 if (maintain_minimum) { | |
315 // Only make eden larger than the requested size if | |
316 // the minimum size of the generation has to be maintained. | |
317 // This could be done in general but policy at a higher | |
318 // level is determining a requested size for eden and that | |
319 // should be honored unless there is a fundamental reason. | |
320 eden_size = pointer_delta(from_start, | |
321 eden_start, | |
322 sizeof(char)); | |
323 } else { | |
324 eden_size = MIN2(requested_eden_size, | |
325 pointer_delta(from_start, eden_start, sizeof(char))); | |
326 } | |
327 | |
295 eden_end = eden_start + eden_size; | 328 eden_end = eden_start + eden_size; |
296 assert(eden_end >= eden_start, "addition overflowed") | 329 assert(eden_end >= eden_start, "addition overflowed") |
297 | 330 |
298 // To may resize into from space as long as it is clear of live data. | 331 // To may resize into from space as long as it is clear of live data. |
299 // From space must remain page aligned, though, so we need to do some | 332 // From space must remain page aligned, though, so we need to do some |
369 // 'to_start' will point beyond the young generation. In this case | 402 // 'to_start' will point beyond the young generation. In this case |
370 // 'to_start' should be adjusted. | 403 // 'to_start' should be adjusted. |
371 to_start = MAX2(to_start, eden_start + alignment); | 404 to_start = MAX2(to_start, eden_start + alignment); |
372 | 405 |
373 // Compute how big eden can be, then adjust end. | 406 // Compute how big eden can be, then adjust end. |
374 // See comment in PSYoungGen::resize_spaces() on | 407 // See comments above on calculating eden_end. |
375 // calculating eden_end. | 408 size_t eden_size; |
376 const size_t eden_size = MIN2(requested_eden_size, | 409 if (maintain_minimum) { |
377 pointer_delta(to_start, | 410 eden_size = pointer_delta(to_start, eden_start, sizeof(char)); |
378 eden_start, | 411 } else { |
379 sizeof(char))); | 412 eden_size = MIN2(requested_eden_size, |
413 pointer_delta(to_start, eden_start, sizeof(char))); | |
414 } | |
380 eden_end = eden_start + eden_size; | 415 eden_end = eden_start + eden_size; |
381 assert(eden_end >= eden_start, "addition overflowed") | 416 assert(eden_end >= eden_start, "addition overflowed") |
382 | 417 |
383 // Don't let eden shrink down to 0 or less. | 418 // Don't let eden shrink down to 0 or less. |
384 eden_end = MAX2(eden_end, eden_start + alignment); | 419 eden_end = MAX2(eden_end, eden_start + alignment); |
421 | 456 |
422 // For PrintAdaptiveSizePolicy block below | 457 // For PrintAdaptiveSizePolicy block below |
423 size_t old_from = from_space()->capacity_in_bytes(); | 458 size_t old_from = from_space()->capacity_in_bytes(); |
424 size_t old_to = to_space()->capacity_in_bytes(); | 459 size_t old_to = to_space()->capacity_in_bytes(); |
425 | 460 |
426 eden_space()->initialize(edenMR, true); | 461 if (ZapUnusedHeapArea) { |
427 to_space()->initialize(toMR , true); | 462 // NUMA is a special case because a numa space is not mangled |
428 from_space()->initialize(fromMR, false); // Note, not cleared! | 463 // in order to not prematurely bind its address to memory to |
464 // the wrong memory (i.e., don't want the GC thread to first | |
465 // touch the memory). The survivor spaces are not numa | |
466 // spaces and are mangled. | |
467 if (UseNUMA) { | |
468 if (eden_from_to_order) { | |
469 mangle_survivors(from_space(), fromMR, to_space(), toMR); | |
470 } else { | |
471 mangle_survivors(to_space(), toMR, from_space(), fromMR); | |
472 } | |
473 } | |
474 | |
475 // If not mangling the spaces, do some checking to verify that | |
476 // the spaces are already mangled. | |
477 // The spaces should be correctly mangled at this point so | |
478 // do some checking here. Note that they are not being mangled | |
479 // in the calls to initialize(). | |
480 // Must check mangling before the spaces are reshaped. Otherwise, | |
481 // the bottom or end of one space may have moved into an area | |
482 // covered by another space and a failure of the check may | |
483 // not correctly indicate which space is not properly mangled. | |
484 | |
485 HeapWord* limit = (HeapWord*) virtual_space()->high(); | |
486 eden_space()->check_mangled_unused_area(limit); | |
487 from_space()->check_mangled_unused_area(limit); | |
488 to_space()->check_mangled_unused_area(limit); | |
489 } | |
490 // When an existing space is being initialized, it is not | |
491 // mangled because the space has been previously mangled. | |
492 eden_space()->initialize(edenMR, | |
493 SpaceDecorator::Clear, | |
494 SpaceDecorator::DontMangle); | |
495 to_space()->initialize(toMR, | |
496 SpaceDecorator::Clear, | |
497 SpaceDecorator::DontMangle); | |
498 from_space()->initialize(fromMR, | |
499 SpaceDecorator::DontClear, | |
500 SpaceDecorator::DontMangle); | |
501 | |
429 PSScavenge::set_young_generation_boundary(eden_space()->bottom()); | 502 PSScavenge::set_young_generation_boundary(eden_space()->bottom()); |
430 | 503 |
431 assert(from_space()->top() == old_from_top, "from top changed!"); | 504 assert(from_space()->top() == old_from_top, "from top changed!"); |
432 | 505 |
433 if (PrintAdaptiveSizePolicy) { | 506 if (PrintAdaptiveSizePolicy) { |
444 to_space()->capacity_in_bytes()); | 517 to_space()->capacity_in_bytes()); |
445 gclog_or_tty->cr(); | 518 gclog_or_tty->cr(); |
446 } | 519 } |
447 space_invariants(); | 520 space_invariants(); |
448 } | 521 } |
449 | |
450 void ASPSYoungGen::reset_after_change() { | 522 void ASPSYoungGen::reset_after_change() { |
451 assert_locked_or_safepoint(Heap_lock); | 523 assert_locked_or_safepoint(Heap_lock); |
452 | 524 |
453 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), | 525 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), |
454 (HeapWord*)virtual_space()->high_boundary()); | 526 (HeapWord*)virtual_space()->high_boundary()); |
456 | 528 |
457 HeapWord* new_eden_bottom = (HeapWord*)virtual_space()->low(); | 529 HeapWord* new_eden_bottom = (HeapWord*)virtual_space()->low(); |
458 HeapWord* eden_bottom = eden_space()->bottom(); | 530 HeapWord* eden_bottom = eden_space()->bottom(); |
459 if (new_eden_bottom != eden_bottom) { | 531 if (new_eden_bottom != eden_bottom) { |
460 MemRegion eden_mr(new_eden_bottom, eden_space()->end()); | 532 MemRegion eden_mr(new_eden_bottom, eden_space()->end()); |
461 eden_space()->initialize(eden_mr, true); | 533 eden_space()->initialize(eden_mr, |
534 SpaceDecorator::Clear, | |
535 SpaceDecorator::Mangle); | |
462 PSScavenge::set_young_generation_boundary(eden_space()->bottom()); | 536 PSScavenge::set_young_generation_boundary(eden_space()->bottom()); |
463 } | 537 } |
464 MemRegion cmr((HeapWord*)virtual_space()->low(), | 538 MemRegion cmr((HeapWord*)virtual_space()->low(), |
465 (HeapWord*)virtual_space()->high()); | 539 (HeapWord*)virtual_space()->high()); |
466 Universe::heap()->barrier_set()->resize_covered_region(cmr); | 540 Universe::heap()->barrier_set()->resize_covered_region(cmr); |