annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @ 6862:8a5ea0a9ccc4

7127708: G1: change task num types from int to uint in concurrent mark Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich. Reviewed-by: johnc Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author johnc
date Sat, 06 Oct 2012 01:17:44 -0700
parents da91efe96a93
children f34d701e952e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
2 * Copyright (c) 2007, 2012, 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"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
43 #include "runtime/vmThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
44 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
45 # include "thread_linux.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
46 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
47 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
48 # include "thread_solaris.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
49 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
50 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
51 # include "thread_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
52 #endif
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 1972
diff changeset
53 #ifdef TARGET_OS_FAMILY_bsd
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 1972
diff changeset
54 # include "thread_bsd.inline.hpp"
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 1972
diff changeset
55 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 //
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // ConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 initialize_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void ConcurrentMarkSweepPolicy::initialize_generations() {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _generations = new GenerationSpecPtr[number_of_generations()];
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (_generations == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
68 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
69
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
70 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _generations[0] = new GenerationSpec(Generation::ASParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _generations[0] = new GenerationSpec(Generation::ParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _generations[0] = new GenerationSpec(Generation::DefNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (_generations[0] == NULL || _generations[1] == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 size_t init_survivor_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _size_policy = new CMSAdaptiveSizePolicy(init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 max_gc_minor_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
104 max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 GCTimeRatio);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // initialize the policy counters - 2 collectors, 3 generations
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
110 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Returns true if the incremental mode is enabled.
a61af66fc99e Initial load
duke
parents:
diff changeset
119 bool ConcurrentMarkSweepPolicy::has_soft_ended_eden()
a61af66fc99e Initial load
duke
parents:
diff changeset
120 {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return CMSIncrementalMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // ASConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
127 //
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 assert(size_policy() != NULL, "A size policy is required");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // initialize the policy counters - 2 collectors, 3 generations
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
133 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
139 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }