Skip to content

Commit

Permalink
make them static
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBing committed Dec 23, 2023
1 parent 02e74bf commit cf5ccce
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void G1Allocator::reuse_retained_old_region(G1EvacInfo* evacuation_info,
}

void G1Allocator::init_gc_alloc_regions(G1EvacInfo* evacuation_info) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

_survivor_is_full = false;
_old_is_full = false;
Expand Down
17 changes: 9 additions & 8 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,16 @@ class G1CollectedHeap : public CollectedHeap {

// These are assert functions so that, if the assert fires, we get the correct
// line number, file, etc.
public:
static void assert_heap_locked() NOT_DEBUG_RETURN;
static void assert_heap_locked_or_at_safepoint(bool should_be_vm_thread) NOT_DEBUG_RETURN;
static void assert_heap_locked_and_not_at_safepoint() NOT_DEBUG_RETURN;
static void assert_heap_not_locked() NOT_DEBUG_RETURN;
static void assert_heap_not_locked_and_not_at_safepoint() NOT_DEBUG_RETURN;
static void assert_at_safepoint_on_vm_thread() NOT_DEBUG_RETURN;
static void assert_used_and_recalculate_used_equal(G1CollectedHeap* g1h) NOT_DEBUG_RETURN;

void assert_heap_locked() const NOT_DEBUG_RETURN;
void assert_heap_locked_or_at_safepoint(bool should_be_vm_thread) const NOT_DEBUG_RETURN;
void assert_heap_locked_and_not_at_safepoint() const NOT_DEBUG_RETURN;
void assert_heap_not_locked() const NOT_DEBUG_RETURN;
void assert_heap_not_locked_and_not_at_safepoint() const NOT_DEBUG_RETURN;
void assert_at_safepoint_on_vm_thread() const NOT_DEBUG_RETURN;
void assert_used_and_recalculate_used_equal() const NOT_DEBUG_RETURN;

private:
// The young region list.
G1EdenRegions _eden;
G1SurvivorRegions _survivor;
Expand Down
19 changes: 10 additions & 9 deletions src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,49 +320,50 @@ inline bool G1CollectedHeap::is_collection_set_candidate(const HeapRegion* r) co
BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()), \
BOOL_TO_STR(Thread::current()->is_VM_thread())

