Mercurial > hg > truffle
diff src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @ 271:818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
Summary: An expansion by 0 bytes was not anticipated when the assertion was composed.
Reviewed-by: jjh, jcoomes, apetrusenko
author | jmasa |
---|---|
date | Wed, 30 Jul 2008 11:54:00 -0700 |
parents | 12eea04c8b06 |
children | 9ee9cf798b59 a4b729f5b611 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp Mon Jul 28 15:30:23 2008 -0700 +++ b/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp Wed Jul 30 11:54:00 2008 -0700 @@ -215,10 +215,22 @@ } void PSOldGen::expand(size_t bytes) { + if (bytes == 0) { + return; + } MutexLocker x(ExpandHeap_lock); const size_t alignment = virtual_space()->alignment(); size_t aligned_bytes = align_size_up(bytes, alignment); size_t aligned_expand_bytes = align_size_up(MinHeapDeltaBytes, alignment); + if (aligned_bytes == 0){ + // The alignment caused the number of bytes to wrap. An expand_by(0) will + // return true with the implication that and expansion was done when it + // was not. A call to expand implies a best effort to expand by "bytes" + // but not a guarantee. Align down to give a best effort. This is likely + // the most that the generation can expand since it has some capacity to + // start with. + aligned_bytes = align_size_down(bytes, alignment); + } bool success = false; if (aligned_expand_bytes > aligned_bytes) { @@ -231,8 +243,8 @@ success = expand_to_reserved(); } - if (GC_locker::is_active()) { - if (PrintGC && Verbose) { + if (PrintGC && Verbose) { + if (success && GC_locker::is_active()) { gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead"); } } @@ -241,6 +253,9 @@ bool PSOldGen::expand_by(size_t bytes) { assert_lock_strong(ExpandHeap_lock); assert_locked_or_safepoint(Heap_lock); + if (bytes == 0) { + return true; // That's what virtual_space()->expand_by(0) would return + } bool result = virtual_space()->expand_by(bytes); if (result) { if (ZapUnusedHeapArea) {