1 /* 2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 # include "incls/_precompiled.incl" 26 # include "incls/_cmsCollectorPolicy.cpp.incl" 27 28 // 29 // ConcurrentMarkSweepPolicy methods 30 // 31 32 ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() { 33 initialize_all(); 34 } 35 36 void ConcurrentMarkSweepPolicy::initialize_generations() { 37 initialize_perm_generation(PermGen::ConcurrentMarkSweep); 38 _generations = new GenerationSpecPtr[number_of_generations()]; 39 if (_generations == NULL) 40 vm_exit_during_initialization("Unable to allocate gen spec"); 41 42 if (ParNewGeneration::in_use()) { 43 if (UseAdaptiveSizePolicy) { 44 _generations[0] = new GenerationSpec(Generation::ASParNew, 45 _initial_gen0_size, _max_gen0_size); 46 } else { 47 _generations[0] = new GenerationSpec(Generation::ParNew, 48 _initial_gen0_size, _max_gen0_size); 49 } 50 } else { 51 _generations[0] = new GenerationSpec(Generation::DefNew, 52 _initial_gen0_size, _max_gen0_size); 53 } 54 if (UseAdaptiveSizePolicy) { 55 _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, 56 _initial_gen1_size, _max_gen1_size); 57 } else { 58 _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, 59 _initial_gen1_size, _max_gen1_size); 60 } 61 62 if (_generations[0] == NULL || _generations[1] == NULL) { 63 vm_exit_during_initialization("Unable to allocate gen spec"); 64 } 65 } 66 67 void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, 68 size_t init_promo_size, 69 size_t init_survivor_size) { 70 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; 71 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 72 _size_policy = new CMSAdaptiveSizePolicy(init_eden_size, 73 init_promo_size, 74 init_survivor_size, 75 max_gc_minor_pause_sec, 76 max_gc_pause_sec, 77 GCTimeRatio); 78 } 79 80 void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { 81 // initialize the policy counters - 2 collectors, 3 generations 82 if (ParNewGeneration::in_use()) { 83 _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3); 84 } 85 else { 86 _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3); 87 } 88 } 89 90 // Returns true if the incremental mode is enabled. 91 bool ConcurrentMarkSweepPolicy::has_soft_ended_eden() 92 { 93 return CMSIncrementalMode; 94 } 95 96 97 // 98 // ASConcurrentMarkSweepPolicy methods 99 // 100 101 void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { 102 103 assert(size_policy() != NULL, "A size policy is required"); 104 // initialize the policy counters - 2 collectors, 3 generations 105 if (ParNewGeneration::in_use()) { 106 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, 107 size_policy()); 108 } 109 else { 110 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3, 111 size_policy()); 112 } 113 }