author | jmasa |
Fri, 01 Aug 2014 15:40:12 -0700 | |
changeset 25905 | 04a3d83cc752 |
parent 24092 | e274d864545a |
child 30173 | 13cf7580b000 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
21561
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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" |
|
1 | 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 |
ASPSOldGen::ASPSOldGen(PSVirtualSpace* vs, |
|
60 |
size_t initial_size, |
|
61 |
size_t min_size, |
|
62 |
size_t size_limit, |
|
63 |
const char* gen_name, |
|
64 |
int level) : |
|
65 |
PSOldGen(initial_size, min_size, size_limit, gen_name, level), |
|
66 |
_gen_size_limit(size_limit) |
|
67 |
{ |
|
68 |
_virtual_space = vs; |
|
69 |
} |
|
70 |
||
18443 | 71 |
void ASPSOldGen::initialize_work(const char* perf_data_name, int level) { |
72 |
PSOldGen::initialize_work(perf_data_name, level); |
|
73 |
||
74 |
// The old gen can grow to gen_size_limit(). _reserve reflects only |
|
75 |
// the current maximum that can be committed. |
|
76 |
assert(_reserved.byte_size() <= gen_size_limit(), "Consistency check"); |
|
77 |
||
78 |
initialize_performance_counters(perf_data_name, level); |
|
79 |
} |
|
80 |
||
1 | 81 |
void ASPSOldGen::reset_after_change() { |
82 |
_reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), |
|
83 |
(HeapWord*)virtual_space()->high_boundary()); |
|
84 |
post_resize(); |
|
85 |
} |
|
86 |
||
87 |
||
88 |
size_t ASPSOldGen::available_for_expansion() { |
|
89 |
assert(virtual_space()->is_aligned(gen_size_limit()), "not aligned"); |
|
90 |
assert(gen_size_limit() >= virtual_space()->committed_size(), "bad gen size"); |
|
91 |
||
92 |
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
|
93 |
size_t result = gen_size_limit() - virtual_space()->committed_size(); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
94 |
size_t result_aligned = align_size_down(result, heap->generation_alignment()); |
1 | 95 |
return result_aligned; |
96 |
} |
|
97 |
||
98 |
size_t ASPSOldGen::available_for_contraction() { |
|
99 |
size_t uncommitted_bytes = virtual_space()->uncommitted_size(); |
|
100 |
if (uncommitted_bytes != 0) { |
|
101 |
return uncommitted_bytes; |
|
102 |
} |
|
103 |
||
104 |
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
105 |
const size_t gen_alignment = heap->generation_alignment(); |
1 | 106 |
PSAdaptiveSizePolicy* policy = heap->size_policy(); |
107 |
const size_t working_size = |
|
108 |
used_in_bytes() + (size_t) policy->avg_promoted()->padded_average(); |
|
109 |
const size_t working_aligned = align_size_up(working_size, gen_alignment); |
|
110 |
const size_t working_or_min = MAX2(working_aligned, min_gen_size()); |
|
111 |
if (working_or_min > reserved().byte_size()) { |
|
112 |
// If the used or minimum gen size (aligned up) is greater |
|
113 |
// than the total reserved size, then the space available |
|
114 |
// for contraction should (after proper alignment) be 0 |
|
115 |
return 0; |
|
116 |
} |
|
117 |
const size_t max_contraction = |
|
118 |
reserved().byte_size() - working_or_min; |
|
119 |
||
120 |
// Use the "increment" fraction instead of the "decrement" fraction |
|
121 |
// to allow the other gen to expand more aggressively. The |
|
122 |
// "decrement" fraction is conservative because its intent is to |
|
123 |
// only reduce the footprint. |
|
124 |
||
125 |
size_t result = policy->promo_increment_aligned_down(max_contraction); |
|
126 |
// Also adjust for inter-generational alignment |
|
127 |
size_t result_aligned = align_size_down(result, gen_alignment); |
|
128 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
129 |
gclog_or_tty->print_cr("\nASPSOldGen::available_for_contraction:" |
|
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
130 |
" " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, result_aligned/K, result_aligned); |
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
131 |
gclog_or_tty->print_cr(" reserved().byte_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 132 |
reserved().byte_size()/K, reserved().byte_size()); |
133 |
size_t working_promoted = (size_t) policy->avg_promoted()->padded_average(); |
|
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
134 |
gclog_or_tty->print_cr(" padded promoted " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 135 |
working_promoted/K, working_promoted); |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
136 |
gclog_or_tty->print_cr(" used " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 137 |
used_in_bytes()/K, used_in_bytes()); |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
138 |
gclog_or_tty->print_cr(" min_gen_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 139 |
min_gen_size()/K, min_gen_size()); |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
140 |
gclog_or_tty->print_cr(" max_contraction " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 141 |
max_contraction/K, max_contraction); |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
142 |
gclog_or_tty->print_cr(" without alignment " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, |
1 | 143 |
policy->promo_increment(max_contraction)/K, |
144 |
policy->promo_increment(max_contraction)); |
|
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22234
diff
changeset
|
145 |
gclog_or_tty->print_cr(" alignment " SIZE_FORMAT_HEX, gen_alignment); |
1 | 146 |
} |
147 |
assert(result_aligned <= max_contraction, "arithmetic is wrong"); |
|
148 |
return result_aligned; |
|
149 |
} |