Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @ 481:7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
Reviewed-by: apetrusenko, ysr
author | jcoomes |
---|---|
date | Thu, 11 Dec 2008 12:05:08 -0800 |
parents | 27a80744a83b |
children | 05c6d52fa7a9 |
comparison
equal
deleted
inserted
replaced
480:d249b360e026 | 481:7d7a7c599c17 |
---|---|
387 // Figure out how much to take from eden. Include the average amount promoted | 387 // Figure out how much to take from eden. Include the average amount promoted |
388 // in the total; otherwise the next young gen GC will simply bail out to a | 388 // in the total; otherwise the next young gen GC will simply bail out to a |
389 // full GC. | 389 // full GC. |
390 const size_t alignment = old_gen->virtual_space()->alignment(); | 390 const size_t alignment = old_gen->virtual_space()->alignment(); |
391 const size_t eden_used = eden_space->used_in_bytes(); | 391 const size_t eden_used = eden_space->used_in_bytes(); |
392 const size_t promoted = (size_t)(size_policy->avg_promoted()->padded_average()); | 392 const size_t promoted = (size_t)size_policy->avg_promoted()->padded_average(); |
393 const size_t absorb_size = align_size_up(eden_used + promoted, alignment); | 393 const size_t absorb_size = align_size_up(eden_used + promoted, alignment); |
394 const size_t eden_capacity = eden_space->capacity_in_bytes(); | 394 const size_t eden_capacity = eden_space->capacity_in_bytes(); |
395 | 395 |
396 if (absorb_size >= eden_capacity) { | 396 if (absorb_size >= eden_capacity) { |
397 return false; // Must leave some space in eden. | 397 return false; // Must leave some space in eden. |
414 young_gen->capacity_in_bytes() / K, new_young_size / K); | 414 young_gen->capacity_in_bytes() / K, new_young_size / K); |
415 } | 415 } |
416 | 416 |
417 // Fill the unused part of the old gen. | 417 // Fill the unused part of the old gen. |
418 MutableSpace* const old_space = old_gen->object_space(); | 418 MutableSpace* const old_space = old_gen->object_space(); |
419 MemRegion old_gen_unused(old_space->top(), old_space->end()); | 419 HeapWord* const unused_start = old_space->top(); |
420 | 420 size_t const unused_words = pointer_delta(old_space->end(), unused_start); |
421 // If the unused part of the old gen cannot be filled, skip | 421 |
422 // absorbing eden. | 422 if (unused_words > 0) { |
423 if (old_gen_unused.word_size() < SharedHeap::min_fill_size()) { | 423 if (unused_words < CollectedHeap::min_fill_size()) { |
424 return false; | 424 return false; // If the old gen cannot be filled, must give up. |
425 } | 425 } |
426 | 426 CollectedHeap::fill_with_objects(unused_start, unused_words); |
427 if (!old_gen_unused.is_empty()) { | |
428 SharedHeap::fill_region_with_object(old_gen_unused); | |
429 } | 427 } |
430 | 428 |
431 // Take the live data from eden and set both top and end in the old gen to | 429 // Take the live data from eden and set both top and end in the old gen to |
432 // eden top. (Need to set end because reset_after_change() mangles the region | 430 // eden top. (Need to set end because reset_after_change() mangles the region |
433 // from end to virtual_space->high() in debug builds). | 431 // from end to virtual_space->high() in debug builds). |
439 old_space->set_end(new_top); | 437 old_space->set_end(new_top); |
440 old_gen->reset_after_change(); | 438 old_gen->reset_after_change(); |
441 | 439 |
442 // Update the object start array for the filler object and the data from eden. | 440 // Update the object start array for the filler object and the data from eden. |
443 ObjectStartArray* const start_array = old_gen->start_array(); | 441 ObjectStartArray* const start_array = old_gen->start_array(); |
444 HeapWord* const start = old_gen_unused.start(); | 442 for (HeapWord* p = unused_start; p < new_top; p += oop(p)->size()) { |
445 for (HeapWord* addr = start; addr < new_top; addr += oop(addr)->size()) { | 443 start_array->allocate_block(p); |
446 start_array->allocate_block(addr); | |
447 } | 444 } |
448 | 445 |
449 // Could update the promoted average here, but it is not typically updated at | 446 // Could update the promoted average here, but it is not typically updated at |
450 // full GCs and the value to use is unclear. Something like | 447 // full GCs and the value to use is unclear. Something like |
451 // | 448 // |