Tue, 08 Aug 2017 15:57:29 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" |
aoqi@0 | 27 | #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" |
aoqi@0 | 28 | #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" |
aoqi@0 | 29 | #include "gc_implementation/parNew/parNewGeneration.hpp" |
aoqi@0 | 30 | #include "gc_implementation/shared/gcPolicyCounters.hpp" |
aoqi@0 | 31 | #include "gc_implementation/shared/vmGCOperations.hpp" |
aoqi@0 | 32 | #include "memory/cardTableRS.hpp" |
aoqi@0 | 33 | #include "memory/collectorPolicy.hpp" |
aoqi@0 | 34 | #include "memory/gcLocker.inline.hpp" |
aoqi@0 | 35 | #include "memory/genCollectedHeap.hpp" |
aoqi@0 | 36 | #include "memory/generationSpec.hpp" |
aoqi@0 | 37 | #include "memory/space.hpp" |
aoqi@0 | 38 | #include "memory/universe.hpp" |
aoqi@0 | 39 | #include "runtime/arguments.hpp" |
aoqi@0 | 40 | #include "runtime/globals_extension.hpp" |
aoqi@0 | 41 | #include "runtime/handles.inline.hpp" |
aoqi@0 | 42 | #include "runtime/java.hpp" |
aoqi@0 | 43 | #include "runtime/thread.inline.hpp" |
aoqi@0 | 44 | #include "runtime/vmThread.hpp" |
aoqi@0 | 45 | |
aoqi@0 | 46 | // |
aoqi@0 | 47 | // ConcurrentMarkSweepPolicy methods |
aoqi@0 | 48 | // |
aoqi@0 | 49 | |
aoqi@0 | 50 | void ConcurrentMarkSweepPolicy::initialize_alignments() { |
aoqi@0 | 51 | _space_alignment = _gen_alignment = (uintx)Generation::GenGrain; |
aoqi@0 | 52 | _heap_alignment = compute_heap_alignment(); |
aoqi@0 | 53 | } |
aoqi@0 | 54 | |
aoqi@0 | 55 | void ConcurrentMarkSweepPolicy::initialize_generations() { |
aoqi@0 | 56 | _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); |
aoqi@0 | 57 | if (_generations == NULL) |
aoqi@0 | 58 | vm_exit_during_initialization("Unable to allocate gen spec"); |
aoqi@0 | 59 | |
aoqi@0 | 60 | if (UseParNewGC) { |
aoqi@0 | 61 | if (UseAdaptiveSizePolicy) { |
aoqi@0 | 62 | _generations[0] = new GenerationSpec(Generation::ASParNew, |
aoqi@0 | 63 | _initial_gen0_size, _max_gen0_size); |
aoqi@0 | 64 | } else { |
aoqi@0 | 65 | _generations[0] = new GenerationSpec(Generation::ParNew, |
aoqi@0 | 66 | _initial_gen0_size, _max_gen0_size); |
aoqi@0 | 67 | } |
aoqi@0 | 68 | } else { |
aoqi@0 | 69 | _generations[0] = new GenerationSpec(Generation::DefNew, |
aoqi@0 | 70 | _initial_gen0_size, _max_gen0_size); |
aoqi@0 | 71 | } |
aoqi@0 | 72 | if (UseAdaptiveSizePolicy) { |
aoqi@0 | 73 | _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, |
aoqi@0 | 74 | _initial_gen1_size, _max_gen1_size); |
aoqi@0 | 75 | } else { |
aoqi@0 | 76 | _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, |
aoqi@0 | 77 | _initial_gen1_size, _max_gen1_size); |
aoqi@0 | 78 | } |
aoqi@0 | 79 | |
aoqi@0 | 80 | if (_generations[0] == NULL || _generations[1] == NULL) { |
aoqi@0 | 81 | vm_exit_during_initialization("Unable to allocate gen spec"); |
aoqi@0 | 82 | } |
aoqi@0 | 83 | } |
aoqi@0 | 84 | |
aoqi@0 | 85 | void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, |
aoqi@0 | 86 | size_t init_promo_size, |
aoqi@0 | 87 | size_t init_survivor_size) { |
aoqi@0 | 88 | double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; |
aoqi@0 | 89 | double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; |
aoqi@0 | 90 | _size_policy = new CMSAdaptiveSizePolicy(init_eden_size, |
aoqi@0 | 91 | init_promo_size, |
aoqi@0 | 92 | init_survivor_size, |
aoqi@0 | 93 | max_gc_minor_pause_sec, |
aoqi@0 | 94 | max_gc_pause_sec, |
aoqi@0 | 95 | GCTimeRatio); |
aoqi@0 | 96 | } |
aoqi@0 | 97 | |
aoqi@0 | 98 | void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { |
aoqi@0 | 99 | // initialize the policy counters - 2 collectors, 3 generations |
aoqi@0 | 100 | if (UseParNewGC) { |
aoqi@0 | 101 | _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3); |
aoqi@0 | 102 | } |
aoqi@0 | 103 | else { |
aoqi@0 | 104 | _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3); |
aoqi@0 | 105 | } |
aoqi@0 | 106 | } |
aoqi@0 | 107 | |
aoqi@0 | 108 | // Returns true if the incremental mode is enabled. |
aoqi@0 | 109 | bool ConcurrentMarkSweepPolicy::has_soft_ended_eden() |
aoqi@0 | 110 | { |
aoqi@0 | 111 | return CMSIncrementalMode; |
aoqi@0 | 112 | } |
aoqi@0 | 113 | |
aoqi@0 | 114 | |
aoqi@0 | 115 | // |
aoqi@0 | 116 | // ASConcurrentMarkSweepPolicy methods |
aoqi@0 | 117 | // |
aoqi@0 | 118 | |
aoqi@0 | 119 | void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { |
aoqi@0 | 120 | |
aoqi@0 | 121 | assert(size_policy() != NULL, "A size policy is required"); |
aoqi@0 | 122 | // initialize the policy counters - 2 collectors, 3 generations |
aoqi@0 | 123 | if (UseParNewGC) { |
aoqi@0 | 124 | _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, |
aoqi@0 | 125 | size_policy()); |
aoqi@0 | 126 | } |
aoqi@0 | 127 | else { |
aoqi@0 | 128 | _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3, |
aoqi@0 | 129 | size_policy()); |
aoqi@0 | 130 | } |
aoqi@0 | 131 | } |