1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,113 @@ 1.4 +/* 1.5 + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +# include "incls/_precompiled.incl" 1.29 +# include "incls/_cmsCollectorPolicy.cpp.incl" 1.30 + 1.31 +// 1.32 +// ConcurrentMarkSweepPolicy methods 1.33 +// 1.34 + 1.35 +ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() { 1.36 + initialize_all(); 1.37 +} 1.38 + 1.39 +void ConcurrentMarkSweepPolicy::initialize_generations() { 1.40 + initialize_perm_generation(PermGen::ConcurrentMarkSweep); 1.41 + _generations = new GenerationSpecPtr[number_of_generations()]; 1.42 + if (_generations == NULL) 1.43 + vm_exit_during_initialization("Unable to allocate gen spec"); 1.44 + 1.45 + if (UseParNewGC && ParallelGCThreads > 0) { 1.46 + if (UseAdaptiveSizePolicy) { 1.47 + _generations[0] = new GenerationSpec(Generation::ASParNew, 1.48 + _initial_gen0_size, _max_gen0_size); 1.49 + } else { 1.50 + _generations[0] = new GenerationSpec(Generation::ParNew, 1.51 + _initial_gen0_size, _max_gen0_size); 1.52 + } 1.53 + } else { 1.54 + _generations[0] = new GenerationSpec(Generation::DefNew, 1.55 + _initial_gen0_size, _max_gen0_size); 1.56 + } 1.57 + if (UseAdaptiveSizePolicy) { 1.58 + _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, 1.59 + _initial_gen1_size, _max_gen1_size); 1.60 + } else { 1.61 + _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, 1.62 + _initial_gen1_size, _max_gen1_size); 1.63 + } 1.64 + 1.65 + if (_generations[0] == NULL || _generations[1] == NULL) { 1.66 + vm_exit_during_initialization("Unable to allocate gen spec"); 1.67 + } 1.68 +} 1.69 + 1.70 +void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, 1.71 + size_t init_promo_size, 1.72 + size_t init_survivor_size) { 1.73 + double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; 1.74 + double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 1.75 + _size_policy = new CMSAdaptiveSizePolicy(init_eden_size, 1.76 + init_promo_size, 1.77 + init_survivor_size, 1.78 + max_gc_minor_pause_sec, 1.79 + max_gc_pause_sec, 1.80 + GCTimeRatio); 1.81 +} 1.82 + 1.83 +void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { 1.84 + // initialize the policy counters - 2 collectors, 3 generations 1.85 + if (UseParNewGC && ParallelGCThreads > 0) { 1.86 + _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3); 1.87 + } 1.88 + else { 1.89 + _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3); 1.90 + } 1.91 +} 1.92 + 1.93 +// Returns true if the incremental mode is enabled. 1.94 +bool ConcurrentMarkSweepPolicy::has_soft_ended_eden() 1.95 +{ 1.96 + return CMSIncrementalMode; 1.97 +} 1.98 + 1.99 + 1.100 +// 1.101 +// ASConcurrentMarkSweepPolicy methods 1.102 +// 1.103 + 1.104 +void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { 1.105 + 1.106 + assert(size_policy() != NULL, "A size policy is required"); 1.107 + // initialize the policy counters - 2 collectors, 3 generations 1.108 + if (UseParNewGC && ParallelGCThreads > 0) { 1.109 + _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, 1.110 + size_policy()); 1.111 + } 1.112 + else { 1.113 + _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3, 1.114 + size_policy()); 1.115 + } 1.116 +}