2892 assert(haveFreelistLocks(), "must hold free list locks"); |
2892 assert(haveFreelistLocks(), "must hold free list locks"); |
2893 assert_lock_strong(bitMapLock()); |
2893 assert_lock_strong(bitMapLock()); |
2894 |
2894 |
2895 // Clear the marking bit map array before starting, but, just |
2895 // Clear the marking bit map array before starting, but, just |
2896 // for kicks, first report if the given address is already marked |
2896 // for kicks, first report if the given address is already marked |
2897 gclog_or_tty->print_cr("Start: Address 0x%x is%s marked", addr, |
2897 gclog_or_tty->print_cr("Start: Address " PTR_FORMAT " is%s marked", addr, |
2898 _markBitMap.isMarked(addr) ? "" : " not"); |
2898 _markBitMap.isMarked(addr) ? "" : " not"); |
2899 |
2899 |
2900 if (verify_after_remark()) { |
2900 if (verify_after_remark()) { |
2901 MutexLockerEx x(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag); |
2901 MutexLockerEx x(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag); |
2902 bool result = verification_mark_bm()->isMarked(addr); |
2902 bool result = verification_mark_bm()->isMarked(addr); |
2903 gclog_or_tty->print_cr("TransitiveMark: Address 0x%x %s marked", addr, |
2903 gclog_or_tty->print_cr("TransitiveMark: Address " PTR_FORMAT " %s marked", addr, |
2904 result ? "IS" : "is NOT"); |
2904 result ? "IS" : "is NOT"); |
2905 return result; |
2905 return result; |
2906 } else { |
2906 } else { |
2907 gclog_or_tty->print_cr("Could not compute result"); |
2907 gclog_or_tty->print_cr("Could not compute result"); |
2908 return false; |
2908 return false; |
4567 startTimer(); |
4567 startTimer(); |
4568 waited++; |
4568 waited++; |
4569 } |
4569 } |
4570 } |
4570 } |
4571 if (PrintCMSStatistics > 0) { |
4571 if (PrintCMSStatistics > 0) { |
4572 gclog_or_tty->print(" [%d iterations, %d waits, %d cards)] ", |
4572 gclog_or_tty->print(" [" SIZE_FORMAT " iterations, " SIZE_FORMAT " waits, " SIZE_FORMAT " cards)] ", |
4573 loops, waited, cumworkdone); |
4573 loops, waited, cumworkdone); |
4574 } |
4574 } |
4575 } |
4575 } |
4576 CMSTokenSync x(true); // is cms thread |
4576 CMSTokenSync x(true); // is cms thread |
4577 if (_collectorState != Idling) { |
4577 if (_collectorState != Idling) { |
4719 for (numIter = 0, cumNumCards = lastNumCards = curNumCards = 0; |
4719 for (numIter = 0, cumNumCards = lastNumCards = curNumCards = 0; |
4720 numIter < CMSPrecleanIter; |
4720 numIter < CMSPrecleanIter; |
4721 numIter++, lastNumCards = curNumCards, cumNumCards += curNumCards) { |
4721 numIter++, lastNumCards = curNumCards, cumNumCards += curNumCards) { |
4722 curNumCards = preclean_mod_union_table(_cmsGen, &smoac_cl); |
4722 curNumCards = preclean_mod_union_table(_cmsGen, &smoac_cl); |
4723 if (Verbose && PrintGCDetails) { |
4723 if (Verbose && PrintGCDetails) { |
4724 gclog_or_tty->print(" (modUnionTable: %d cards)", curNumCards); |
4724 gclog_or_tty->print(" (modUnionTable: " SIZE_FORMAT " cards)", curNumCards); |
4725 } |
4725 } |
4726 // Either there are very few dirty cards, so re-mark |
4726 // Either there are very few dirty cards, so re-mark |
4727 // pause will be small anyway, or our pre-cleaning isn't |
4727 // pause will be small anyway, or our pre-cleaning isn't |
4728 // that much faster than the rate at which cards are being |
4728 // that much faster than the rate at which cards are being |
4729 // dirtied, so we might as well stop and re-mark since |
4729 // dirtied, so we might as well stop and re-mark since |
4741 preclean_klasses(&mrias_cl, _cmsGen->freelistLock()); |
4741 preclean_klasses(&mrias_cl, _cmsGen->freelistLock()); |
4742 |
4742 |
4743 curNumCards = preclean_card_table(_cmsGen, &smoac_cl); |
4743 curNumCards = preclean_card_table(_cmsGen, &smoac_cl); |
4744 cumNumCards += curNumCards; |
4744 cumNumCards += curNumCards; |
4745 if (PrintGCDetails && PrintCMSStatistics != 0) { |
4745 if (PrintGCDetails && PrintCMSStatistics != 0) { |
4746 gclog_or_tty->print_cr(" (cardTable: %d cards, re-scanned %d cards, %d iterations)", |
4746 gclog_or_tty->print_cr(" (cardTable: " SIZE_FORMAT " cards, re-scanned " SIZE_FORMAT " cards, " SIZE_FORMAT " iterations)", |
4747 curNumCards, cumNumCards, numIter); |
4747 curNumCards, cumNumCards, numIter); |
4748 } |
4748 } |
4749 return cumNumCards; // as a measure of useful work done |
4749 return cumNumCards; // as a measure of useful work done |
4750 } |
4750 } |
4751 |
4751 |
8203 #endif // PRODUCT |
8203 #endif // PRODUCT |
8204 |
8204 |
8205 void SweepClosure::initialize_free_range(HeapWord* freeFinger, |
8205 void SweepClosure::initialize_free_range(HeapWord* freeFinger, |
8206 bool freeRangeInFreeLists) { |
8206 bool freeRangeInFreeLists) { |
8207 if (CMSTraceSweeper) { |
8207 if (CMSTraceSweeper) { |
8208 gclog_or_tty->print("---- Start free range at 0x%x with free block (%d)\n", |
8208 gclog_or_tty->print("---- Start free range at " PTR_FORMAT " with free block (%d)\n", |
8209 freeFinger, freeRangeInFreeLists); |
8209 freeFinger, freeRangeInFreeLists); |
8210 } |
8210 } |
8211 assert(!inFreeRange(), "Trampling existing free range"); |
8211 assert(!inFreeRange(), "Trampling existing free range"); |
8212 set_inFreeRange(true); |
8212 set_inFreeRange(true); |
8213 set_lastFreeRangeCoalesced(false); |
8213 set_lastFreeRangeCoalesced(false); |
8273 err_msg("freeFinger() " PTR_FORMAT" is out-of-bounds", freeFinger())); |
8273 err_msg("freeFinger() " PTR_FORMAT" is out-of-bounds", freeFinger())); |
8274 flush_cur_free_chunk(freeFinger(), |
8274 flush_cur_free_chunk(freeFinger(), |
8275 pointer_delta(addr, freeFinger())); |
8275 pointer_delta(addr, freeFinger())); |
8276 if (CMSTraceSweeper) { |
8276 if (CMSTraceSweeper) { |
8277 gclog_or_tty->print("Sweep: last chunk: "); |
8277 gclog_or_tty->print("Sweep: last chunk: "); |
8278 gclog_or_tty->print("put_free_blk 0x%x ("SIZE_FORMAT") " |
8278 gclog_or_tty->print("put_free_blk " PTR_FORMAT " ("SIZE_FORMAT") " |
8279 "[coalesced:"SIZE_FORMAT"]\n", |
8279 "[coalesced:%d]\n", |
8280 freeFinger(), pointer_delta(addr, freeFinger()), |
8280 freeFinger(), pointer_delta(addr, freeFinger()), |
8281 lastFreeRangeCoalesced()); |
8281 lastFreeRangeCoalesced() ? 1 : 0); |
8282 } |
8282 } |
8283 } |
8283 } |
8284 |
8284 |
8285 // help the iterator loop finish |
8285 // help the iterator loop finish |
8286 return pointer_delta(_sp->end(), addr); |
8286 return pointer_delta(_sp->end(), addr); |
8419 } |
8419 } |
8420 } else { |
8420 } else { |
8421 // the midst of a free range, we are coalescing |
8421 // the midst of a free range, we are coalescing |
8422 print_free_block_coalesced(fc); |
8422 print_free_block_coalesced(fc); |
8423 if (CMSTraceSweeper) { |
8423 if (CMSTraceSweeper) { |
8424 gclog_or_tty->print(" -- pick up free block 0x%x (%d)\n", fc, size); |
8424 gclog_or_tty->print(" -- pick up free block " PTR_FORMAT " (" SIZE_FORMAT ")\n", fc, size); |
8425 } |
8425 } |
8426 // remove it from the free lists |
8426 // remove it from the free lists |
8427 _sp->removeFreeChunkFromFreeLists(fc); |
8427 _sp->removeFreeChunkFromFreeLists(fc); |
8428 set_lastFreeRangeCoalesced(true); |
8428 set_lastFreeRangeCoalesced(true); |
8429 // If the chunk is being coalesced and the current free range is |
8429 // If the chunk is being coalesced and the current free range is |
8481 initialize_free_range(addr, false); |
8481 initialize_free_range(addr, false); |
8482 } else { |
8482 } else { |
8483 // this will be swept up when we hit the end of the |
8483 // this will be swept up when we hit the end of the |
8484 // free range |
8484 // free range |
8485 if (CMSTraceSweeper) { |
8485 if (CMSTraceSweeper) { |
8486 gclog_or_tty->print(" -- pick up garbage 0x%x (%d) \n", fc, size); |
8486 gclog_or_tty->print(" -- pick up garbage " PTR_FORMAT " (" SIZE_FORMAT ")\n", fc, size); |
8487 } |
8487 } |
8488 // If the chunk is being coalesced and the current free range is |
8488 // If the chunk is being coalesced and the current free range is |
8489 // in the free lists, remove the current free range so that it |
8489 // in the free lists, remove the current free range so that it |
8490 // will be returned to the free lists in its entirety - all |
8490 // will be returned to the free lists in its entirety - all |
8491 // the coalesced pieces included. |
8491 // the coalesced pieces included. |
8574 if (CMSTestInFreeList && fcInFreeLists) { |
8574 if (CMSTestInFreeList && fcInFreeLists) { |
8575 assert(_sp->verify_chunk_in_free_list(fc), "free chunk is not in free lists"); |
8575 assert(_sp->verify_chunk_in_free_list(fc), "free chunk is not in free lists"); |
8576 } |
8576 } |
8577 |
8577 |
8578 if (CMSTraceSweeper) { |
8578 if (CMSTraceSweeper) { |
8579 gclog_or_tty->print_cr(" -- pick up another chunk at 0x%x (%d)", fc, chunkSize); |
8579 gclog_or_tty->print_cr(" -- pick up another chunk at " PTR_FORMAT " (" SIZE_FORMAT ")", fc, chunkSize); |
8580 } |
8580 } |
8581 |
8581 |
8582 HeapWord* const fc_addr = (HeapWord*) fc; |
8582 HeapWord* const fc_addr = (HeapWord*) fc; |
8583 |
8583 |
8584 bool coalesce; |
8584 bool coalesce; |
8703 fc->set_size(size); |
8703 fc->set_size(size); |
8704 assert(!_sp->verify_chunk_in_free_list(fc), |
8704 assert(!_sp->verify_chunk_in_free_list(fc), |
8705 "chunk should not be in free lists yet"); |
8705 "chunk should not be in free lists yet"); |
8706 } |
8706 } |
8707 if (CMSTraceSweeper) { |
8707 if (CMSTraceSweeper) { |
8708 gclog_or_tty->print_cr(" -- add free block 0x%x (%d) to free lists", |
8708 gclog_or_tty->print_cr(" -- add free block " PTR_FORMAT " (" SIZE_FORMAT ") to free lists", |
8709 chunk, size); |
8709 chunk, size); |
8710 } |
8710 } |
8711 // A new free range is going to be starting. The current |
8711 // A new free range is going to be starting. The current |
8712 // free range has not been added to the free lists yet or |
8712 // free range has not been added to the free lists yet or |
8713 // was removed so add it back. |
8713 // was removed so add it back. |