src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

duke@435 1 /*
drchase@6680 2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/parallelScavenge/asPSOldGen.hpp"
stefank@2314 27 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
stefank@2314 28 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
stefank@2314 29 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
stefank@2314 30 #include "memory/cardTableModRefBS.hpp"
stefank@2314 31 #include "oops/oop.inline.hpp"
stefank@2314 32 #include "runtime/java.hpp"
duke@435 33
duke@435 34 // Whereas PSOldGen takes the maximum size of the generation
duke@435 35 // (which doesn't change in the case of PSOldGen) as a parameter,
duke@435 36 // ASPSOldGen takes the upper limit on the size of
duke@435 37 // the generation as a parameter. In ASPSOldGen the
duke@435 38 // maximum size of the generation can change as the boundary
duke@435 39 // moves. The "maximum size of the generation" is still a valid
duke@435 40 // concept since the generation can grow and shrink within that
duke@435 41 // maximum. There are lots of useful checks that use that
duke@435 42 // maximum. In PSOldGen the method max_gen_size() returns
duke@435 43 // _max_gen_size (as set by the PSOldGen constructor). This
duke@435 44 // is how it always worked. In ASPSOldGen max_gen_size()
duke@435 45 // returned the size of the reserved space for the generation.
duke@435 46 // That can change as the boundary moves. Below the limit of
duke@435 47 // the size of the generation is passed to the PSOldGen constructor
duke@435 48 // for "_max_gen_size" (have to pass something) but it is not used later.
duke@435 49 //
duke@435 50 ASPSOldGen::ASPSOldGen(size_t initial_size,
duke@435 51 size_t min_size,
duke@435 52 size_t size_limit,
duke@435 53 const char* gen_name,
duke@435 54 int level) :
duke@435 55 PSOldGen(initial_size, min_size, size_limit, gen_name, level),
duke@435 56 _gen_size_limit(size_limit)
duke@435 57 {}
duke@435 58
duke@435 59 ASPSOldGen::ASPSOldGen(PSVirtualSpace* vs,
duke@435 60 size_t initial_size,
duke@435 61 size_t min_size,
duke@435 62 size_t size_limit,
duke@435 63 const char* gen_name,
duke@435 64 int level) :
duke@435 65 PSOldGen(initial_size, min_size, size_limit, gen_name, level),
duke@435 66 _gen_size_limit(size_limit)
duke@435 67 {
duke@435 68 _virtual_space = vs;
duke@435 69 }
duke@435 70
jmasa@5311 71 void ASPSOldGen::initialize_work(const char* perf_data_name, int level) {
jmasa@5311 72 PSOldGen::initialize_work(perf_data_name, level);
jmasa@5311 73
jmasa@5311 74 // The old gen can grow to gen_size_limit(). _reserve reflects only
jmasa@5311 75 // the current maximum that can be committed.
jmasa@5311 76 assert(_reserved.byte_size() <= gen_size_limit(), "Consistency check");
jmasa@5311 77
jmasa@5311 78 initialize_performance_counters(perf_data_name, level);
jmasa@5311 79 }
jmasa@5311 80
duke@435 81 void ASPSOldGen::reset_after_change() {
duke@435 82 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
duke@435 83 (HeapWord*)virtual_space()->high_boundary());
duke@435 84 post_resize();
duke@435 85 }
duke@435 86
duke@435 87
duke@435 88 size_t ASPSOldGen::available_for_expansion() {
duke@435 89 assert(virtual_space()->is_aligned(gen_size_limit()), "not aligned");
duke@435 90 assert(gen_size_limit() >= virtual_space()->committed_size(), "bad gen size");
duke@435 91
duke@435 92 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 93 size_t result = gen_size_limit() - virtual_space()->committed_size();
jwilhelm@6085 94 size_t result_aligned = align_size_down(result, heap->generation_alignment());
duke@435 95 return result_aligned;
duke@435 96 }
duke@435 97
duke@435 98 size_t ASPSOldGen::available_for_contraction() {
duke@435 99 size_t uncommitted_bytes = virtual_space()->uncommitted_size();
duke@435 100 if (uncommitted_bytes != 0) {
duke@435 101 return uncommitted_bytes;
duke@435 102 }
duke@435 103
duke@435 104 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
jwilhelm@6085 105 const size_t gen_alignment = heap->generation_alignment();
duke@435 106 PSAdaptiveSizePolicy* policy = heap->size_policy();
duke@435 107 const size_t working_size =
duke@435 108 used_in_bytes() + (size_t) policy->avg_promoted()->padded_average();
duke@435 109 const size_t working_aligned = align_size_up(working_size, gen_alignment);
duke@435 110 const size_t working_or_min = MAX2(working_aligned, min_gen_size());
duke@435 111 if (working_or_min > reserved().byte_size()) {
duke@435 112 // If the used or minimum gen size (aligned up) is greater
duke@435 113 // than the total reserved size, then the space available
duke@435 114 // for contraction should (after proper alignment) be 0
duke@435 115 return 0;
duke@435 116 }
duke@435 117 const size_t max_contraction =
duke@435 118 reserved().byte_size() - working_or_min;
duke@435 119
duke@435 120 // Use the "increment" fraction instead of the "decrement" fraction
duke@435 121 // to allow the other gen to expand more aggressively. The
duke@435 122 // "decrement" fraction is conservative because its intent is to
duke@435 123 // only reduce the footprint.
duke@435 124
duke@435 125 size_t result = policy->promo_increment_aligned_down(max_contraction);
duke@435 126 // Also adjust for inter-generational alignment
duke@435 127 size_t result_aligned = align_size_down(result, gen_alignment);
duke@435 128 if (PrintAdaptiveSizePolicy && Verbose) {
duke@435 129 gclog_or_tty->print_cr("\nASPSOldGen::available_for_contraction:"
drchase@6680 130 " " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX, (result_aligned/K), result_aligned);
drchase@6680 131 gclog_or_tty->print_cr(" reserved().byte_size() " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX " ",
drchase@6680 132 (reserved().byte_size()/K), reserved().byte_size());
duke@435 133 size_t working_promoted = (size_t) policy->avg_promoted()->padded_average();
drchase@6680 134 gclog_or_tty->print_cr(" padded promoted " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX,
drchase@6680 135 (working_promoted/K), working_promoted);
drchase@6680 136 gclog_or_tty->print_cr(" used " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX,
drchase@6680 137 (used_in_bytes()/K), used_in_bytes());
drchase@6680 138 gclog_or_tty->print_cr(" min_gen_size() " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX,
drchase@6680 139 (min_gen_size()/K), min_gen_size());
drchase@6680 140 gclog_or_tty->print_cr(" max_contraction " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX,
drchase@6680 141 (max_contraction/K), max_contraction);
drchase@6680 142 gclog_or_tty->print_cr(" without alignment " SSIZE_FORMAT " K / " SIZE_FORMAT_HEX,
drchase@6680 143 (policy->promo_increment(max_contraction)/K),
duke@435 144 policy->promo_increment(max_contraction));
drchase@6680 145 gclog_or_tty->print_cr(" alignment " SIZE_FORMAT_HEX, gen_alignment);
duke@435 146 }
duke@435 147 assert(result_aligned <= max_contraction, "arithmetic is wrong");
duke@435 148 return result_aligned;
duke@435 149 }

mercurial