8233822: VM_G1CollectForAllocation should always check for upgrade to full
Move upgrade check into do_collection_pause_at_safepoint. Reviewed-by: tschatzl, sangheki
This commit is contained in:
parent
73cdeafe98
commit
f262092fd9
@ -2987,6 +2987,19 @@ bool G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_collection_pause_at_safepoint_helper(target_pause_time_ms);
|
||||||
|
if (should_upgrade_to_full_gc(gc_cause())) {
|
||||||
|
log_info(gc, ergo)("Attempting maximally compacting collection");
|
||||||
|
bool result = do_full_collection(false /* explicit gc */,
|
||||||
|
true /* clear_all_soft_refs */);
|
||||||
|
// do_full_collection only fails if blocked by GC locker, but
|
||||||
|
// we've already checked for that above.
|
||||||
|
assert(result, "invariant");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_pause_time_ms) {
|
||||||
GCIdMark gc_id_mark;
|
GCIdMark gc_id_mark;
|
||||||
|
|
||||||
SvcGCMarker sgcm(SvcGCMarker::MINOR);
|
SvcGCMarker sgcm(SvcGCMarker::MINOR);
|
||||||
@ -3174,8 +3187,6 @@ bool G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_
|
|||||||
// itself is released in SuspendibleThreadSet::desynchronize().
|
// itself is released in SuspendibleThreadSet::desynchronize().
|
||||||
do_concurrent_mark();
|
do_concurrent_mark();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void G1CollectedHeap::remove_self_forwarding_pointers(G1RedirtyCardsQueueSet* rdcqs) {
|
void G1CollectedHeap::remove_self_forwarding_pointers(G1RedirtyCardsQueueSet* rdcqs) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -757,11 +757,18 @@ private:
|
|||||||
|
|
||||||
void wait_for_root_region_scanning();
|
void wait_for_root_region_scanning();
|
||||||
|
|
||||||
// The guts of the incremental collection pause, executed by the vm
|
// Perform an incremental collection at a safepoint, possibly
|
||||||
// thread. It returns false if it is unable to do the collection due
|
// followed by a by-policy upgrade to a full collection. Returns
|
||||||
// to the GC locker being active, true otherwise
|
// false if unable to do the collection due to the GC locker being
|
||||||
|
// active, true otherwise.
|
||||||
|
// precondition: at safepoint on VM thread
|
||||||
|
// precondition: !is_gc_active()
|
||||||
bool do_collection_pause_at_safepoint(double target_pause_time_ms);
|
bool do_collection_pause_at_safepoint(double target_pause_time_ms);
|
||||||
|
|
||||||
|
// Helper for do_collection_pause_at_safepoint, containing the guts
|
||||||
|
// of the incremental collection pause, executed by the vm thread.
|
||||||
|
void do_collection_pause_at_safepoint_helper(double target_pause_time_ms);
|
||||||
|
|
||||||
G1HeapVerifier::G1VerifyType young_collection_verify_type() const;
|
G1HeapVerifier::G1VerifyType young_collection_verify_type() const;
|
||||||
void verify_before_young_collection(G1HeapVerifier::G1VerifyType type);
|
void verify_before_young_collection(G1HeapVerifier::G1VerifyType type);
|
||||||
void verify_after_young_collection(G1HeapVerifier::G1VerifyType type);
|
void verify_after_young_collection(G1HeapVerifier::G1VerifyType type);
|
||||||
|
@ -82,20 +82,14 @@ void VM_G1TryInitiateConcMark::doit() {
|
|||||||
// there is already a concurrent marking cycle in progress. Set flag
|
// there is already a concurrent marking cycle in progress. Set flag
|
||||||
// to notify the caller and return immediately.
|
// to notify the caller and return immediately.
|
||||||
_cycle_already_in_progress = true;
|
_cycle_already_in_progress = true;
|
||||||
} else if (!g1h->do_collection_pause_at_safepoint(_target_pause_time_ms)) {
|
} else if (g1h->do_collection_pause_at_safepoint(_target_pause_time_ms)) {
|
||||||
|
_gc_succeeded = true;
|
||||||
|
} else {
|
||||||
// Failure to perform the collection at all occurs because GCLocker is
|
// Failure to perform the collection at all occurs because GCLocker is
|
||||||
// active, and we have the bad luck to be the collection request that
|
// active, and we have the bad luck to be the collection request that
|
||||||
// makes a later _gc_locker collection needed. (Else we would have hit
|
// makes a later _gc_locker collection needed. (Else we would have hit
|
||||||
// the GCLocker check in the prologue.)
|
// the GCLocker check in the prologue.)
|
||||||
_transient_failure = true;
|
_transient_failure = true;
|
||||||
} else if (g1h->should_upgrade_to_full_gc(_gc_cause)) {
|
|
||||||
// GC ran, but we're still in trouble and need a full GC.
|
|
||||||
log_info(gc, ergo)("Attempting maximally compacting collection");
|
|
||||||
_gc_succeeded = g1h->do_full_collection(false, /* explicit gc */
|
|
||||||
true /* clear_all_soft_refs */);
|
|
||||||
guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed");
|
|
||||||
} else {
|
|
||||||
_gc_succeeded = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,20 +126,10 @@ void VM_G1CollectForAllocation::doit() {
|
|||||||
// Try a partial collection of some kind.
|
// Try a partial collection of some kind.
|
||||||
_gc_succeeded = g1h->do_collection_pause_at_safepoint(_target_pause_time_ms);
|
_gc_succeeded = g1h->do_collection_pause_at_safepoint(_target_pause_time_ms);
|
||||||
|
|
||||||
if (_gc_succeeded) {
|
if (_gc_succeeded && (_word_size > 0)) {
|
||||||
if (_word_size > 0) {
|
// An allocation had been requested. Do it, eventually trying a stronger
|
||||||
// An allocation had been requested. Do it, eventually trying a stronger
|
// kind of GC.
|
||||||
// kind of GC.
|
_result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded);
|
||||||
_result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded);
|
|
||||||
} else if (g1h->should_upgrade_to_full_gc(_gc_cause)) {
|
|
||||||
// There has been a request to perform a GC to free some space. We have no
|
|
||||||
// information on how much memory has been asked for. In case there are
|
|
||||||
// absolutely no regions left to allocate into, do a maximally compacting full GC.
|
|
||||||
log_info(gc, ergo)("Attempting maximally compacting collection");
|
|
||||||
_gc_succeeded = g1h->do_full_collection(false, /* explicit gc */
|
|
||||||
true /* clear_all_soft_refs */);
|
|
||||||
}
|
|
||||||
guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
#include "gc/shared/gcVMOperations.hpp"
|
#include "gc/shared/gcVMOperations.hpp"
|
||||||
|
|
||||||
// VM_operations for the G1 collector.
|
// VM_operations for the G1 collector.
|
||||||
// VM_GC_Operation:
|
|
||||||
// - VM_G1Concurrent
|
|
||||||
// - VM_G1CollectForAllocation
|
|
||||||
// - VM_G1CollectFull
|
|
||||||
|
|
||||||
class VM_G1CollectFull : public VM_GC_Operation {
|
class VM_G1CollectFull : public VM_GC_Operation {
|
||||||
bool _gc_succeeded;
|
bool _gc_succeeded;
|
||||||
|
Loading…
Reference in New Issue
Block a user