comparison src/share/vm/memory/generation.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 850fdf70db2b
children e9be0e04635a
comparison
equal deleted inserted replaced
269:850fdf70db2b 271:818a18cd69a8
375 if (reserved_mr.end() != Universe::heap()->reserved_region().end()) { 375 if (reserved_mr.end() != Universe::heap()->reserved_region().end()) {
376 // Don't check at the very end of the heap as we'll assert that we're probing off 376 // Don't check at the very end of the heap as we'll assert that we're probing off
377 // the end if we try. 377 // the end if we try.
378 guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned"); 378 guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
379 } 379 }
380 }
381
382 bool CardGeneration::expand(size_t bytes, size_t expand_bytes) {
383 assert_locked_or_safepoint(Heap_lock);
384 if (bytes == 0) {
385 return true; // That's what grow_by(0) would return
386 }
387 size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes);
388 if (aligned_bytes == 0){
389 // The alignment caused the number of bytes to wrap. An expand_by(0) will
390 // return true with the implication that an expansion was done when it
391 // was not. A call to expand implies a best effort to expand by "bytes"
392 // but not a guarantee. Align down to give a best effort. This is likely
393 // the most that the generation can expand since it has some capacity to
394 // start with.
395 aligned_bytes = ReservedSpace::page_align_size_down(bytes);
396 }
397 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
398 bool success = false;
399 if (aligned_expand_bytes > aligned_bytes) {
400 success = grow_by(aligned_expand_bytes);
401 }
402 if (!success) {
403 success = grow_by(aligned_bytes);
404 }
405 if (!success) {
406 success = grow_to_reserved();
407 }
408 if (PrintGC && Verbose) {
409 if (success && GC_locker::is_active()) {
410 gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
411 }
412 }
413
414 return success;
380 } 415 }
381 416
382 417
383 // No young generation references, clear this generation's cards. 418 // No young generation references, clear this generation's cards.
384 void CardGeneration::clear_remembered_set() { 419 void CardGeneration::clear_remembered_set() {
439 expand(word_size*HeapWordSize, _min_heap_delta_bytes); 474 expand(word_size*HeapWordSize, _min_heap_delta_bytes);
440 return _the_space->allocate(word_size); 475 return _the_space->allocate(word_size);
441 } 476 }
442 } 477 }
443 478
444 void OneContigSpaceCardGeneration::expand(size_t bytes, size_t expand_bytes) { 479 bool OneContigSpaceCardGeneration::expand(size_t bytes, size_t expand_bytes) {
445 GCMutexLocker x(ExpandHeap_lock); 480 GCMutexLocker x(ExpandHeap_lock);
446 size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes); 481 return CardGeneration::expand(bytes, expand_bytes);
447 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
448 bool success = false;
449 if (aligned_expand_bytes > aligned_bytes) {
450 success = grow_by(aligned_expand_bytes);
451 }
452 if (!success) {
453 success = grow_by(aligned_bytes);
454 }
455 if (!success) {
456 grow_to_reserved();
457 }
458 if (GC_locker::is_active()) {
459 if (PrintGC && Verbose) {
460 gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
461 }
462 }
463 } 482 }
464 483
465 484
466 void OneContigSpaceCardGeneration::shrink(size_t bytes) { 485 void OneContigSpaceCardGeneration::shrink(size_t bytes) {
467 assert_locked_or_safepoint(ExpandHeap_lock); 486 assert_locked_or_safepoint(ExpandHeap_lock);