comparison src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @ 344:6aae2f9d0294

Merge
author ysr
date Thu, 12 Jun 2008 13:50:55 -0700
parents 37f87013dfd8 790e66e5fbac
children 1ee8caae33af
comparison
equal deleted inserted replaced
342:37f87013dfd8 344:6aae2f9d0294
188 // Verify the assumption that FreeChunk::_prev and OopDesc::_klass 188 // Verify the assumption that FreeChunk::_prev and OopDesc::_klass
189 // offsets match. The ability to tell free chunks from objects 189 // offsets match. The ability to tell free chunks from objects
190 // depends on this property. 190 // depends on this property.
191 debug_only( 191 debug_only(
192 FreeChunk* junk = NULL; 192 FreeChunk* junk = NULL;
193 assert(junk->prev_addr() == (void*)(oop(junk)->klass_addr()), 193 assert(UseCompressedOops ||
194 junk->prev_addr() == (void*)(oop(junk)->klass_addr()),
194 "Offset of FreeChunk::_prev within FreeChunk must match" 195 "Offset of FreeChunk::_prev within FreeChunk must match"
195 " that of OopDesc::_klass within OopDesc"); 196 " that of OopDesc::_klass within OopDesc");
196 ) 197 )
197 if (ParallelGCThreads > 0) { 198 if (ParallelGCThreads > 0) {
198 typedef CMSParGCThreadState* CMSParGCThreadStatePtr; 199 typedef CMSParGCThreadState* CMSParGCThreadStatePtr;
1037 _markBitMap.mark(start + 1); // object is potentially uninitialized? 1038 _markBitMap.mark(start + 1); // object is potentially uninitialized?
1038 _markBitMap.mark(start + size - 1); 1039 _markBitMap.mark(start + size - 1);
1039 // mark end of object 1040 // mark end of object
1040 } 1041 }
1041 // check that oop looks uninitialized 1042 // check that oop looks uninitialized
1042 assert(oop(start)->klass() == NULL, "_klass should be NULL"); 1043 assert(oop(start)->klass_or_null() == NULL, "_klass should be NULL");
1043 } 1044 }
1044 1045
1045 void CMSCollector::promoted(bool par, HeapWord* start, 1046 void CMSCollector::promoted(bool par, HeapWord* start,
1046 bool is_obj_array, size_t obj_size) { 1047 bool is_obj_array, size_t obj_size) {
1047 assert(_markBitMap.covers(start), "Out of bounds"); 1048 assert(_markBitMap.covers(start), "Out of bounds");
1307 if (obj_ptr == NULL) { 1308 if (obj_ptr == NULL) {
1308 return NULL; 1309 return NULL;
1309 } 1310 }
1310 } 1311 }
1311 oop obj = oop(obj_ptr); 1312 oop obj = oop(obj_ptr);
1312 assert(obj->klass() == NULL, "Object should be uninitialized here."); 1313 assert(obj->klass_or_null() == NULL, "Object should be uninitialized here.");
1313 // Otherwise, copy the object. Here we must be careful to insert the 1314 // Otherwise, copy the object. Here we must be careful to insert the
1314 // klass pointer last, since this marks the block as an allocated object. 1315 // klass pointer last, since this marks the block as an allocated object.
1316 // Except with compressed oops it's the mark word.
1315 HeapWord* old_ptr = (HeapWord*)old; 1317 HeapWord* old_ptr = (HeapWord*)old;
1316 if (word_sz > (size_t)oopDesc::header_size()) { 1318 if (word_sz > (size_t)oopDesc::header_size()) {
1317 Copy::aligned_disjoint_words(old_ptr + oopDesc::header_size(), 1319 Copy::aligned_disjoint_words(old_ptr + oopDesc::header_size(),
1318 obj_ptr + oopDesc::header_size(), 1320 obj_ptr + oopDesc::header_size(),
1319 word_sz - oopDesc::header_size()); 1321 word_sz - oopDesc::header_size());
1320 } 1322 }
1323
1324 if (UseCompressedOops) {
1325 // Copy gap missed by (aligned) header size calculation above
1326 obj->set_klass_gap(old->klass_gap());
1327 }
1328
1321 // Restore the mark word copied above. 1329 // Restore the mark word copied above.
1322 obj->set_mark(m); 1330 obj->set_mark(m);
1331
1323 // Now we can track the promoted object, if necessary. We take care 1332 // Now we can track the promoted object, if necessary. We take care
1324 // To delay the transition from uninitialized to full object 1333 // To delay the transition from uninitialized to full object
1325 // (i.e., insertion of klass pointer) until after, so that it 1334 // (i.e., insertion of klass pointer) until after, so that it
1326 // atomically becomes a promoted object. 1335 // atomically becomes a promoted object.
1327 if (promoInfo->tracking()) { 1336 if (promoInfo->tracking()) {
1328 promoInfo->track((PromotedObject*)obj, old->klass()); 1337 promoInfo->track((PromotedObject*)obj, old->klass());
1329 } 1338 }
1330 // Finally, install the klass pointer. 1339
1340 // Finally, install the klass pointer (this should be volatile).
1331 obj->set_klass(old->klass()); 1341 obj->set_klass(old->klass());
1332 1342
1333 assert(old->is_oop(), "Will dereference klass ptr below"); 1343 assert(old->is_oop(), "Will dereference klass ptr below");
1334 collector()->promoted(true, // parallel 1344 collector()->promoted(true, // parallel
1335 obj_ptr, old->is_objArray(), word_sz); 1345 obj_ptr, old->is_objArray(), word_sz);
6167 } 6177 }
6168 6178
6169 HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const { 6179 HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const {
6170 size_t sz = 0; 6180 size_t sz = 0;
6171 oop p = (oop)addr; 6181 oop p = (oop)addr;
6172 if (p->klass() != NULL && p->is_parsable()) { 6182 if (p->klass_or_null() != NULL && p->is_parsable()) {
6173 sz = CompactibleFreeListSpace::adjustObjectSize(p->size()); 6183 sz = CompactibleFreeListSpace::adjustObjectSize(p->size());
6174 } else { 6184 } else {
6175 sz = block_size_using_printezis_bits(addr); 6185 sz = block_size_using_printezis_bits(addr);
6176 } 6186 }
6177 assert(sz > 0, "size must be nonzero"); 6187 assert(sz > 0, "size must be nonzero");
6604 // and we have been asked to abort this ongoing preclean cycle. 6614 // and we have been asked to abort this ongoing preclean cycle.
6605 return 0; 6615 return 0;
6606 } 6616 }
6607 if (_bitMap->isMarked(addr)) { 6617 if (_bitMap->isMarked(addr)) {
6608 // it's marked; is it potentially uninitialized? 6618 // it's marked; is it potentially uninitialized?
6609 if (p->klass() != NULL) { 6619 if (p->klass_or_null() != NULL) {
6610 if (CMSPermGenPrecleaningEnabled && !p->is_parsable()) { 6620 if (CMSPermGenPrecleaningEnabled && !p->is_parsable()) {
6611 // Signal precleaning to redirty the card since 6621 // Signal precleaning to redirty the card since
6612 // the klass pointer is already installed. 6622 // the klass pointer is already installed.
6613 assert(size == 0, "Initial value"); 6623 assert(size == 0, "Initial value");
6614 } else { 6624 } else {
6617 // since we are running concurrent with mutators 6627 // since we are running concurrent with mutators
6618 assert(p->is_oop(true), "should be an oop"); 6628 assert(p->is_oop(true), "should be an oop");
6619 if (p->is_objArray()) { 6629 if (p->is_objArray()) {
6620 // objArrays are precisely marked; restrict scanning 6630 // objArrays are precisely marked; restrict scanning
6621 // to dirty cards only. 6631 // to dirty cards only.
6622 size = p->oop_iterate(_scanningClosure, mr); 6632 size = CompactibleFreeListSpace::adjustObjectSize(
6623 assert(size == CompactibleFreeListSpace::adjustObjectSize(size), 6633 p->oop_iterate(_scanningClosure, mr));
6624 "adjustObjectSize should be the identity for array sizes, "
6625 "which are necessarily larger than minimum object size of "
6626 "two heap words");
6627 } else { 6634 } else {
6628 // A non-array may have been imprecisely marked; we need 6635 // A non-array may have been imprecisely marked; we need
6629 // to scan object in its entirety. 6636 // to scan object in its entirety.
6630 size = CompactibleFreeListSpace::adjustObjectSize( 6637 size = CompactibleFreeListSpace::adjustObjectSize(
6631 p->oop_iterate(_scanningClosure)); 6638 p->oop_iterate(_scanningClosure));
6655 // will dirty the card when the klass pointer is installed in the 6662 // will dirty the card when the klass pointer is installed in the
6656 // object (signalling the completion of initialization). 6663 // object (signalling the completion of initialization).
6657 } 6664 }
6658 } else { 6665 } else {
6659 // Either a not yet marked object or an uninitialized object 6666 // Either a not yet marked object or an uninitialized object
6660 if (p->klass() == NULL || !p->is_parsable()) { 6667 if (p->klass_or_null() == NULL || !p->is_parsable()) {
6661 // An uninitialized object, skip to the next card, since 6668 // An uninitialized object, skip to the next card, since
6662 // we may not be able to read its P-bits yet. 6669 // we may not be able to read its P-bits yet.
6663 assert(size == 0, "Initial value"); 6670 assert(size == 0, "Initial value");
6664 } else { 6671 } else {
6665 // An object not (yet) reached by marking: we merely need to 6672 // An object not (yet) reached by marking: we merely need to
6712 size_t SurvivorSpacePrecleanClosure::do_object_careful(oop p) { 6719 size_t SurvivorSpacePrecleanClosure::do_object_careful(oop p) {
6713 6720
6714 HeapWord* addr = (HeapWord*)p; 6721 HeapWord* addr = (HeapWord*)p;
6715 DEBUG_ONLY(_collector->verify_work_stacks_empty();) 6722 DEBUG_ONLY(_collector->verify_work_stacks_empty();)
6716 assert(!_span.contains(addr), "we are scanning the survivor spaces"); 6723 assert(!_span.contains(addr), "we are scanning the survivor spaces");
6717 assert(p->klass() != NULL, "object should be initializd"); 6724 assert(p->klass_or_null() != NULL, "object should be initializd");
6718 assert(p->is_parsable(), "must be parsable."); 6725 assert(p->is_parsable(), "must be parsable.");
6719 // an initialized object; ignore mark word in verification below 6726 // an initialized object; ignore mark word in verification below
6720 // since we are running concurrent with mutators 6727 // since we are running concurrent with mutators
6721 assert(p->is_oop(true), "should be an oop"); 6728 assert(p->is_oop(true), "should be an oop");
6722 // Note that we do not yield while we iterate over 6729 // Note that we do not yield while we iterate over
6870 if (_bitMap->isMarked(addr+1)) { 6877 if (_bitMap->isMarked(addr+1)) {
6871 // this is an allocated but not yet initialized object 6878 // this is an allocated but not yet initialized object
6872 assert(_skipBits == 0, "tautology"); 6879 assert(_skipBits == 0, "tautology");
6873 _skipBits = 2; // skip next two marked bits ("Printezis-marks") 6880 _skipBits = 2; // skip next two marked bits ("Printezis-marks")
6874 oop p = oop(addr); 6881 oop p = oop(addr);
6875 if (p->klass() == NULL || !p->is_parsable()) { 6882 if (p->klass_or_null() == NULL || !p->is_parsable()) {
6876 DEBUG_ONLY(if (!_verifying) {) 6883 DEBUG_ONLY(if (!_verifying) {)
6877 // We re-dirty the cards on which this object lies and increase 6884 // We re-dirty the cards on which this object lies and increase
6878 // the _threshold so that we'll come back to scan this object 6885 // the _threshold so that we'll come back to scan this object
6879 // during the preclean or remark phase. (CMSCleanOnEnter) 6886 // during the preclean or remark phase. (CMSCleanOnEnter)
6880 if (CMSCleanOnEnter) { 6887 if (CMSCleanOnEnter) {
6892 assert(_threshold <= end_card_addr, 6899 assert(_threshold <= end_card_addr,
6893 "Because we are just scanning into this object"); 6900 "Because we are just scanning into this object");
6894 if (_threshold < end_card_addr) { 6901 if (_threshold < end_card_addr) {
6895 _threshold = end_card_addr; 6902 _threshold = end_card_addr;
6896 } 6903 }
6897 if (p->klass() != NULL) { 6904 if (p->klass_or_null() != NULL) {
6898 // Redirty the range of cards... 6905 // Redirty the range of cards...
6899 _mut->mark_range(redirty_range); 6906 _mut->mark_range(redirty_range);
6900 } // ...else the setting of klass will dirty the card anyway. 6907 } // ...else the setting of klass will dirty the card anyway.
6901 } 6908 }
6902 DEBUG_ONLY(}) 6909 DEBUG_ONLY(})
7051 if (_bit_map->isMarked(addr+1)) { 7058 if (_bit_map->isMarked(addr+1)) {
7052 // this is an allocated object that might not yet be initialized 7059 // this is an allocated object that might not yet be initialized
7053 assert(_skip_bits == 0, "tautology"); 7060 assert(_skip_bits == 0, "tautology");
7054 _skip_bits = 2; // skip next two marked bits ("Printezis-marks") 7061 _skip_bits = 2; // skip next two marked bits ("Printezis-marks")
7055 oop p = oop(addr); 7062 oop p = oop(addr);
7056 if (p->klass() == NULL || !p->is_parsable()) { 7063 if (p->klass_or_null() == NULL || !p->is_parsable()) {
7057 // in the case of Clean-on-Enter optimization, redirty card 7064 // in the case of Clean-on-Enter optimization, redirty card
7058 // and avoid clearing card by increasing the threshold. 7065 // and avoid clearing card by increasing the threshold.
7059 return true; 7066 return true;
7060 } 7067 }
7061 } 7068 }
8032 size = pointer_delta(nextOneAddr + 1, addr); 8039 size = pointer_delta(nextOneAddr + 1, addr);
8033 assert(size == CompactibleFreeListSpace::adjustObjectSize(size), 8040 assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
8034 "alignment problem"); 8041 "alignment problem");
8035 8042
8036 #ifdef DEBUG 8043 #ifdef DEBUG
8037 if (oop(addr)->klass() != NULL && 8044 if (oop(addr)->klass_or_null() != NULL &&
8038 ( !_collector->should_unload_classes() 8045 ( !_collector->should_unload_classes()
8039 || oop(addr)->is_parsable())) { 8046 || oop(addr)->is_parsable())) {
8040 // Ignore mark word because we are running concurrent with mutators 8047 // Ignore mark word because we are running concurrent with mutators
8041 assert(oop(addr)->is_oop(true), "live block should be an oop"); 8048 assert(oop(addr)->is_oop(true), "live block should be an oop");
8042 assert(size == 8049 assert(size ==
8045 } 8052 }
8046 #endif 8053 #endif
8047 8054
8048 } else { 8055 } else {
8049 // This should be an initialized object that's alive. 8056 // This should be an initialized object that's alive.
8050 assert(oop(addr)->klass() != NULL && 8057 assert(oop(addr)->klass_or_null() != NULL &&
8051 (!_collector->should_unload_classes() 8058 (!_collector->should_unload_classes()
8052 || oop(addr)->is_parsable()), 8059 || oop(addr)->is_parsable()),
8053 "Should be an initialized object"); 8060 "Should be an initialized object");
8054 // Ignore mark word because we are running concurrent with mutators 8061 // Ignore mark word because we are running concurrent with mutators
8055 assert(oop(addr)->is_oop(true), "live block should be an oop"); 8062 assert(oop(addr)->is_oop(true), "live block should be an oop");