160 |
160 |
161 if (desired_size > orig_size) { |
161 if (desired_size > orig_size) { |
162 // Grow the generation |
162 // Grow the generation |
163 size_t change = desired_size - orig_size; |
163 size_t change = desired_size - orig_size; |
164 assert(change % alignment == 0, "just checking"); |
164 assert(change % alignment == 0, "just checking"); |
165 if (!virtual_space()->expand_by(change)) { |
165 if (expand(change)) { |
166 return false; // Error if we fail to resize! |
166 return false; // Error if we fail to resize! |
167 } |
167 } |
168 |
|
169 size_changed = true; |
168 size_changed = true; |
170 } else if (desired_size < orig_size) { |
169 } else if (desired_size < orig_size) { |
171 size_t desired_change = orig_size - desired_size; |
170 size_t desired_change = orig_size - desired_size; |
172 assert(desired_change % alignment == 0, "just checking"); |
171 assert(desired_change % alignment == 0, "just checking"); |
173 |
172 |
220 } else { |
219 } else { |
221 assert(new_end >= to()->bottom(), "Shrink was too large"); |
220 assert(new_end >= to()->bottom(), "Shrink was too large"); |
222 // Was there a shrink of the survivor space? |
221 // Was there a shrink of the survivor space? |
223 if (new_end < to()->end()) { |
222 if (new_end < to()->end()) { |
224 MemRegion mr(to()->bottom(), new_end); |
223 MemRegion mr(to()->bottom(), new_end); |
225 to()->initialize(mr, false /* clear */); |
224 to()->initialize(mr, |
|
225 SpaceDecorator::DontClear, |
|
226 SpaceDecorator::DontMangle); |
226 } |
227 } |
227 } |
228 } |
228 } |
229 } |
229 void ASParNewGeneration::resize_spaces(size_t requested_eden_size, |
230 void ASParNewGeneration::resize_spaces(size_t requested_eden_size, |
230 size_t requested_survivor_size) { |
231 size_t requested_survivor_size) { |
320 } else { |
321 } else { |
321 eden_size = MIN2(requested_eden_size, |
322 eden_size = MIN2(requested_eden_size, |
322 pointer_delta(from_start, eden_start, sizeof(char))); |
323 pointer_delta(from_start, eden_start, sizeof(char))); |
323 } |
324 } |
324 |
325 |
325 // tty->print_cr("eden_size before: " SIZE_FORMAT, eden_size); |
|
326 eden_size = align_size_down(eden_size, alignment); |
326 eden_size = align_size_down(eden_size, alignment); |
327 // tty->print_cr("eden_size after: " SIZE_FORMAT, eden_size); |
|
328 eden_end = eden_start + eden_size; |
327 eden_end = eden_start + eden_size; |
329 assert(eden_end >= eden_start, "addition overflowed") |
328 assert(eden_end >= eden_start, "addition overflowed") |
330 |
329 |
331 // To may resize into from space as long as it is clear of live data. |
330 // To may resize into from space as long as it is clear of live data. |
332 // From space must remain page aligned, though, so we need to do some |
331 // From space must remain page aligned, though, so we need to do some |
499 |
498 |
500 // For PrintAdaptiveSizePolicy block below |
499 // For PrintAdaptiveSizePolicy block below |
501 size_t old_from = from()->capacity(); |
500 size_t old_from = from()->capacity(); |
502 size_t old_to = to()->capacity(); |
501 size_t old_to = to()->capacity(); |
503 |
502 |
|
503 // If not clearing the spaces, do some checking to verify that |
|
504 // the spaces are already mangled. |
|
505 |
|
506 // Must check mangling before the spaces are reshaped. Otherwise, |
|
507 // the bottom or end of one space may have moved into another |
|
508 // a failure of the check may not correctly indicate which space |
|
509 // is not properly mangled. |
|
510 if (ZapUnusedHeapArea) { |
|
511 HeapWord* limit = (HeapWord*) virtual_space()->high(); |
|
512 eden()->check_mangled_unused_area(limit); |
|
513 from()->check_mangled_unused_area(limit); |
|
514 to()->check_mangled_unused_area(limit); |
|
515 } |
|
516 |
504 // The call to initialize NULL's the next compaction space |
517 // The call to initialize NULL's the next compaction space |
505 eden()->initialize(edenMR, true); |
518 eden()->initialize(edenMR, |
|
519 SpaceDecorator::Clear, |
|
520 SpaceDecorator::DontMangle); |
506 eden()->set_next_compaction_space(from()); |
521 eden()->set_next_compaction_space(from()); |
507 to()->initialize(toMR , true); |
522 to()->initialize(toMR , |
508 from()->initialize(fromMR, false); // Note, not cleared! |
523 SpaceDecorator::Clear, |
|
524 SpaceDecorator::DontMangle); |
|
525 from()->initialize(fromMR, |
|
526 SpaceDecorator::DontClear, |
|
527 SpaceDecorator::DontMangle); |
509 |
528 |
510 assert(from()->top() == old_from_top, "from top changed!"); |
529 assert(from()->top() == old_from_top, "from top changed!"); |
511 |
530 |
512 if (PrintAdaptiveSizePolicy) { |
531 if (PrintAdaptiveSizePolicy) { |
513 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
532 GenCollectedHeap* gch = GenCollectedHeap::heap(); |