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