duke@435: /* jmasa@2188: * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" stefank@2314: #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" stefank@2314: #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" stefank@2314: #include "gc_implementation/parNew/parNewGeneration.hpp" stefank@2314: #include "gc_implementation/shared/gcPolicyCounters.hpp" stefank@2314: #include "gc_implementation/shared/vmGCOperations.hpp" stefank@2314: #include "memory/cardTableRS.hpp" stefank@2314: #include "memory/collectorPolicy.hpp" stefank@2314: #include "memory/gcLocker.inline.hpp" stefank@2314: #include "memory/genCollectedHeap.hpp" stefank@2314: #include "memory/generationSpec.hpp" stefank@2314: #include "memory/space.hpp" stefank@2314: #include "memory/universe.hpp" stefank@2314: #include "runtime/arguments.hpp" stefank@2314: #include "runtime/globals_extension.hpp" stefank@2314: #include "runtime/handles.inline.hpp" stefank@2314: #include "runtime/java.hpp" stefank@2314: #include "runtime/vmThread.hpp" stefank@2314: #ifdef TARGET_OS_FAMILY_linux stefank@2314: # include "thread_linux.inline.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_OS_FAMILY_solaris stefank@2314: # include "thread_solaris.inline.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_OS_FAMILY_windows stefank@2314: # include "thread_windows.inline.hpp" stefank@2314: #endif duke@435: duke@435: // duke@435: // ConcurrentMarkSweepPolicy methods duke@435: // duke@435: duke@435: ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() { duke@435: initialize_all(); duke@435: } duke@435: duke@435: void ConcurrentMarkSweepPolicy::initialize_generations() { duke@435: initialize_perm_generation(PermGen::ConcurrentMarkSweep); duke@435: _generations = new GenerationSpecPtr[number_of_generations()]; duke@435: if (_generations == NULL) duke@435: vm_exit_during_initialization("Unable to allocate gen spec"); duke@435: jmasa@2188: if (ParNewGeneration::in_use()) { duke@435: if (UseAdaptiveSizePolicy) { duke@435: _generations[0] = new GenerationSpec(Generation::ASParNew, duke@435: _initial_gen0_size, _max_gen0_size); duke@435: } else { duke@435: _generations[0] = new GenerationSpec(Generation::ParNew, duke@435: _initial_gen0_size, _max_gen0_size); duke@435: } duke@435: } else { duke@435: _generations[0] = new GenerationSpec(Generation::DefNew, duke@435: _initial_gen0_size, _max_gen0_size); duke@435: } duke@435: if (UseAdaptiveSizePolicy) { duke@435: _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, duke@435: _initial_gen1_size, _max_gen1_size); duke@435: } else { duke@435: _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, duke@435: _initial_gen1_size, _max_gen1_size); duke@435: } duke@435: duke@435: if (_generations[0] == NULL || _generations[1] == NULL) { duke@435: vm_exit_during_initialization("Unable to allocate gen spec"); duke@435: } duke@435: } duke@435: duke@435: void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, duke@435: size_t init_promo_size, duke@435: size_t init_survivor_size) { duke@435: double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; duke@435: double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; duke@435: _size_policy = new CMSAdaptiveSizePolicy(init_eden_size, duke@435: init_promo_size, duke@435: init_survivor_size, duke@435: max_gc_minor_pause_sec, duke@435: max_gc_pause_sec, duke@435: GCTimeRatio); duke@435: } duke@435: duke@435: void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { duke@435: // initialize the policy counters - 2 collectors, 3 generations jmasa@2188: if (ParNewGeneration::in_use()) { duke@435: _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3); duke@435: } duke@435: else { duke@435: _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3); duke@435: } duke@435: } duke@435: duke@435: // Returns true if the incremental mode is enabled. duke@435: bool ConcurrentMarkSweepPolicy::has_soft_ended_eden() duke@435: { duke@435: return CMSIncrementalMode; duke@435: } duke@435: duke@435: duke@435: // duke@435: // ASConcurrentMarkSweepPolicy methods duke@435: // duke@435: duke@435: void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { duke@435: duke@435: assert(size_policy() != NULL, "A size policy is required"); duke@435: // initialize the policy counters - 2 collectors, 3 generations jmasa@2188: if (ParNewGeneration::in_use()) { duke@435: _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, duke@435: size_policy()); duke@435: } duke@435: else { duke@435: _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3, duke@435: size_policy()); duke@435: } duke@435: }