mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-29 01:00:29 +00:00
8379020: GenShen: Promote all objects when whitebox full GC is requested
Reviewed-by: ysr, kdnilsen
This commit is contained in:
parent
4e79015768
commit
e8ce930e28
@ -97,6 +97,8 @@ struct ShenandoahNoiseStats {
|
||||
// once the per-worker data is consolidated into the appropriate population vector
|
||||
// per minor collection. The _local_age_table is thus C x N, for N GC workers.
|
||||
class ShenandoahAgeCensus: public CHeapObj<mtGC> {
|
||||
friend class ShenandoahTenuringOverride;
|
||||
|
||||
AgeTable** _global_age_tables; // Global age tables used for adapting tenuring threshold, one per snapshot
|
||||
AgeTable** _local_age_tables; // Local scratch age tables to track object ages, one per worker
|
||||
|
||||
@ -148,6 +150,10 @@ class ShenandoahAgeCensus: public CHeapObj<mtGC> {
|
||||
return _tenuring_threshold[prev];
|
||||
}
|
||||
|
||||
// Override the tenuring threshold for the current epoch. This is used to
|
||||
// cause everything to be promoted for a whitebox full gc request.
|
||||
void set_tenuring_threshold(uint threshold) { _tenuring_threshold[_epoch] = threshold; }
|
||||
|
||||
#ifndef PRODUCT
|
||||
// Return the sum of size of objects of all ages recorded in the
|
||||
// census at snapshot indexed by snap.
|
||||
@ -232,4 +238,26 @@ class ShenandoahAgeCensus: public CHeapObj<mtGC> {
|
||||
void print();
|
||||
};
|
||||
|
||||
// RAII object that temporarily overrides the tenuring threshold for the
|
||||
// duration of a scope, restoring the original value on destruction.
|
||||
// Used to force promotion of all young objects during whitebox full GCs.
|
||||
class ShenandoahTenuringOverride : public StackObj {
|
||||
ShenandoahAgeCensus* _census;
|
||||
uint _saved_threshold;
|
||||
bool _active;
|
||||
public:
|
||||
ShenandoahTenuringOverride(bool active, ShenandoahAgeCensus* census) :
|
||||
_census(census), _saved_threshold(0), _active(active) {
|
||||
if (_active) {
|
||||
_saved_threshold = _census->tenuring_threshold();
|
||||
_census->set_tenuring_threshold(0);
|
||||
}
|
||||
}
|
||||
~ShenandoahTenuringOverride() {
|
||||
if (_active) {
|
||||
_census->set_tenuring_threshold(_saved_threshold);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHAGECENSUS_HPP
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gc/shenandoah/shenandoahAgeCensus.hpp"
|
||||
#include "gc/shenandoah/shenandoahAsserts.hpp"
|
||||
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
|
||||
#include "gc/shenandoah/shenandoahConcurrentGC.hpp"
|
||||
@ -271,6 +272,12 @@ void ShenandoahGenerationalControlThread::run_gc_cycle(const ShenandoahGCRequest
|
||||
// Cannot uncommit bitmap slices during concurrent reset
|
||||
ShenandoahNoUncommitMark forbid_region_uncommit(_heap);
|
||||
|
||||
// When a whitebox full GC is requested, set the tenuring threshold to zero
|
||||
// so that all young objects are promoted to old. This ensures that tests
|
||||
// using WB.fullGC() to promote objects to old gen will not loop forever.
|
||||
ShenandoahTenuringOverride tenuring_override(request.cause == GCCause::_wb_full_gc,
|
||||
_heap->age_census());
|
||||
|
||||
_heap->print_before_gc();
|
||||
switch (gc_mode()) {
|
||||
case concurrent_normal: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user