2749 bool _failed; |
2749 bool _failed; |
2750 |
2750 |
2751 public: |
2751 public: |
2752 VerifyMarkedClosure(CMSBitMap* bm): _marks(bm), _failed(false) {} |
2752 VerifyMarkedClosure(CMSBitMap* bm): _marks(bm), _failed(false) {} |
2753 |
2753 |
2754 void do_bit(size_t offset) { |
2754 bool do_bit(size_t offset) { |
2755 HeapWord* addr = _marks->offsetToHeapWord(offset); |
2755 HeapWord* addr = _marks->offsetToHeapWord(offset); |
2756 if (!_marks->isMarked(addr)) { |
2756 if (!_marks->isMarked(addr)) { |
2757 oop(addr)->print(); |
2757 oop(addr)->print(); |
2758 gclog_or_tty->print_cr(" ("INTPTR_FORMAT" should have been marked)", addr); |
2758 gclog_or_tty->print_cr(" ("INTPTR_FORMAT" should have been marked)", addr); |
2759 _failed = true; |
2759 _failed = true; |
2760 } |
2760 } |
|
2761 return true; |
2761 } |
2762 } |
2762 |
2763 |
2763 bool failed() { return _failed; } |
2764 bool failed() { return _failed; } |
2764 }; |
2765 }; |
2765 |
2766 |
4643 stopTimer(); |
4644 stopTimer(); |
4644 CMSTokenSync x(true); // is cms thread |
4645 CMSTokenSync x(true); // is cms thread |
4645 startTimer(); |
4646 startTimer(); |
4646 sample_eden(); |
4647 sample_eden(); |
4647 // Get and clear dirty region from card table |
4648 // Get and clear dirty region from card table |
4648 dirtyRegion = _ct->ct_bs()->dirty_card_range_after_preclean( |
4649 dirtyRegion = _ct->ct_bs()->dirty_card_range_after_reset( |
4649 MemRegion(nextAddr, endAddr)); |
4650 MemRegion(nextAddr, endAddr), |
|
4651 true, |
|
4652 CardTableModRefBS::precleaned_card_val()); |
|
4653 |
4650 assert(dirtyRegion.start() >= nextAddr, |
4654 assert(dirtyRegion.start() >= nextAddr, |
4651 "returned region inconsistent?"); |
4655 "returned region inconsistent?"); |
4652 } |
4656 } |
4653 lastAddr = dirtyRegion.end(); |
4657 lastAddr = dirtyRegion.end(); |
4654 numDirtyCards = |
4658 numDirtyCards = |
5412 NULL, // space is set further below |
5416 NULL, // space is set further below |
5413 &_markBitMap, &_markStack, &_revisitStack, |
5417 &_markBitMap, &_markStack, &_revisitStack, |
5414 &mrias_cl); |
5418 &mrias_cl); |
5415 { |
5419 { |
5416 TraceTime t("grey object rescan", PrintGCDetails, false, gclog_or_tty); |
5420 TraceTime t("grey object rescan", PrintGCDetails, false, gclog_or_tty); |
5417 // Iterate over the dirty cards, marking them precleaned, and |
5421 // Iterate over the dirty cards, setting the corresponding bits in the |
5418 // setting the corresponding bits in the mod union table. |
5422 // mod union table. |
5419 { |
5423 { |
5420 ModUnionClosure modUnionClosure(&_modUnionTable); |
5424 ModUnionClosure modUnionClosure(&_modUnionTable); |
5421 _ct->ct_bs()->dirty_card_iterate( |
5425 _ct->ct_bs()->dirty_card_iterate( |
5422 _cmsGen->used_region(), |
5426 _cmsGen->used_region(), |
5423 &modUnionClosure); |
5427 &modUnionClosure); |
6185 |
6189 |
6186 // Construct a CMS bit map infrastructure, but don't create the |
6190 // Construct a CMS bit map infrastructure, but don't create the |
6187 // bit vector itself. That is done by a separate call CMSBitMap::allocate() |
6191 // bit vector itself. That is done by a separate call CMSBitMap::allocate() |
6188 // further below. |
6192 // further below. |
6189 CMSBitMap::CMSBitMap(int shifter, int mutex_rank, const char* mutex_name): |
6193 CMSBitMap::CMSBitMap(int shifter, int mutex_rank, const char* mutex_name): |
6190 _bm(NULL,0), |
6194 _bm(), |
6191 _shifter(shifter), |
6195 _shifter(shifter), |
6192 _lock(mutex_rank >= 0 ? new Mutex(mutex_rank, mutex_name, true) : NULL) |
6196 _lock(mutex_rank >= 0 ? new Mutex(mutex_rank, mutex_name, true) : NULL) |
6193 { |
6197 { |
6194 _bmStartWord = 0; |
6198 _bmStartWord = 0; |
6195 _bmWordSize = 0; |
6199 _bmWordSize = 0; |
6210 warning("CMS bit map backing store failure"); |
6214 warning("CMS bit map backing store failure"); |
6211 return false; |
6215 return false; |
6212 } |
6216 } |
6213 assert(_virtual_space.committed_size() == brs.size(), |
6217 assert(_virtual_space.committed_size() == brs.size(), |
6214 "didn't reserve backing store for all of CMS bit map?"); |
6218 "didn't reserve backing store for all of CMS bit map?"); |
6215 _bm.set_map((uintptr_t*)_virtual_space.low()); |
6219 _bm.set_map((BitMap::bm_word_t*)_virtual_space.low()); |
6216 assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >= |
6220 assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >= |
6217 _bmWordSize, "inconsistency in bit map sizing"); |
6221 _bmWordSize, "inconsistency in bit map sizing"); |
6218 _bm.set_size(_bmWordSize >> _shifter); |
6222 _bm.set_size(_bmWordSize >> _shifter); |
6219 |
6223 |
6220 // bm.clear(); // can we rely on getting zero'd memory? verify below |
6224 // bm.clear(); // can we rely on getting zero'd memory? verify below |
6851 (intptr_t)_finger, CardTableModRefBS::card_size); |
6855 (intptr_t)_finger, CardTableModRefBS::card_size); |
6852 } |
6856 } |
6853 |
6857 |
6854 // Should revisit to see if this should be restructured for |
6858 // Should revisit to see if this should be restructured for |
6855 // greater efficiency. |
6859 // greater efficiency. |
6856 void MarkFromRootsClosure::do_bit(size_t offset) { |
6860 bool MarkFromRootsClosure::do_bit(size_t offset) { |
6857 if (_skipBits > 0) { |
6861 if (_skipBits > 0) { |
6858 _skipBits--; |
6862 _skipBits--; |
6859 return; |
6863 return true; |
6860 } |
6864 } |
6861 // convert offset into a HeapWord* |
6865 // convert offset into a HeapWord* |
6862 HeapWord* addr = _bitMap->startWord() + offset; |
6866 HeapWord* addr = _bitMap->startWord() + offset; |
6863 assert(_bitMap->endWord() && addr < _bitMap->endWord(), |
6867 assert(_bitMap->endWord() && addr < _bitMap->endWord(), |
6864 "address out of range"); |
6868 "address out of range"); |
6894 // Redirty the range of cards... |
6898 // Redirty the range of cards... |
6895 _mut->mark_range(redirty_range); |
6899 _mut->mark_range(redirty_range); |
6896 } // ...else the setting of klass will dirty the card anyway. |
6900 } // ...else the setting of klass will dirty the card anyway. |
6897 } |
6901 } |
6898 DEBUG_ONLY(}) |
6902 DEBUG_ONLY(}) |
6899 return; |
6903 return true; |
6900 } |
6904 } |
6901 } |
6905 } |
6902 scanOopsInOop(addr); |
6906 scanOopsInOop(addr); |
|
6907 return true; |
6903 } |
6908 } |
6904 |
6909 |
6905 // We take a break if we've been at this for a while, |
6910 // We take a break if we've been at this for a while, |
6906 // so as to avoid monopolizing the locks involved. |
6911 // so as to avoid monopolizing the locks involved. |
6907 void MarkFromRootsClosure::do_yield_work() { |
6912 void MarkFromRootsClosure::do_yield_work() { |
7031 assert(_span.contains(_finger), "Out of bounds _finger?"); |
7036 assert(_span.contains(_finger), "Out of bounds _finger?"); |
7032 } |
7037 } |
7033 |
7038 |
7034 // Should revisit to see if this should be restructured for |
7039 // Should revisit to see if this should be restructured for |
7035 // greater efficiency. |
7040 // greater efficiency. |
7036 void Par_MarkFromRootsClosure::do_bit(size_t offset) { |
7041 bool Par_MarkFromRootsClosure::do_bit(size_t offset) { |
7037 if (_skip_bits > 0) { |
7042 if (_skip_bits > 0) { |
7038 _skip_bits--; |
7043 _skip_bits--; |
7039 return; |
7044 return true; |
7040 } |
7045 } |
7041 // convert offset into a HeapWord* |
7046 // convert offset into a HeapWord* |
7042 HeapWord* addr = _bit_map->startWord() + offset; |
7047 HeapWord* addr = _bit_map->startWord() + offset; |
7043 assert(_bit_map->endWord() && addr < _bit_map->endWord(), |
7048 assert(_bit_map->endWord() && addr < _bit_map->endWord(), |
7044 "address out of range"); |
7049 "address out of range"); |
7049 _skip_bits = 2; // skip next two marked bits ("Printezis-marks") |
7054 _skip_bits = 2; // skip next two marked bits ("Printezis-marks") |
7050 oop p = oop(addr); |
7055 oop p = oop(addr); |
7051 if (p->klass() == NULL || !p->is_parsable()) { |
7056 if (p->klass() == NULL || !p->is_parsable()) { |
7052 // in the case of Clean-on-Enter optimization, redirty card |
7057 // in the case of Clean-on-Enter optimization, redirty card |
7053 // and avoid clearing card by increasing the threshold. |
7058 // and avoid clearing card by increasing the threshold. |
7054 return; |
7059 return true; |
7055 } |
7060 } |
7056 } |
7061 } |
7057 scan_oops_in_oop(addr); |
7062 scan_oops_in_oop(addr); |
|
7063 return true; |
7058 } |
7064 } |
7059 |
7065 |
7060 void Par_MarkFromRootsClosure::scan_oops_in_oop(HeapWord* ptr) { |
7066 void Par_MarkFromRootsClosure::scan_oops_in_oop(HeapWord* ptr) { |
7061 assert(_bit_map->isMarked(ptr), "expected bit to be set"); |
7067 assert(_bit_map->isMarked(ptr), "expected bit to be set"); |
7062 // Should we assert that our work queue is empty or |
7068 // Should we assert that our work queue is empty or |
7175 _finger = addr; |
7181 _finger = addr; |
7176 } |
7182 } |
7177 |
7183 |
7178 // Should revisit to see if this should be restructured for |
7184 // Should revisit to see if this should be restructured for |
7179 // greater efficiency. |
7185 // greater efficiency. |
7180 void MarkFromRootsVerifyClosure::do_bit(size_t offset) { |
7186 bool MarkFromRootsVerifyClosure::do_bit(size_t offset) { |
7181 // convert offset into a HeapWord* |
7187 // convert offset into a HeapWord* |
7182 HeapWord* addr = _verification_bm->startWord() + offset; |
7188 HeapWord* addr = _verification_bm->startWord() + offset; |
7183 assert(_verification_bm->endWord() && addr < _verification_bm->endWord(), |
7189 assert(_verification_bm->endWord() && addr < _verification_bm->endWord(), |
7184 "address out of range"); |
7190 "address out of range"); |
7185 assert(_verification_bm->isMarked(addr), "tautology"); |
7191 assert(_verification_bm->isMarked(addr), "tautology"); |
7203 assert(new_oop->is_oop(), "Oops! expected to pop an oop"); |
7209 assert(new_oop->is_oop(), "Oops! expected to pop an oop"); |
7204 // now scan this oop's oops |
7210 // now scan this oop's oops |
7205 new_oop->oop_iterate(&_pam_verify_closure); |
7211 new_oop->oop_iterate(&_pam_verify_closure); |
7206 } |
7212 } |
7207 assert(_mark_stack->isEmpty(), "tautology, emphasizing post-condition"); |
7213 assert(_mark_stack->isEmpty(), "tautology, emphasizing post-condition"); |
|
7214 return true; |
7208 } |
7215 } |
7209 |
7216 |
7210 PushAndMarkVerifyClosure::PushAndMarkVerifyClosure( |
7217 PushAndMarkVerifyClosure::PushAndMarkVerifyClosure( |
7211 CMSCollector* collector, MemRegion span, |
7218 CMSCollector* collector, MemRegion span, |
7212 CMSBitMap* verification_bm, CMSBitMap* cms_bm, |
7219 CMSBitMap* verification_bm, CMSBitMap* cms_bm, |
7446 } |
7453 } |
7447 |
7454 |
7448 // Grey object rescan during pre-cleaning and second checkpoint phases -- |
7455 // Grey object rescan during pre-cleaning and second checkpoint phases -- |
7449 // the non-parallel version (the parallel version appears further below.) |
7456 // the non-parallel version (the parallel version appears further below.) |
7450 void PushAndMarkClosure::do_oop(oop obj) { |
7457 void PushAndMarkClosure::do_oop(oop obj) { |
7451 // If _concurrent_precleaning, ignore mark word verification |
7458 // Ignore mark word verification. If during concurrent precleaning, |
7452 assert(obj->is_oop_or_null(_concurrent_precleaning), |
7459 // the object monitor may be locked. If during the checkpoint |
|
7460 // phases, the object may already have been reached by a different |
|
7461 // path and may be at the end of the global overflow list (so |
|
7462 // the mark word may be NULL). |
|
7463 assert(obj->is_oop_or_null(true /* ignore mark word */), |
7453 "expected an oop or NULL"); |
7464 "expected an oop or NULL"); |
7454 HeapWord* addr = (HeapWord*)obj; |
7465 HeapWord* addr = (HeapWord*)obj; |
7455 // Check if oop points into the CMS generation |
7466 // Check if oop points into the CMS generation |
7456 // and is not marked |
7467 // and is not marked |
7457 if (_span.contains(addr) && !_bit_map->isMarked(addr)) { |
7468 if (_span.contains(addr) && !_bit_map->isMarked(addr)) { |