annotate src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp @ 17524:89152779163c

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