# HG changeset patch
# User tschatzl
# Parent a147722602302b6c30e9a4a8bce742e90fc74e2b
diff -r a14772260230 -r fbc34875a0cb src/hotspot/share/gc/g1/g1CollectedHeap.cpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Jun 04 15:46:26 2020 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Jun 04 15:49:02 2020 +0200
@@ -2403,6 +2403,10 @@
  return _hrm->max_length() * HeapRegion::GrainBytes; }
+size_t G1CollectedHeap::soft_max_capacity() const {
+ return clamp(align_up(SoftMaxHeapSize, HeapAlignment), MinHeapSize, max_capacity());
+}
+ jlong G1CollectedHeap::millis_since_last_gc() { // See the notes in GenCollectedHeap::millis_since_last_gc() // for more information about the implementation.

diff -r a14772260230 -r fbc34875a0cb src/hotspot/share/gc/g1/g1CollectedHeap.hpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Jun 04 15:46:26 2020 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Jun 04 15:49:02 2020 +0200
@@ -1289,6 +1289,9 @@
 // Return the size of reserved memory. Returns different value than max_capacity() when AllocateOldGenAt is used.
 virtual size_t max_reserved_capacity() const;
 + // Print the soft maximum heap capacity.
 + size_t soft_max_capacity() const;
 + virtual jlong millis_since_last_gc();

diff -r a14772260230 -r fbc34875a0cb src/hotspot/share/gc/g1/g1IHOPControl.cpp
--- a/src/hotspot/share/gc/g1/g1IHOPControl.cpp Thu Jun 04 15:46:26 2020 +0200
+++ b/src/hotspot/share/gc/g1/g1IHOPControl.cpp Thu Jun 04 15:49:02 2020 +0200
@@ -1,5 +1,5 @@
/*
 - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
 + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * * This code is free software; you can redistribute it and/or modify it
@@ -119,7 +119,7 @@
double safe_total_heap_percentage = MIN2((double)(_heap_reserve_percent + _heap_waste_percent), 100.0);
return (size_t)MIN2(
- G1CollectedHeap::heap()->max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0,
+ G1CollectedHeap::heap()->soft_max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0, _target_occupancy * (100.0 - _heap_waste_percent) / 100.0 ); } 
