src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,131 @@
     1.4 +/*
     1.5 + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
    1.30 +#include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
    1.31 +#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
    1.32 +#include "gc_implementation/parNew/parNewGeneration.hpp"
    1.33 +#include "gc_implementation/shared/gcPolicyCounters.hpp"
    1.34 +#include "gc_implementation/shared/vmGCOperations.hpp"
    1.35 +#include "memory/cardTableRS.hpp"
    1.36 +#include "memory/collectorPolicy.hpp"
    1.37 +#include "memory/gcLocker.inline.hpp"
    1.38 +#include "memory/genCollectedHeap.hpp"
    1.39 +#include "memory/generationSpec.hpp"
    1.40 +#include "memory/space.hpp"
    1.41 +#include "memory/universe.hpp"
    1.42 +#include "runtime/arguments.hpp"
    1.43 +#include "runtime/globals_extension.hpp"
    1.44 +#include "runtime/handles.inline.hpp"
    1.45 +#include "runtime/java.hpp"
    1.46 +#include "runtime/thread.inline.hpp"
    1.47 +#include "runtime/vmThread.hpp"
    1.48 +
    1.49 +//
    1.50 +// ConcurrentMarkSweepPolicy methods
    1.51 +//
    1.52 +
    1.53 +void ConcurrentMarkSweepPolicy::initialize_alignments() {
    1.54 +  _space_alignment = _gen_alignment = (uintx)Generation::GenGrain;
    1.55 +  _heap_alignment = compute_heap_alignment();
    1.56 +}
    1.57 +
    1.58 +void ConcurrentMarkSweepPolicy::initialize_generations() {
    1.59 +  _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL);
    1.60 +  if (_generations == NULL)
    1.61 +    vm_exit_during_initialization("Unable to allocate gen spec");
    1.62 +
    1.63 +  if (UseParNewGC) {
    1.64 +    if (UseAdaptiveSizePolicy) {
    1.65 +      _generations[0] = new GenerationSpec(Generation::ASParNew,
    1.66 +                                           _initial_gen0_size, _max_gen0_size);
    1.67 +    } else {
    1.68 +      _generations[0] = new GenerationSpec(Generation::ParNew,
    1.69 +                                           _initial_gen0_size, _max_gen0_size);
    1.70 +    }
    1.71 +  } else {
    1.72 +    _generations[0] = new GenerationSpec(Generation::DefNew,
    1.73 +                                         _initial_gen0_size, _max_gen0_size);
    1.74 +  }
    1.75 +  if (UseAdaptiveSizePolicy) {
    1.76 +    _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep,
    1.77 +                            _initial_gen1_size, _max_gen1_size);
    1.78 +  } else {
    1.79 +    _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
    1.80 +                            _initial_gen1_size, _max_gen1_size);
    1.81 +  }
    1.82 +
    1.83 +  if (_generations[0] == NULL || _generations[1] == NULL) {
    1.84 +    vm_exit_during_initialization("Unable to allocate gen spec");
    1.85 +  }
    1.86 +}
    1.87 +
    1.88 +void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
    1.89 +                                               size_t init_promo_size,
    1.90 +                                               size_t init_survivor_size) {
    1.91 +  double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
    1.92 +  double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
    1.93 +  _size_policy = new CMSAdaptiveSizePolicy(init_eden_size,
    1.94 +                                           init_promo_size,
    1.95 +                                           init_survivor_size,
    1.96 +                                           max_gc_minor_pause_sec,
    1.97 +                                           max_gc_pause_sec,
    1.98 +                                           GCTimeRatio);
    1.99 +}
   1.100 +
   1.101 +void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
   1.102 +  // initialize the policy counters - 2 collectors, 3 generations
   1.103 +  if (UseParNewGC) {
   1.104 +    _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
   1.105 +  }
   1.106 +  else {
   1.107 +    _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3);
   1.108 +  }
   1.109 +}
   1.110 +
   1.111 +// Returns true if the incremental mode is enabled.
   1.112 +bool ConcurrentMarkSweepPolicy::has_soft_ended_eden()
   1.113 +{
   1.114 +  return CMSIncrementalMode;
   1.115 +}
   1.116 +
   1.117 +
   1.118 +//
   1.119 +// ASConcurrentMarkSweepPolicy methods
   1.120 +//
   1.121 +
   1.122 +void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
   1.123 +
   1.124 +  assert(size_policy() != NULL, "A size policy is required");
   1.125 +  // initialize the policy counters - 2 collectors, 3 generations
   1.126 +  if (UseParNewGC) {
   1.127 +    _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3,
   1.128 +      size_policy());
   1.129 +  }
   1.130 +  else {
   1.131 +    _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3,
   1.132 +      size_policy());
   1.133 +  }
   1.134 +}

mercurial