8250961: Move Universe::update_heap_info_at_gc to CollectedHeap
Reviewed-by: stefank, kbarrett
This commit is contained in:
parent
f78f780570
commit
6a005343b4
@ -2676,7 +2676,7 @@ void G1CollectedHeap::gc_epilogue(bool full) {
|
||||
MemoryService::track_memory_usage();
|
||||
// We have just completed a GC. Update the soft reference
|
||||
// policy with the new heap occupancy
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
// Print NUMA statistics.
|
||||
_numa->print_statistics();
|
||||
|
@ -1280,7 +1280,7 @@ void G1ConcurrentMark::compute_new_sizes() {
|
||||
|
||||
// Cleanup will have freed any regions completely full of garbage.
|
||||
// Update the soft reference policy with the new heap occupancy.
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
// We reclaimed old regions so we should calculate the sizes to make
|
||||
// sure we update the old gen/space data.
|
||||
|
@ -1043,7 +1043,7 @@ void PSParallelCompact::post_compact()
|
||||
|
||||
// Update heap occupancy information which is used as input to the soft ref
|
||||
// clearing policy at the next gc.
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
bool young_gen_empty = eden_empty && from_space->is_empty() &&
|
||||
to_space->is_empty();
|
||||
|
@ -135,7 +135,7 @@ void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_so
|
||||
|
||||
// Update heap occupancy information which is used as
|
||||
// input to soft ref clearing policy at the next gc.
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
// Signal that we have completed a visit to all live objects.
|
||||
Universe::heap()->record_whole_heap_examined_timestamp();
|
||||
|
@ -190,6 +190,8 @@ bool CollectedHeap::is_oop(oop object) const {
|
||||
|
||||
|
||||
CollectedHeap::CollectedHeap() :
|
||||
_capacity_at_last_gc(0),
|
||||
_used_at_last_gc(0),
|
||||
_is_gc_active(false),
|
||||
_last_whole_heap_examined_time_ns(os::javaTimeNanos()),
|
||||
_total_collections(0),
|
||||
@ -590,3 +592,10 @@ uint32_t CollectedHeap::hash_oop(oop obj) const {
|
||||
const uintptr_t addr = cast_from_oop<uintptr_t>(obj);
|
||||
return static_cast<uint32_t>(addr >> LogMinObjAlignment);
|
||||
}
|
||||
|
||||
// It's the caller's responsibility to ensure glitch-freedom
|
||||
// (if required).
|
||||
void CollectedHeap::update_capacity_and_used_at_gc() {
|
||||
_capacity_at_last_gc = capacity();
|
||||
_used_at_last_gc = used();
|
||||
}
|
||||
|
@ -110,6 +110,10 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||
private:
|
||||
GCHeapLog* _gc_heap_log;
|
||||
|
||||
// Historic gc information
|
||||
size_t _capacity_at_last_gc;
|
||||
size_t _used_at_last_gc;
|
||||
|
||||
protected:
|
||||
// Not used by all GCs
|
||||
MemRegion _reserved;
|
||||
@ -239,6 +243,11 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||
// Returns unused capacity.
|
||||
virtual size_t unused() const;
|
||||
|
||||
// Historic gc information
|
||||
size_t free_at_last_gc() const { return _capacity_at_last_gc - _used_at_last_gc; }
|
||||
size_t used_at_last_gc() const { return _used_at_last_gc; }
|
||||
void update_capacity_and_used_at_gc();
|
||||
|
||||
// Return "true" if the part of the heap that allocates Java
|
||||
// objects has reached the maximal committed limit that it can
|
||||
// reach, without a garbage collection.
|
||||
|
@ -35,7 +35,7 @@ LRUCurrentHeapPolicy::LRUCurrentHeapPolicy() {
|
||||
|
||||
// Capture state (of-the-VM) information needed to evaluate the policy
|
||||
void LRUCurrentHeapPolicy::setup() {
|
||||
_max_interval = (Universe::get_heap_free_at_last_gc() / M) * SoftRefLRUPolicyMSPerMB;
|
||||
_max_interval = (Universe::heap()->free_at_last_gc() / M) * SoftRefLRUPolicyMSPerMB;
|
||||
assert(_max_interval >= 0,"Sanity check");
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ LRUMaxHeapPolicy::LRUMaxHeapPolicy() {
|
||||
// Capture state (of-the-VM) information needed to evaluate the policy
|
||||
void LRUMaxHeapPolicy::setup() {
|
||||
size_t max_heap = MaxHeapSize;
|
||||
max_heap -= Universe::get_heap_used_at_last_gc();
|
||||
max_heap -= Universe::heap()->used_at_last_gc();
|
||||
max_heap /= M;
|
||||
|
||||
_max_interval = max_heap * SoftRefLRUPolicyMSPerMB;
|
||||
|
@ -237,7 +237,7 @@ void ShenandoahControlThread::run_service() {
|
||||
// Notify Universe about new heap usage. This has implications for
|
||||
// global soft refs policy, and we better report it every time heap
|
||||
// usage goes down.
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
// Signal that we have completed a visit to all live objects.
|
||||
Universe::heap()->record_whole_heap_examined_timestamp();
|
||||
|
@ -380,7 +380,7 @@ public:
|
||||
ZStatCycle::at_end(_gc_cause, boost_factor);
|
||||
|
||||
// Update data used by soft reference policy
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
|
||||
// Signal that we have completed a visit to all live objects
|
||||
Universe::heap()->record_whole_heap_examined_timestamp();
|
||||
|
@ -226,7 +226,7 @@ void ObjectSampler::add(HeapWord* obj, size_t allocated, traceid thread_id, Java
|
||||
sample->set_object((oop)obj);
|
||||
sample->set_allocated(allocated);
|
||||
sample->set_allocation_time(JfrTicks::now());
|
||||
sample->set_heap_used_at_last_gc(Universe::get_heap_used_at_last_gc());
|
||||
sample->set_heap_used_at_last_gc(Universe::heap()->used_at_last_gc());
|
||||
_priority_queue->push(sample);
|
||||
}
|
||||
|
||||
|
@ -141,9 +141,6 @@ bool Universe::_bootstrapping = false;
|
||||
bool Universe::_module_initialized = false;
|
||||
bool Universe::_fully_initialized = false;
|
||||
|
||||
size_t Universe::_heap_capacity_at_last_gc;
|
||||
size_t Universe::_heap_used_at_last_gc = 0;
|
||||
|
||||
OopStorage* Universe::_vm_weak = NULL;
|
||||
OopStorage* Universe::_vm_global = NULL;
|
||||
|
||||
@ -865,14 +862,6 @@ ReservedHeapSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
|
||||
return ReservedHeapSpace(0, 0, false);
|
||||
}
|
||||
|
||||
|
||||
// It's the caller's responsibility to ensure glitch-freedom
|
||||
// (if required).
|
||||
void Universe::update_heap_info_at_gc() {
|
||||
_heap_capacity_at_last_gc = heap()->capacity();
|
||||
_heap_used_at_last_gc = heap()->used();
|
||||
}
|
||||
|
||||
OopStorage* Universe::vm_weak() {
|
||||
return Universe::_vm_weak;
|
||||
}
|
||||
@ -1008,7 +997,7 @@ bool universe_post_init() {
|
||||
// it's an input to soft ref clearing policy.
|
||||
{
|
||||
MutexLocker x(THREAD, Heap_lock);
|
||||
Universe::update_heap_info_at_gc();
|
||||
Universe::heap()->update_capacity_and_used_at_gc();
|
||||
}
|
||||
|
||||
// ("weak") refs processing infrastructure initialization
|
||||
|
@ -162,10 +162,6 @@ class Universe: AllStatic {
|
||||
// otherwise return the given default error.
|
||||
static oop gen_out_of_memory_error(oop default_err);
|
||||
|
||||
// Historic gc information
|
||||
static size_t _heap_capacity_at_last_gc;
|
||||
static size_t _heap_used_at_last_gc;
|
||||
|
||||
static OopStorage* _vm_weak;
|
||||
static OopStorage* _vm_global;
|
||||
|
||||
@ -309,11 +305,6 @@ class Universe: AllStatic {
|
||||
// Reserve Java heap and determine CompressedOops mode
|
||||
static ReservedHeapSpace reserve_heap(size_t heap_size, size_t alignment);
|
||||
|
||||
// Historic gc information
|
||||
static size_t get_heap_free_at_last_gc() { return _heap_capacity_at_last_gc - _heap_used_at_last_gc; }
|
||||
static size_t get_heap_used_at_last_gc() { return _heap_used_at_last_gc; }
|
||||
static void update_heap_info_at_gc();
|
||||
|
||||
// Global OopStorages
|
||||
static OopStorage* vm_weak();
|
||||
static OopStorage* vm_global();
|
||||
|
Loading…
x
Reference in New Issue
Block a user