Skip to content

Commit

Permalink
use 'ASSERT' and fix include statement
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBing committed Dec 23, 2023
1 parent 6a18b09 commit 75f3010
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
25 changes: 9 additions & 16 deletions src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,61 +320,54 @@ 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())

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

DEBUG_ONLY(
inline void G1CollectedHeap::
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"));
})
}

DEBUG_ONLY(
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"));
})
}

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

DEBUG_ONLY(
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"));
})
}

DEBUG_ONLY(
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");
})
}

DEBUG_ONLY(
inline void G1CollectedHeap::
assert_used_and_recalculate_used_equal(G1CollectedHeap* g1h) {
#ifdef ASSERT
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);
#endif
})
}
#endif // ASSERT

#endif // SHARE_GC_G1_G1COLLECTEDHEAP_INLINE_HPP
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 @@ -25,7 +25,7 @@
#include "precompiled.hpp"
#include "ci/ciUtilities.hpp"
#include "gc/g1/g1CardSetMemory.inline.hpp"
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
#include "gc/g1/g1_globals.hpp"
Expand Down

0 comments on commit 75f3010

Please sign in to comment.