Skip to content

Commit

Permalink
8255131: G1CollectedHeap::is_in() returns wrong result
Browse files Browse the repository at this point in the history
Reviewed-by: sjohanss, kbarrett, ayang
  • Loading branch information
Thomas Schatzl committed Oct 23, 2020
1 parent 107fb9c commit c520469
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
Expand Up @@ -60,7 +60,7 @@ void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {
assert((index) < (_reserved.word_size() >> BOTConstants::LogN_words),
"%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT,
msg, (index), (_reserved.word_size() >> BOTConstants::LogN_words));
assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)),
assert(G1CollectedHeap::heap()->is_in(address_for_index_raw(index)),
"Index " SIZE_FORMAT " corresponding to " PTR_FORMAT
" (%u) is not in committed area.",
(index),
Expand Down
22 changes: 1 addition & 21 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Expand Up @@ -2260,29 +2260,9 @@ bool G1CollectedHeap::try_collect(GCCause::Cause cause) {
}

bool G1CollectedHeap::is_in(const void* p) const {
if (_hrm->reserved().contains(p)) {
// Given that we know that p is in the reserved space,
// heap_region_containing() should successfully
// return the containing region.
HeapRegion* hr = heap_region_containing(p);
return hr->is_in(p);
} else {
return false;
}
return is_in_reserved(p) && _hrm->is_available(addr_to_region((HeapWord*)p));
}

#ifdef ASSERT
bool G1CollectedHeap::is_in_exact(const void* p) const {
bool contains = reserved().contains(p);
bool available = _hrm->is_available(addr_to_region((HeapWord*)p));
if (contains && available) {
return true;
} else {
return false;
}
}
#endif

// Iteration functions.

// Iterates an ObjectClosure over all objects within a HeapRegion.
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Expand Up @@ -1136,11 +1136,6 @@ class G1CollectedHeap : public CollectedHeap {
void decrement_summary_bytes(size_t bytes);

virtual bool is_in(const void* p) const;
#ifdef ASSERT
// Returns whether p is in one of the available areas of the heap. Slow but
// extensive version.
bool is_in_exact(const void* p) const;
#endif

// Return "TRUE" iff the given object address is within the collection
// set. Assumes that the reference points into the heap.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp
Expand Up @@ -51,7 +51,7 @@ void G1CMBitMap::clear_region(HeapRegion* region) {

#ifdef ASSERT
void G1CMBitMap::check_mark(HeapWord* addr) {
assert(G1CollectedHeap::heap()->is_in_exact(addr),
assert(G1CollectedHeap::heap()->is_in(addr),
"Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
p2i(this), p2i(addr));
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1RemSet.cpp
Expand Up @@ -1304,7 +1304,7 @@ void G1RemSet::cleanup_after_scan_heap_roots() {
inline void check_card_ptr(CardTable::CardValue* card_ptr, G1CardTable* ct) {
#ifdef ASSERT
G1CollectedHeap* g1h = G1CollectedHeap::heap();
assert(g1h->is_in_exact(ct->addr_for(card_ptr)),
assert(g1h->is_in(ct->addr_for(card_ptr)),
"Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap",
p2i(card_ptr),
ct->index_for(ct->addr_for(card_ptr)),
Expand Down

1 comment on commit c520469

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on c520469 Oct 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.