annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @ 13060:8f07aa079343

8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking 7057939: jmap shows MaxNewSize=4GB when Java is using parallel collector Summary: Major cleanup of the collectorpolicy classes Reviewed-by: tschatzl, jcoomes
author jwilhelm
date Fri, 01 Nov 2013 17:09:38 +0100
parents f9be75d21404
children 833b0f92429a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10135
diff changeset
2 * Copyright (c) 2007, 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: 1833
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
26 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
27 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
28 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
29 #include "gc_implementation/parNew/parNewGeneration.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
30 #include "gc_implementation/shared/gcPolicyCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
31 #include "gc_implementation/shared/vmGCOperations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
32 #include "memory/cardTableRS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
33 #include "memory/collectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
34 #include "memory/gcLocker.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
35 #include "memory/genCollectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
36 #include "memory/generationSpec.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
37 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
38 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
39 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
40 #include "runtime/globals_extension.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
41 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
42 #include "runtime/java.hpp"
7180
f34d701e952e 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 6725
diff changeset
43 #include "runtime/thread.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
44 #include "runtime/vmThread.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 //
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // ConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //
a61af66fc99e Initial load
duke
parents:
diff changeset
49
13060
8f07aa079343 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 10271
diff changeset
50 void ConcurrentMarkSweepPolicy::initialize_alignments() {
8f07aa079343 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 10271
diff changeset
51 _space_alignment = _gen_alignment = (uintx)Generation::GenGrain;
8f07aa079343 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 10271
diff changeset
52 _heap_alignment = compute_heap_alignment();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void ConcurrentMarkSweepPolicy::initialize_generations() {
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10135
diff changeset
56 _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (_generations == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
58 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
59
7451
ca0a78017dc7 8005396: Use ParNew with only one thread instead of DefNew as default for CMS on single CPU machines
brutisso
parents: 7180
diff changeset
60 if (UseParNewGC) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _generations[0] = new GenerationSpec(Generation::ASParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _generations[0] = new GenerationSpec(Generation::ParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _generations[0] = new GenerationSpec(Generation::DefNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (_generations[0] == NULL || _generations[1] == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
87 size_t init_survivor_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _size_policy = new CMSAdaptiveSizePolicy(init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 max_gc_minor_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 GCTimeRatio);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // initialize the policy counters - 2 collectors, 3 generations
7451
ca0a78017dc7 8005396: Use ParNew with only one thread instead of DefNew as default for CMS on single CPU machines
brutisso
parents: 7180
diff changeset
100 if (UseParNewGC) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Returns true if the incremental mode is enabled.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 bool ConcurrentMarkSweepPolicy::has_soft_ended_eden()
a61af66fc99e Initial load
duke
parents:
diff changeset
110 {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return CMSIncrementalMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 //
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // ASConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
117 //
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 assert(size_policy() != NULL, "A size policy is required");
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // initialize the policy counters - 2 collectors, 3 generations
7451
ca0a78017dc7 8005396: Use ParNew with only one thread instead of DefNew as default for CMS on single CPU machines
brutisso
parents: 7180
diff changeset
123 if (UseParNewGC) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
125 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }