8221509: Refactor assert( G1CollectedHeap::used() == recalculate_used() ) with better message
Reviewed-by: tschatzl, manc
This commit is contained in:
parent
26255c10cb
commit
cb62a78492
src/hotspot/share/gc/g1
@ -1036,7 +1036,7 @@ void G1CollectedHeap::prepare_heap_for_full_collection() {
|
||||
|
||||
void G1CollectedHeap::verify_before_full_collection(bool explicit_gc) {
|
||||
assert(!GCCause::is_user_requested_gc(gc_cause()) || explicit_gc, "invariant");
|
||||
assert(used() == recalculate_used(), "Should be equal");
|
||||
assert_used_and_recalculate_used_equal(this);
|
||||
_verifier->verify_region_sets_optional();
|
||||
_verifier->verify_before_gc(G1HeapVerifier::G1VerifyFull);
|
||||
_verifier->check_bitmaps("Full GC Start");
|
||||
@ -4539,9 +4539,7 @@ void G1CollectedHeap::rebuild_region_sets(bool free_list_only) {
|
||||
_archive_allocator->clear_used();
|
||||
}
|
||||
}
|
||||
assert(used() == recalculate_used(),
|
||||
"inconsistent used(), value: " SIZE_FORMAT " recalculated: " SIZE_FORMAT,
|
||||
used(), recalculate_used());
|
||||
assert_used_and_recalculate_used_equal(this);
|
||||
}
|
||||
|
||||
// Methods for the mutator alloc region
|
||||
|
@ -354,6 +354,15 @@ private:
|
||||
assert(Thread::current()->is_VM_thread(), "current thread is not VM thread"); \
|
||||
} while (0)
|
||||
|
||||
#define assert_used_and_recalculate_used_equal(g1h) \
|
||||
do { \
|
||||
size_t cur_used_bytes = g1h->used(); \
|
||||
size_t recal_used_bytes = g1h->recalculate_used(); \
|
||||
assert(cur_used_bytes == recal_used_bytes, "Used(" SIZE_FORMAT ") is not" \
|
||||
" same as recalculated used(" SIZE_FORMAT ").", \
|
||||
cur_used_bytes, recal_used_bytes); \
|
||||
} while (0)
|
||||
|
||||
const char* young_gc_name() const;
|
||||
|
||||
// The young region list.
|
||||
|
@ -487,10 +487,7 @@ void G1Policy::record_collection_pause_start(double start_time_sec) {
|
||||
assert(max_survivor_regions() + _g1h->num_used_regions() <= _g1h->max_regions(),
|
||||
"Maximum survivor regions %u plus used regions %u exceeds max regions %u",
|
||||
max_survivor_regions(), _g1h->num_used_regions(), _g1h->max_regions());
|
||||
|
||||
assert(_g1h->used() == _g1h->recalculate_used(),
|
||||
"sanity, used: " SIZE_FORMAT " recalculate_used: " SIZE_FORMAT,
|
||||
_g1h->used(), _g1h->recalculate_used());
|
||||
assert_used_and_recalculate_used_equal(_g1h);
|
||||
|
||||
phase_times()->record_cur_collection_start_sec(start_time_sec);
|
||||
_pending_cards = _g1h->pending_card_num();
|
||||
@ -581,8 +578,8 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_siz
|
||||
void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) {
|
||||
double end_time_sec = os::elapsedTime();
|
||||
|
||||
assert_used_and_recalculate_used_equal(_g1h);
|
||||
size_t cur_used_bytes = _g1h->used();
|
||||
assert(cur_used_bytes == _g1h->recalculate_used(), "It should!");
|
||||
bool this_pause_included_initial_mark = false;
|
||||
bool this_pause_was_young_only = collector_state()->in_young_only_phase();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user