6828 // and we have been asked to abort this ongoing preclean cycle.
6829 return 0;
6830 }
6831 if (_bitMap->isMarked(addr)) {
6832 // it's marked; is it potentially uninitialized?
6833 if (p->klass_or_null() != NULL) {
6834 // an initialized object; ignore mark word in verification below
6835 // since we are running concurrent with mutators
6836 assert(p->is_oop(true), "should be an oop");
6837 if (p->is_objArray()) {
6838 // objArrays are precisely marked; restrict scanning
6839 // to dirty cards only.
6840 size = CompactibleFreeListSpace::adjustObjectSize(
6841 p->oop_iterate(_scanningClosure, mr));
6842 } else {
6843 // A non-array may have been imprecisely marked; we need
6844 // to scan object in its entirety.
6845 size = CompactibleFreeListSpace::adjustObjectSize(
6846 p->oop_iterate(_scanningClosure));
6847 }
6848 #ifdef DEBUG
6849 size_t direct_size =
6850 CompactibleFreeListSpace::adjustObjectSize(p->size());
6851 assert(size == direct_size, "Inconsistency in size");
6852 assert(size >= 3, "Necessary for Printezis marks to work");
6853 if (!_bitMap->isMarked(addr+1)) {
6854 _bitMap->verifyNoOneBitsInRange(addr+2, addr+size);
6855 } else {
6856 _bitMap->verifyNoOneBitsInRange(addr+2, addr+size-1);
6857 assert(_bitMap->isMarked(addr+size-1),
6858 "inconsistent Printezis mark");
6859 }
6860 #endif // DEBUG
6861 } else {
6862 // an unitialized object
6863 assert(_bitMap->isMarked(addr+1), "missing Printezis mark?");
6864 HeapWord* nextOneAddr = _bitMap->getNextMarkedWordAddress(addr + 2);
6865 size = pointer_delta(nextOneAddr + 1, addr);
6866 assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
6867 "alignment problem");
6868 // Note that pre-cleaning needn't redirty the card. OopDesc::set_klass()
6869 // will dirty the card when the klass pointer is installed in the
6870 // object (signalling the completion of initialization).
6871 }
6872 } else {
6873 // Either a not yet marked object or an uninitialized object
6874 if (p->klass_or_null() == NULL) {
6875 // An uninitialized object, skip to the next card, since
6876 // we may not be able to read its P-bits yet.
6877 assert(size == 0, "Initial value");
6878 } else {
6879 // An object not (yet) reached by marking: we merely need to
6880 // compute its size so as to go look at the next block.
6982 !CMSCollector::foregroundGCIsActive(); ++i) {
6983 os::sleep(Thread::current(), 1, false);
6984 ConcurrentMarkSweepThread::acknowledge_yield_request();
6985 }
6986
6987 ConcurrentMarkSweepThread::synchronize(true);
6988 _bit_map->lock()->lock_without_safepoint_check();
6989 _collector->startTimer();
6990 }
6991
6992 // This closure is used to rescan the marked objects on the dirty cards
6993 // in the mod union table and the card table proper. In the parallel
6994 // case, although the bitMap is shared, we do a single read so the
6995 // isMarked() query is "safe".
6996 bool ScanMarkedObjectsAgainClosure::do_object_bm(oop p, MemRegion mr) {
6997 // Ignore mark word because we are running concurrent with mutators
6998 assert(p->is_oop_or_null(true), "expected an oop or null");
6999 HeapWord* addr = (HeapWord*)p;
7000 assert(_span.contains(addr), "we are scanning the CMS generation");
7001 bool is_obj_array = false;
7002 #ifdef DEBUG
7003 if (!_parallel) {
7004 assert(_mark_stack->isEmpty(), "pre-condition (eager drainage)");
7005 assert(_collector->overflow_list_is_empty(),
7006 "overflow list should be empty");
7007
7008 }
7009 #endif // DEBUG
7010 if (_bit_map->isMarked(addr)) {
7011 // Obj arrays are precisely marked, non-arrays are not;
7012 // so we scan objArrays precisely and non-arrays in their
7013 // entirety.
7014 if (p->is_objArray()) {
7015 is_obj_array = true;
7016 if (_parallel) {
7017 p->oop_iterate(_par_scan_closure, mr);
7018 } else {
7019 p->oop_iterate(_scan_closure, mr);
7020 }
7021 } else {
7022 if (_parallel) {
7023 p->oop_iterate(_par_scan_closure);
7024 } else {
7025 p->oop_iterate(_scan_closure);
7026 }
7027 }
7028 }
7029 #ifdef DEBUG
7030 if (!_parallel) {
7031 assert(_mark_stack->isEmpty(), "post-condition (eager drainage)");
7032 assert(_collector->overflow_list_is_empty(),
7033 "overflow list should be empty");
7034
7035 }
7036 #endif // DEBUG
7037 return is_obj_array;
7038 }
7039
7040 MarkFromRootsClosure::MarkFromRootsClosure(CMSCollector* collector,
7041 MemRegion span,
7042 CMSBitMap* bitMap, CMSMarkStack* markStack,
7043 bool should_yield, bool verifying):
7044 _collector(collector),
7045 _span(span),
7046 _bitMap(bitMap),
7047 _mut(&collector->_modUnionTable),
7048 _markStack(markStack),
7049 _yield(should_yield),
7050 _skipBits(0)
7051 {
7052 assert(_markStack->isEmpty(), "stack should be empty");
7053 _finger = _bitMap->startWord();
7054 _threshold = _finger;
7055 assert(_collector->_restart_addr == NULL, "Sanity check");
7056 assert(_span.contains(_finger), "Out of bounds _finger?");
8227 if (inFreeRange()) {
8228 assert(freeFinger() < addr, "freeFinger points too high");
8229 flush_cur_free_chunk(freeFinger(), pointer_delta(addr, freeFinger()));
8230 }
8231
8232 // This object is live: we'd normally expect this to be
8233 // an oop, and like to assert the following:
8234 // assert(oop(addr)->is_oop(), "live block should be an oop");
8235 // However, as we commented above, this may be an object whose
8236 // header hasn't yet been initialized.
8237 size_t size;
8238 assert(_bitMap->isMarked(addr), "Tautology for this control point");
8239 if (_bitMap->isMarked(addr + 1)) {
8240 // Determine the size from the bit map, rather than trying to
8241 // compute it from the object header.
8242 HeapWord* nextOneAddr = _bitMap->getNextMarkedWordAddress(addr + 2);
8243 size = pointer_delta(nextOneAddr + 1, addr);
8244 assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
8245 "alignment problem");
8246
8247 #ifdef DEBUG
8248 if (oop(addr)->klass_or_null() != NULL) {
8249 // Ignore mark word because we are running concurrent with mutators
8250 assert(oop(addr)->is_oop(true), "live block should be an oop");
8251 assert(size ==
8252 CompactibleFreeListSpace::adjustObjectSize(oop(addr)->size()),
8253 "P-mark and computed size do not agree");
8254 }
8255 #endif
8256
8257 } else {
8258 // This should be an initialized object that's alive.
8259 assert(oop(addr)->klass_or_null() != NULL,
8260 "Should be an initialized object");
8261 // Ignore mark word because we are running concurrent with mutators
8262 assert(oop(addr)->is_oop(true), "live block should be an oop");
8263 // Verify that the bit map has no bits marked between
8264 // addr and purported end of this block.
8265 size = CompactibleFreeListSpace::adjustObjectSize(oop(addr)->size());
8266 assert(size >= 3, "Necessary for Printezis marks to work");
8267 assert(!_bitMap->isMarked(addr+1), "Tautology for this control point");
|
6828 // and we have been asked to abort this ongoing preclean cycle.
6829 return 0;
6830 }
6831 if (_bitMap->isMarked(addr)) {
6832 // it's marked; is it potentially uninitialized?
6833 if (p->klass_or_null() != NULL) {
6834 // an initialized object; ignore mark word in verification below
6835 // since we are running concurrent with mutators
6836 assert(p->is_oop(true), "should be an oop");
6837 if (p->is_objArray()) {
6838 // objArrays are precisely marked; restrict scanning
6839 // to dirty cards only.
6840 size = CompactibleFreeListSpace::adjustObjectSize(
6841 p->oop_iterate(_scanningClosure, mr));
6842 } else {
6843 // A non-array may have been imprecisely marked; we need
6844 // to scan object in its entirety.
6845 size = CompactibleFreeListSpace::adjustObjectSize(
6846 p->oop_iterate(_scanningClosure));
6847 }
6848 #ifdef ASSERT
6849 size_t direct_size =
6850 CompactibleFreeListSpace::adjustObjectSize(p->size());
6851 assert(size == direct_size, "Inconsistency in size");
6852 assert(size >= 3, "Necessary for Printezis marks to work");
6853 if (!_bitMap->isMarked(addr+1)) {
6854 _bitMap->verifyNoOneBitsInRange(addr+2, addr+size);
6855 } else {
6856 _bitMap->verifyNoOneBitsInRange(addr+2, addr+size-1);
6857 assert(_bitMap->isMarked(addr+size-1),
6858 "inconsistent Printezis mark");
6859 }
6860 #endif // ASSERT
6861 } else {
6862 // an unitialized object
6863 assert(_bitMap->isMarked(addr+1), "missing Printezis mark?");
6864 HeapWord* nextOneAddr = _bitMap->getNextMarkedWordAddress(addr + 2);
6865 size = pointer_delta(nextOneAddr + 1, addr);
6866 assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
6867 "alignment problem");
6868 // Note that pre-cleaning needn't redirty the card. OopDesc::set_klass()
6869 // will dirty the card when the klass pointer is installed in the
6870 // object (signalling the completion of initialization).
6871 }
6872 } else {
6873 // Either a not yet marked object or an uninitialized object
6874 if (p->klass_or_null() == NULL) {
6875 // An uninitialized object, skip to the next card, since
6876 // we may not be able to read its P-bits yet.
6877 assert(size == 0, "Initial value");
6878 } else {
6879 // An object not (yet) reached by marking: we merely need to
6880 // compute its size so as to go look at the next block.
6982 !CMSCollector::foregroundGCIsActive(); ++i) {
6983 os::sleep(Thread::current(), 1, false);
6984 ConcurrentMarkSweepThread::acknowledge_yield_request();
6985 }
6986
6987 ConcurrentMarkSweepThread::synchronize(true);
6988 _bit_map->lock()->lock_without_safepoint_check();
6989 _collector->startTimer();
6990 }
6991
6992 // This closure is used to rescan the marked objects on the dirty cards
6993 // in the mod union table and the card table proper. In the parallel
6994 // case, although the bitMap is shared, we do a single read so the
6995 // isMarked() query is "safe".
6996 bool ScanMarkedObjectsAgainClosure::do_object_bm(oop p, MemRegion mr) {
6997 // Ignore mark word because we are running concurrent with mutators
6998 assert(p->is_oop_or_null(true), "expected an oop or null");
6999 HeapWord* addr = (HeapWord*)p;
7000 assert(_span.contains(addr), "we are scanning the CMS generation");
7001 bool is_obj_array = false;
7002 #ifdef ASSERT
7003 if (!_parallel) {
7004 assert(_mark_stack->isEmpty(), "pre-condition (eager drainage)");
7005 assert(_collector->overflow_list_is_empty(),
7006 "overflow list should be empty");
7007
7008 }
7009 #endif // ASSERT
7010 if (_bit_map->isMarked(addr)) {
7011 // Obj arrays are precisely marked, non-arrays are not;
7012 // so we scan objArrays precisely and non-arrays in their
7013 // entirety.
7014 if (p->is_objArray()) {
7015 is_obj_array = true;
7016 if (_parallel) {
7017 p->oop_iterate(_par_scan_closure, mr);
7018 } else {
7019 p->oop_iterate(_scan_closure, mr);
7020 }
7021 } else {
7022 if (_parallel) {
7023 p->oop_iterate(_par_scan_closure);
7024 } else {
7025 p->oop_iterate(_scan_closure);
7026 }
7027 }
7028 }
7029 #ifdef ASSERT
7030 if (!_parallel) {
7031 assert(_mark_stack->isEmpty(), "post-condition (eager drainage)");
7032 assert(_collector->overflow_list_is_empty(),
7033 "overflow list should be empty");
7034
7035 }
7036 #endif // ASSERT
7037 return is_obj_array;
7038 }
7039
7040 MarkFromRootsClosure::MarkFromRootsClosure(CMSCollector* collector,
7041 MemRegion span,
7042 CMSBitMap* bitMap, CMSMarkStack* markStack,
7043 bool should_yield, bool verifying):
7044 _collector(collector),
7045 _span(span),
7046 _bitMap(bitMap),
7047 _mut(&collector->_modUnionTable),
7048 _markStack(markStack),
7049 _yield(should_yield),
7050 _skipBits(0)
7051 {
7052 assert(_markStack->isEmpty(), "stack should be empty");
7053 _finger = _bitMap->startWord();
7054 _threshold = _finger;
7055 assert(_collector->_restart_addr == NULL, "Sanity check");
7056 assert(_span.contains(_finger), "Out of bounds _finger?");
8227 if (inFreeRange()) {
8228 assert(freeFinger() < addr, "freeFinger points too high");
8229 flush_cur_free_chunk(freeFinger(), pointer_delta(addr, freeFinger()));
8230 }
8231
8232 // This object is live: we'd normally expect this to be
8233 // an oop, and like to assert the following:
8234 // assert(oop(addr)->is_oop(), "live block should be an oop");
8235 // However, as we commented above, this may be an object whose
8236 // header hasn't yet been initialized.
8237 size_t size;
8238 assert(_bitMap->isMarked(addr), "Tautology for this control point");
8239 if (_bitMap->isMarked(addr + 1)) {
8240 // Determine the size from the bit map, rather than trying to
8241 // compute it from the object header.
8242 HeapWord* nextOneAddr = _bitMap->getNextMarkedWordAddress(addr + 2);
8243 size = pointer_delta(nextOneAddr + 1, addr);
8244 assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
8245 "alignment problem");
8246
8247 #ifdef ASSERT
8248 if (oop(addr)->klass_or_null() != NULL) {
8249 // Ignore mark word because we are running concurrent with mutators
8250 assert(oop(addr)->is_oop(true), "live block should be an oop");
8251 assert(size ==
8252 CompactibleFreeListSpace::adjustObjectSize(oop(addr)->size()),
8253 "P-mark and computed size do not agree");
8254 }
8255 #endif
8256
8257 } else {
8258 // This should be an initialized object that's alive.
8259 assert(oop(addr)->klass_or_null() != NULL,
8260 "Should be an initialized object");
8261 // Ignore mark word because we are running concurrent with mutators
8262 assert(oop(addr)->is_oop(true), "live block should be an oop");
8263 // Verify that the bit map has no bits marked between
8264 // addr and purported end of this block.
8265 size = CompactibleFreeListSpace::adjustObjectSize(oop(addr)->size());
8266 assert(size >= 3, "Necessary for Printezis marks to work");
8267 assert(!_bitMap->isMarked(addr+1), "Tautology for this control point");
|