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