8284653: Serial: Inline GenCollectedHeap::collect_locked

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Albert Mingkun Yang 2022-04-12 08:00:27 +00:00
parent 9545ba7dd9
commit 4cd0921cf6
2 changed files with 11 additions and 20 deletions

View File

@ -843,28 +843,24 @@ void GenCollectedHeap::collect(GCCause::Cause cause) {
void GenCollectedHeap::collect(GCCause::Cause cause, GenerationType max_generation) {
// The caller doesn't have the Heap_lock
assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
unsigned int gc_count_before;
unsigned int full_gc_count_before;
{
MutexLocker ml(Heap_lock);
collect_locked(cause, max_generation);
}
// this is the private collection interface
// The Heap_lock is expected to be held on entry.
void GenCollectedHeap::collect_locked(GCCause::Cause cause, GenerationType max_generation) {
// Read the GC count while holding the Heap_lock
unsigned int gc_count_before = total_collections();
unsigned int full_gc_count_before = total_full_collections();
gc_count_before = total_collections();
full_gc_count_before = total_full_collections();
}
if (GCLocker::should_discard(cause, gc_count_before)) {
return;
}
{
MutexUnlocker mu(Heap_lock); // give up heap lock, execute gets it back
VM_GenCollectFull op(gc_count_before, full_gc_count_before,
cause, max_generation);
VMThread::execute(&op);
}
}
void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs) {

View File

@ -417,11 +417,6 @@ private:
void prepare_for_compaction();
#endif
// Perform a full collection of the generations up to and including max_generation.
// This is the low level interface used by the public versions of
// collect() and collect_locked(). Caller holds the Heap_lock on entry.
void collect_locked(GCCause::Cause cause, GenerationType max_generation);
// Save the tops of the spaces in all generations
void record_gen_tops_before_GC() PRODUCT_RETURN;