inline void G1CollectedHeap::assert_heap_locked() const {
inline void G1CollectedHeap::assert_heap_locked() {
assert(Heap_lock->owned_by_self(),
heap_locking_asserts_params("should be holding the Heap_lock"));
}

inline void G1CollectedHeap::
assert_heap_locked_or_at_safepoint(bool should_be_vm_thread) const {
assert_heap_locked_or_at_safepoint(bool should_be_vm_thread) {
assert(Heap_lock->owned_by_self() ||
(SafepointSynchronize::is_at_safepoint() &&
((should_be_vm_thread) == Thread::current()->is_VM_thread())),
heap_locking_asserts_params("should be holding the Heap_lock or "
"should be at a safepoint"));
}

inline void G1CollectedHeap::assert_heap_locked_and_not_at_safepoint() const {
inline void G1CollectedHeap::assert_heap_locked_and_not_at_safepoint() {
assert(Heap_lock->owned_by_self() &&
!SafepointSynchronize::is_at_safepoint(),
heap_locking_asserts_params("should be holding the Heap_lock and "
"should not be at a safepoint"));
}

inline void G1CollectedHeap::assert_heap_not_locked() const {
inline void G1CollectedHeap::assert_heap_not_locked() {
assert(!Heap_lock->owned_by_self(),
heap_locking_asserts_params("should not be holding the Heap_lock"));
}

inline void G1CollectedHeap::assert_heap_not_locked_and_not_at_safepoint() const {
inline void G1CollectedHeap::assert_heap_not_locked_and_not_at_safepoint() {
assert(!Heap_lock->owned_by_self() &&
!SafepointSynchronize::is_at_safepoint(),
heap_locking_asserts_params("should not be holding the Heap_lock and "
"should not be at a safepoint"));
}

inline void G1CollectedHeap::assert_at_safepoint_on_vm_thread() const {
inline void G1CollectedHeap::assert_at_safepoint_on_vm_thread() {
assert_at_safepoint();
assert(Thread::current_or_null() != nullptr, "no current thread");
assert(Thread::current()->is_VM_thread(), "current thread is not VM thread");
}

inline void G1CollectedHeap::assert_used_and_recalculate_used_equal() const {
inline void G1CollectedHeap::
assert_used_and_recalculate_used_equal(G1CollectedHeap* g1h) {
#if ASSERT
size_t cur_used_bytes = used();
size_t recal_used_bytes = recalculate_used();
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);
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/gc/g1/g1CollectionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ G1CollectionSet::~G1CollectionSet() {

void G1CollectionSet::init_region_lengths(uint eden_cset_region_length,
uint survivor_cset_region_length) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

_eden_region_length = eden_cset_region_length;
_survivor_region_length = survivor_cset_region_length;
Expand All @@ -96,7 +96,7 @@ void G1CollectionSet::abandon_all_candidates() {
}

void G1CollectionSet::add_old_region(HeapRegion* hr) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

assert(_inc_build_state == Active,
"Precondition, actively building cset or adding optional later on");
Expand Down Expand Up @@ -125,7 +125,7 @@ void G1CollectionSet::finalize_incremental_building() {
}

void G1CollectionSet::clear() {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();
_collection_set_cur_length = 0;
}

Expand Down Expand Up @@ -233,7 +233,7 @@ class G1VerifyYoungAgesClosure : public HeapRegionClosure {
};

bool G1CollectionSet::verify_young_ages() {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

G1VerifyYoungAgesClosure cl;
iterate(&cl);
Expand Down Expand Up @@ -502,7 +502,7 @@ class G1VerifyYoungCSetIndicesClosure : public HeapRegionClosure {
};

void G1CollectionSet::verify_young_cset_indices() const {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

G1VerifyYoungCSetIndicesClosure cl(_collection_set_cur_length);
iterate(&cl);
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ void G1ConcurrentMark::set_concurrency_and_phase(uint active_tasks, bool concurr

if (!concurrent) {
// At this point we should be in a STW phase, and completed marking.
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();
assert(out_of_regions(),
"only way to get here: _finger: " PTR_FORMAT ", _heap_end: " PTR_FORMAT,
p2i(_finger), p2i(_heap.end()));
Expand Down Expand Up @@ -791,7 +791,7 @@ void G1ConcurrentMark::cleanup_for_next_mark() {
}

void G1ConcurrentMark::clear_bitmap(WorkerThreads* workers) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();
// To avoid fragmentation the full collection requesting to clear the bitmap
// might use fewer workers than available. To ensure the bitmap is cleared
// as efficiently as possible the number of active workers are temporarily
Expand Down Expand Up @@ -864,7 +864,7 @@ G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1Concu
};

void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

G1CollectedHeap::start_codecache_marking_cycle_if_inactive(true /* concurrent_mark_start */);

Expand Down Expand Up @@ -1303,7 +1303,7 @@ class G1ObjectCountIsAliveClosure: public BoolObjectClosure {
};

void G1ConcurrentMark::remark() {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

// If a full collection has happened, we should not continue. However we might
// have ended up here as the Remark VM operation has been scheduled already.
Expand Down Expand Up @@ -1522,7 +1522,7 @@ void G1ConcurrentMark::compute_new_sizes() {
}

void G1ConcurrentMark::cleanup() {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

// If a full collection has happened, we shouldn't do this.
if (has_aborted()) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ inline bool G1ConcurrentMark::mark_in_bitmap(uint const worker_id, oop const obj
#ifndef PRODUCT
template<typename Fn>
inline void G1CMMarkStack::iterate(Fn fn) const {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

size_t num_chunks = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1HeapVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool G1HeapVerifier::should_verify(G1VerifyType type) {
}

void G1HeapVerifier::verify(VerifyOption vo) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();
assert(Heap_lock->is_locked(), "heap must be locked");

log_debug(gc, verify)("Roots");
Expand Down Expand Up @@ -422,7 +422,7 @@ class VerifyRegionListsClosure : public HeapRegionClosure {
};

void G1HeapVerifier::verify_region_sets() {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
G1CollectedHeap::assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);

// First, check the explicit lists.
_g1h->_hrm.verify();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
}

void G1MonitoringSupport::recalculate_sizes() {
assert_heap_locked_or_at_safepoint(true);
G1CollectedHeap::assert_heap_locked_or_at_safepoint(true);

MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
// Recalculate all the sizes from scratch.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void G1MonotonicArenaFreeMemoryTask::execute() {

void G1MonotonicArenaFreeMemoryTask::notify_new_stats(G1MonotonicArenaMemoryStats* young_gen_stats,
G1MonotonicArenaMemoryStats* collection_set_candidate_stats) {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

_total_used = *young_gen_stats;
_total_used.add(*collection_set_candidate_stats);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1Policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void G1Policy::record_young_collection_start() {
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_used_and_recalculate_used_equal(_g1h);
G1CollectedHeap::assert_used_and_recalculate_used_equal(_g1h);

phase_times()->record_cur_collection_start_sec(now.seconds());

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1UncommitRegionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ G1UncommitRegionTask* G1UncommitRegionTask::instance() {
}

void G1UncommitRegionTask::enqueue() {
assert_at_safepoint_on_vm_thread();
G1CollectedHeap::assert_at_safepoint_on_vm_thread();

G1UncommitRegionTask* uncommit_task = instance();
if (!uncommit_task->is_active()) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1YoungCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ void G1YoungCollector::post_evacuate_collection_set(G1EvacInfo* evacuation_info,

_evac_failure_regions.post_collection();

assert_used_and_recalculate_used_equal(_g1h);
G1CollectedHeap::assert_used_and_recalculate_used_equal(_g1h);

_g1h->rebuild_free_region_list();

Expand Down

0 comments on commit cf5ccce

Please sign in to comment.