This commit is contained in:
Bengt Rutisson 2014-09-19 12:11:08 +00:00
commit f42eb3b19e
17 changed files with 48 additions and 48 deletions

View file

@ -4167,7 +4167,7 @@ class Par_ConcMarkingClosure: public MetadataAwareOopClosure {
// been published), so we do not need to check for // been published), so we do not need to check for
// uninitialized objects before pushing here. // uninitialized objects before pushing here.
void Par_ConcMarkingClosure::do_oop(oop obj) { void Par_ConcMarkingClosure::do_oop(oop obj) {
assert(obj->is_oop_or_null(true), "expected an oop or NULL"); assert(obj->is_oop_or_null(true), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
// Check if oop points into the CMS generation // Check if oop points into the CMS generation
// and is not marked // and is not marked
@ -7226,7 +7226,7 @@ void SurvivorSpacePrecleanClosure::do_yield_work() {
// isMarked() query is "safe". // isMarked() query is "safe".
bool ScanMarkedObjectsAgainClosure::do_object_bm(oop p, MemRegion mr) { bool ScanMarkedObjectsAgainClosure::do_object_bm(oop p, MemRegion mr) {
// Ignore mark word because we are running concurrent with mutators // Ignore mark word because we are running concurrent with mutators
assert(p->is_oop_or_null(true), "expected an oop or null"); assert(p->is_oop_or_null(true), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(p)));
HeapWord* addr = (HeapWord*)p; HeapWord* addr = (HeapWord*)p;
assert(_span.contains(addr), "we are scanning the CMS generation"); assert(_span.contains(addr), "we are scanning the CMS generation");
bool is_obj_array = false; bool is_obj_array = false;
@ -7666,7 +7666,7 @@ void PushAndMarkVerifyClosure::handle_stack_overflow(HeapWord* lost) {
} }
void PushAndMarkVerifyClosure::do_oop(oop obj) { void PushAndMarkVerifyClosure::do_oop(oop obj) {
assert(obj->is_oop_or_null(), "expected an oop or NULL"); assert(obj->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
if (_span.contains(addr) && !_verification_bm->isMarked(addr)) { if (_span.contains(addr) && !_verification_bm->isMarked(addr)) {
// Oop lies in _span and isn't yet grey or black // Oop lies in _span and isn't yet grey or black
@ -7764,7 +7764,7 @@ void Par_PushOrMarkClosure::handle_stack_overflow(HeapWord* lost) {
void PushOrMarkClosure::do_oop(oop obj) { void PushOrMarkClosure::do_oop(oop obj) {
// Ignore mark word because we are running concurrent with mutators. // Ignore mark word because we are running concurrent with mutators.
assert(obj->is_oop_or_null(true), "expected an oop or NULL"); assert(obj->is_oop_or_null(true), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
if (_span.contains(addr) && !_bitMap->isMarked(addr)) { if (_span.contains(addr) && !_bitMap->isMarked(addr)) {
// Oop lies in _span and isn't yet grey or black // Oop lies in _span and isn't yet grey or black
@ -7802,7 +7802,7 @@ void PushOrMarkClosure::do_oop(narrowOop* p) { PushOrMarkClosure::do_oop_work(p)
void Par_PushOrMarkClosure::do_oop(oop obj) { void Par_PushOrMarkClosure::do_oop(oop obj) {
// Ignore mark word because we are running concurrent with mutators. // Ignore mark word because we are running concurrent with mutators.
assert(obj->is_oop_or_null(true), "expected an oop or NULL"); assert(obj->is_oop_or_null(true), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
if (_whole_span.contains(addr) && !_bit_map->isMarked(addr)) { if (_whole_span.contains(addr) && !_bit_map->isMarked(addr)) {
// Oop lies in _span and isn't yet grey or black // Oop lies in _span and isn't yet grey or black
@ -7879,7 +7879,7 @@ void PushAndMarkClosure::do_oop(oop obj) {
// path and may be at the end of the global overflow list (so // path and may be at the end of the global overflow list (so
// the mark word may be NULL). // the mark word may be NULL).
assert(obj->is_oop_or_null(true /* ignore mark word */), assert(obj->is_oop_or_null(true /* ignore mark word */),
"expected an oop or NULL"); err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
// Check if oop points into the CMS generation // Check if oop points into the CMS generation
// and is not marked // and is not marked
@ -7959,7 +7959,7 @@ void Par_PushAndMarkClosure::do_oop(oop obj) {
// the debugger, is_oop_or_null(false) may subsequently start // the debugger, is_oop_or_null(false) may subsequently start
// to hold. // to hold.
assert(obj->is_oop_or_null(true), assert(obj->is_oop_or_null(true),
"expected an oop or NULL"); err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
HeapWord* addr = (HeapWord*)obj; HeapWord* addr = (HeapWord*)obj;
// Check if oop points into the CMS generation // Check if oop points into the CMS generation
// and is not marked // and is not marked

View file

@ -73,7 +73,7 @@ class PromotedObject VALUE_OBJ_CLASS_SPEC {
} else { } else {
res = (PromotedObject*)(_next & next_mask); res = (PromotedObject*)(_next & next_mask);
} }
assert(oop(res)->is_oop_or_null(true /* ignore mark word */), "Not an oop?"); assert(oop(res)->is_oop_or_null(true /* ignore mark word */), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(res))));
return res; return res;
} }
inline void setNext(PromotedObject* x) { inline void setNext(PromotedObject* x) {

View file

@ -277,7 +277,7 @@ inline void CMTask::deal_with_reference(oop obj) {
++_refs_reached; ++_refs_reached;
HeapWord* objAddr = (HeapWord*) obj; HeapWord* objAddr = (HeapWord*) obj;
assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); assert(obj->is_oop_or_null(true /* ignore mark word */), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
if (_g1h->is_in_g1_reserved(objAddr)) { if (_g1h->is_in_g1_reserved(objAddr)) {
assert(obj != NULL, "null check is implicit"); assert(obj != NULL, "null check is implicit");
if (!_nextMarkBitMap->isMarked(objAddr)) { if (!_nextMarkBitMap->isMarked(objAddr)) {

View file

@ -1960,15 +1960,10 @@ jint G1CollectedHeap::initialize() {
ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size, ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
heap_alignment); heap_alignment);
// It is important to do this in a way such that concurrent readers can't initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
// temporarily think something is in the heap. (I've actually seen this
// happen in asserts: DLD.)
_reserved.set_word_size(0);
_reserved.set_start((HeapWord*)heap_rs.base());
_reserved.set_end((HeapWord*)(heap_rs.base() + heap_rs.size()));
// Create the gen rem set (and barrier set) for the entire reserved region. // Create the gen rem set (and barrier set) for the entire reserved region.
_rem_set = collector_policy()->create_rem_set(_reserved, 2); _rem_set = collector_policy()->create_rem_set(reserved_region(), 2);
set_barrier_set(rem_set()->bs()); set_barrier_set(rem_set()->bs());
if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) { if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) {
vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS"); vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS");
@ -2052,7 +2047,7 @@ jint G1CollectedHeap::initialize() {
FreeRegionList::set_unrealistically_long_length(max_regions() + 1); FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
_bot_shared = new G1BlockOffsetSharedArray(_reserved, bot_storage); _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
_g1h = this; _g1h = this;

View file

@ -43,8 +43,8 @@ inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at
inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
assert(is_in_reserved(addr), assert(is_in_reserved(addr),
err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")", err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
p2i(addr), p2i(_reserved.start()), p2i(_reserved.end()))); p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())));
return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
} }
inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const { inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {

View file

@ -43,9 +43,7 @@ void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) {
_hot_cache_idx = 0; _hot_cache_idx = 0;
// For refining the cards in the hot cache in parallel // For refining the cards in the hot cache in parallel
uint n_workers = (ParallelGCThreads > 0 ? _hot_cache_par_chunk_size = (ParallelGCThreads > 0 ? ClaimChunkSize : _hot_cache_size);
_g1h->workers()->total_workers() : 1);
_hot_cache_par_chunk_size = MAX2(1, _hot_cache_size / (int)n_workers);
_hot_cache_par_claimed_idx = 0; _hot_cache_par_claimed_idx = 0;
_card_counts.initialize(card_counts_storage); _card_counts.initialize(card_counts_storage);

View file

@ -70,6 +70,9 @@ class G1HotCardCache: public CHeapObj<mtGC> {
G1CardCounts _card_counts; G1CardCounts _card_counts;
// The number of cached cards a thread claims when flushing the cache
static const int ClaimChunkSize = 32;
bool default_use_cache() const { bool default_use_cache() const {
return (G1ConcRSLogCacheSize > 0); return (G1ConcRSLogCacheSize > 0);
} }

View file

@ -288,7 +288,7 @@ void CardTableExtension::scavenge_contents_parallel(ObjectStartArray* start_arra
while (p < to) { while (p < to) {
Prefetch::write(p, interval); Prefetch::write(p, interval);
oop m = oop(p); oop m = oop(p);
assert(m->is_oop_or_null(), "check for header"); assert(m->is_oop_or_null(), err_msg("Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m)));
m->push_contents(pm); m->push_contents(pm);
p += m->size(); p += m->size();
} }
@ -296,7 +296,7 @@ void CardTableExtension::scavenge_contents_parallel(ObjectStartArray* start_arra
} else { } else {
while (p < to) { while (p < to) {
oop m = oop(p); oop m = oop(p);
assert(m->is_oop_or_null(), "check for header"); assert(m->is_oop_or_null(), err_msg("Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m)));
m->push_contents(pm); m->push_contents(pm);
p += m->size(); p += m->size();
} }

View file

@ -74,10 +74,9 @@ jint ParallelScavengeHeap::initialize() {
return JNI_ENOMEM; return JNI_ENOMEM;
} }
_reserved = MemRegion((HeapWord*)heap_rs.base(), initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
(HeapWord*)(heap_rs.base() + heap_rs.size()));
CardTableExtension* const barrier_set = new CardTableExtension(_reserved, 3); CardTableExtension* const barrier_set = new CardTableExtension(reserved_region(), 3);
barrier_set->initialize(); barrier_set->initialize();
_barrier_set = barrier_set; _barrier_set = barrier_set;
oopDesc::set_bs(_barrier_set); oopDesc::set_bs(_barrier_set);

View file

@ -2882,7 +2882,7 @@ void PSParallelCompact::update_deferred_objects(ParCompactionManager* cm,
start_array->allocate_block(addr); start_array->allocate_block(addr);
} }
oop(addr)->update_contents(cm); oop(addr)->update_contents(cm);
assert(oop(addr)->is_oop_or_null(), "should be an oop now"); assert(oop(addr)->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(addr))));
} }
} }
} }
@ -3366,7 +3366,7 @@ MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
oop moved_oop = (oop) destination(); oop moved_oop = (oop) destination();
moved_oop->update_contents(compaction_manager()); moved_oop->update_contents(compaction_manager());
assert(moved_oop->is_oop_or_null(), "Object should be whole at this point"); assert(moved_oop->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(moved_oop)));
update_state(words); update_state(words);
assert(destination() == (HeapWord*)moved_oop + moved_oop->size(), "sanity"); assert(destination() == (HeapWord*)moved_oop + moved_oop->size(), "sanity");

View file

@ -582,6 +582,14 @@ void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
} }
} }
void CollectedHeap::initialize_reserved_region(HeapWord *start, HeapWord *end) {
// It is important to do this in a way such that concurrent readers can't
// temporarily think something is in the heap. (Seen this happen in asserts.)
_reserved.set_word_size(0);
_reserved.set_start(start);
_reserved.set_end(end);
}
/////////////// Unit tests /////////////// /////////////// Unit tests ///////////////
#ifndef PRODUCT #ifndef PRODUCT

View file

@ -85,6 +85,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
friend class VMStructs; friend class VMStructs;
friend class IsGCActiveMark; // Block structured external access to _is_gc_active friend class IsGCActiveMark; // Block structured external access to _is_gc_active
private:
#ifdef ASSERT #ifdef ASSERT
static int _fire_out_of_memory_count; static int _fire_out_of_memory_count;
#endif #endif
@ -97,8 +98,9 @@ class CollectedHeap : public CHeapObj<mtInternal> {
// Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used
bool _defer_initial_card_mark; bool _defer_initial_card_mark;
protected:
MemRegion _reserved; MemRegion _reserved;
protected:
BarrierSet* _barrier_set; BarrierSet* _barrier_set;
bool _is_gc_active; bool _is_gc_active;
uint _n_par_threads; uint _n_par_threads;
@ -211,6 +213,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
// Stop any onging concurrent work and prepare for exit. // Stop any onging concurrent work and prepare for exit.
virtual void stop() {} virtual void stop() {}
void initialize_reserved_region(HeapWord *start, HeapWord *end);
MemRegion reserved_region() const { return _reserved; } MemRegion reserved_region() const { return _reserved; }
address base() const { return (address)reserved_region().start(); } address base() const { return (address)reserved_region().start(); }

View file

@ -35,7 +35,7 @@
#ifdef ASSERT #ifdef ASSERT
#define VERIFY_OOP(o_) \ #define VERIFY_OOP(o_) \
if (VerifyOops) { \ if (VerifyOops) { \
assert((oop(o_))->is_oop_or_null(), "Not an oop!"); \ assert((oop(o_))->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(o_)))); \
StubRoutines::_verify_oop_count++; \ StubRoutines::_verify_oop_count++; \
} }
#else #else

View file

@ -123,17 +123,9 @@ jint GenCollectedHeap::initialize() {
return JNI_ENOMEM; return JNI_ENOMEM;
} }
_reserved = MemRegion((HeapWord*)heap_rs.base(), initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
(HeapWord*)(heap_rs.base() + heap_rs.size()));
// It is important to do this in a way such that concurrent readers can't _rem_set = collector_policy()->create_rem_set(reserved_region(), n_covered_regions);
// temporarily think something is in the heap. (Seen this happen in asserts.)
_reserved.set_word_size(0);
_reserved.set_start((HeapWord*)heap_rs.base());
size_t actual_heap_size = heap_rs.size();
_reserved.set_end((HeapWord*)(heap_rs.base() + actual_heap_size));
_rem_set = collector_policy()->create_rem_set(_reserved, n_covered_regions);
set_barrier_set(rem_set()->bs()); set_barrier_set(rem_set()->bs());
_gch = this; _gch = this;

View file

@ -473,7 +473,7 @@ void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
_discovered_addr = java_lang_ref_Reference::discovered_addr(_ref); _discovered_addr = java_lang_ref_Reference::discovered_addr(_ref);
oop discovered = java_lang_ref_Reference::discovered(_ref); oop discovered = java_lang_ref_Reference::discovered(_ref);
assert(_discovered_addr && discovered->is_oop_or_null(), assert(_discovered_addr && discovered->is_oop_or_null(),
"discovered field is bad"); err_msg("Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered)));
_next = discovered; _next = discovered;
_referent_addr = java_lang_ref_Reference::referent_addr(_ref); _referent_addr = java_lang_ref_Reference::referent_addr(_ref);
_referent = java_lang_ref_Reference::referent(_ref); _referent = java_lang_ref_Reference::referent(_ref);
@ -482,7 +482,9 @@ void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
assert(allow_null_referent ? assert(allow_null_referent ?
_referent->is_oop_or_null() _referent->is_oop_or_null()
: _referent->is_oop(), : _referent->is_oop(),
"bad referent"); err_msg("Expected an oop%s for referent field at " PTR_FORMAT,
(allow_null_referent ? " or NULL" : ""),
p2i(_referent)));
} }
void DiscoveredListIterator::remove() { void DiscoveredListIterator::remove() {
@ -630,7 +632,7 @@ ReferenceProcessor::pp2_work_concurrent_discovery(DiscoveredList& refs_list,
oop next = java_lang_ref_Reference::next(iter.obj()); oop next = java_lang_ref_Reference::next(iter.obj());
if ((iter.referent() == NULL || iter.is_referent_alive() || if ((iter.referent() == NULL || iter.is_referent_alive() ||
next != NULL)) { next != NULL)) {
assert(next->is_oop_or_null(), "bad next field"); assert(next->is_oop_or_null(), err_msg("Expected an oop or NULL for next field at " PTR_FORMAT, p2i(next)));
// Remove Reference object from list // Remove Reference object from list
iter.remove(); iter.remove();
// Trace the cohorts // Trace the cohorts
@ -979,7 +981,7 @@ void ReferenceProcessor::clean_up_discovered_reflist(DiscoveredList& refs_list)
while (iter.has_next()) { while (iter.has_next()) {
iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */)); iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */));
oop next = java_lang_ref_Reference::next(iter.obj()); oop next = java_lang_ref_Reference::next(iter.obj());
assert(next->is_oop_or_null(), "bad next field"); assert(next->is_oop_or_null(), err_msg("Expected an oop or NULL for next field at " PTR_FORMAT, p2i(next)));
// If referent has been cleared or Reference is not active, // If referent has been cleared or Reference is not active,
// drop it. // drop it.
if (iter.referent() == NULL || next != NULL) { if (iter.referent() == NULL || next != NULL) {
@ -1172,7 +1174,7 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
HeapWord* const discovered_addr = java_lang_ref_Reference::discovered_addr(obj); HeapWord* const discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
const oop discovered = java_lang_ref_Reference::discovered(obj); const oop discovered = java_lang_ref_Reference::discovered(obj);
assert(discovered->is_oop_or_null(), "bad discovered field"); assert(discovered->is_oop_or_null(), err_msg("Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered)));
if (discovered != NULL) { if (discovered != NULL) {
// The reference has already been discovered... // The reference has already been discovered...
if (TraceReferenceGC) { if (TraceReferenceGC) {

View file

@ -722,7 +722,7 @@ void DumperSupport::dump_field_value(DumpWriter* writer, char type, address addr
// reflection and sun.misc.Unsafe classes may have a reference to a // reflection and sun.misc.Unsafe classes may have a reference to a
// Klass* so filter it out. // Klass* so filter it out.
assert(o->is_oop_or_null(), "should always be an oop"); assert(o->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(o)));
writer->write_objectID(o); writer->write_objectID(o);
break; break;
} }

View file

@ -331,7 +331,7 @@ void GenericTaskQueue<E, F, N>::oops_do(OopClosure* f) {
// index, &_elems[index], _elems[index]); // index, &_elems[index], _elems[index]);
E* t = (E*)&_elems[index]; // cast away volatility E* t = (E*)&_elems[index]; // cast away volatility
oop* p = (oop*)t; oop* p = (oop*)t;
assert((*t)->is_oop_or_null(), "Not an oop or null"); assert((*t)->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(*t)));
f->do_oop(p); f->do_oop(p);
} }
// tty->print_cr("END OopTaskQueue::oops_do"); // tty->print_cr("END OopTaskQueue::oops_do");