< prev index next >

src/share/vm/gc/shared/blockOffsetTable.cpp

Print this page
rev 8442 : 8081629: CMS split_block() does not correctly fix up block-offset-table for large blocks
Reviewed-by:


 430   size_t end_index  = _array->index_for(end_addr - 1) + 1;
 431 
 432   // Calculate the # cards that the prefix and suffix affect.
 433   size_t num_pref_cards = suff_index - pref_index;
 434 
 435   size_t num_suff_cards = end_index  - suff_index;
 436   // Change the cards that need changing
 437   if (num_suff_cards > 0) {
 438     HeapWord* boundary = _array->address_for_index(suff_index);
 439     // Set the offset card for suffix block
 440     _array->set_offset_array(suff_index, boundary, suff_addr, true /* reducing */);
 441     // Change any further cards that need changing in the suffix
 442     if (num_pref_cards > 0) {
 443       if (num_pref_cards >= num_suff_cards) {
 444         // Unilaterally fix all of the suffix cards: closed card
 445         // index interval in args below.
 446         set_remainder_to_point_to_start_incl(suff_index + 1, end_index - 1, true /* reducing */);
 447       } else {
 448         // Unilaterally fix the first (num_pref_cards - 1) following
 449         // the "offset card" in the suffix block.

 450         set_remainder_to_point_to_start_incl(suff_index + 1,
 451           suff_index + num_pref_cards - 1, true /* reducing */);
 452         // Fix the appropriate cards in the remainder of the
 453         // suffix block -- these are the last num_pref_cards
 454         // cards in each power block of the "new" range plumbed
 455         // from suff_addr.
 456         bool more = true;
 457         uint i = 1;

 458         while (more && (i < N_powers)) {
 459           size_t back_by = power_to_cards_back(i);
 460           size_t right_index = suff_index + back_by - 1;
 461           size_t left_index  = right_index - num_pref_cards + 1;
 462           if (right_index >= end_index - 1) { // last iteration
 463             right_index = end_index - 1;
 464             more = false;
 465           }



 466           if (back_by > num_pref_cards) {
 467             // Fill in the remainder of this "power block", if it
 468             // is non-null.
 469             if (left_index <= right_index) {
 470               _array->set_offset_array(left_index, right_index,
 471                                      N_words + i - 1, true /* reducing */);
 472             } else {
 473               more = false; // we are done

 474             }
 475             i++;
 476             break;
 477           }
 478           i++;
 479         }

 480         while (more && (i < N_powers)) {
 481           size_t back_by = power_to_cards_back(i);
 482           size_t right_index = suff_index + back_by - 1;
 483           size_t left_index  = right_index - num_pref_cards + 1;
 484           if (right_index >= end_index - 1) { // last iteration
 485             right_index = end_index - 1;
 486             if (left_index > right_index) {
 487               break;
 488             }
 489             more  = false;
 490           }
 491           assert(left_index <= right_index, "Error");
 492           _array->set_offset_array(left_index, right_index, N_words + i - 1, true /* reducing */);
 493           i++;
 494         }
 495       }
 496     } // else no more cards to fix in suffix
 497   } // else nothing needs to be done
 498   // Verify that we did the right thing
 499   verify_single_block(pref_addr, left_blk_size);




 430   size_t end_index  = _array->index_for(end_addr - 1) + 1;
 431 
 432   // Calculate the # cards that the prefix and suffix affect.
 433   size_t num_pref_cards = suff_index - pref_index;
 434 
 435   size_t num_suff_cards = end_index  - suff_index;
 436   // Change the cards that need changing
 437   if (num_suff_cards > 0) {
 438     HeapWord* boundary = _array->address_for_index(suff_index);
 439     // Set the offset card for suffix block
 440     _array->set_offset_array(suff_index, boundary, suff_addr, true /* reducing */);
 441     // Change any further cards that need changing in the suffix
 442     if (num_pref_cards > 0) {
 443       if (num_pref_cards >= num_suff_cards) {
 444         // Unilaterally fix all of the suffix cards: closed card
 445         // index interval in args below.
 446         set_remainder_to_point_to_start_incl(suff_index + 1, end_index - 1, true /* reducing */);
 447       } else {
 448         // Unilaterally fix the first (num_pref_cards - 1) following
 449         // the "offset card" in the suffix block.
 450         const size_t right_most_fixed_index = suff_index + num_pref_cards - 1;
 451         set_remainder_to_point_to_start_incl(suff_index + 1,
 452           right_most_fixed_index, true /* reducing */);
 453         // Fix the appropriate cards in the remainder of the
 454         // suffix block -- these are the last num_pref_cards
 455         // cards in each power block of the "new" range plumbed
 456         // from suff_addr.
 457         bool more = true;
 458         uint i = 1;
 459         // Fix the first power block with  back_by > num_pref_cards.
 460         while (more && (i < N_powers)) {
 461           size_t back_by = power_to_cards_back(i);
 462           size_t right_index = suff_index + back_by - 1;
 463           size_t left_index  = right_index - num_pref_cards + 1;
 464           if (right_index >= end_index - 1) { // last iteration
 465             right_index = end_index - 1;
 466             more = false;
 467           }
 468           if (left_index <= right_most_fixed_index) {
 469                 left_index = right_most_fixed_index + 1;
 470           }
 471           if (back_by > num_pref_cards) {
 472             // Fill in the remainder of this "power block", if it
 473             // is non-null.
 474             if (left_index <= right_index) {
 475               _array->set_offset_array(left_index, right_index,
 476                                      N_words + i - 1, true /* reducing */);
 477             } else {
 478               more = false; // we are done
 479               assert((end_index - 1) == right_index, "Must be at the end.");
 480             }
 481             i++;
 482             break;
 483           }
 484           i++;
 485         }
 486         // Fix the rest of the power blocks.
 487         while (more && (i < N_powers)) {
 488           size_t back_by = power_to_cards_back(i);
 489           size_t right_index = suff_index + back_by - 1;
 490           size_t left_index  = right_index - num_pref_cards + 1;
 491           if (right_index >= end_index - 1) { // last iteration
 492             right_index = end_index - 1;
 493             if (left_index > right_index) {
 494               break;
 495             }
 496             more  = false;
 497           }
 498           assert(left_index <= right_index, "Error");
 499           _array->set_offset_array(left_index, right_index, N_words + i - 1, true /* reducing */);
 500           i++;
 501         }
 502       }
 503     } // else no more cards to fix in suffix
 504   } // else nothing needs to be done
 505   // Verify that we did the right thing
 506   verify_single_block(pref_addr, left_blk_size);


< prev index next >