Wed, 26 Jun 2013 16:58:37 +0200
8013590: NPG: Add a memory pool MXBean for Metaspace
Reviewed-by: jmasa, mgerdin
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
coleenp@4037 | 26 | #include "memory/binaryTreeDictionary.hpp" |
stefank@2314 | 27 | #include "memory/defNewGeneration.hpp" |
stefank@2314 | 28 | #include "memory/filemap.hpp" |
stefank@2314 | 29 | #include "memory/genRemSet.hpp" |
stefank@2314 | 30 | #include "memory/generationSpec.hpp" |
stefank@2314 | 31 | #include "memory/tenuredGeneration.hpp" |
stefank@2314 | 32 | #include "runtime/java.hpp" |
jprovino@4542 | 33 | #include "utilities/macros.hpp" |
jprovino@4542 | 34 | #if INCLUDE_ALL_GCS |
stefank@2314 | 35 | #include "gc_implementation/parNew/asParNewGeneration.hpp" |
coleenp@4037 | 36 | #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" |
stefank@2314 | 37 | #include "gc_implementation/parNew/parNewGeneration.hpp" |
jprovino@4542 | 38 | #endif // INCLUDE_ALL_GCS |
duke@435 | 39 | |
duke@435 | 40 | Generation* GenerationSpec::init(ReservedSpace rs, int level, |
duke@435 | 41 | GenRemSet* remset) { |
duke@435 | 42 | switch (name()) { |
duke@435 | 43 | case Generation::DefNew: |
duke@435 | 44 | return new DefNewGeneration(rs, init_size(), level); |
duke@435 | 45 | |
duke@435 | 46 | case Generation::MarkSweepCompact: |
duke@435 | 47 | return new TenuredGeneration(rs, init_size(), level, remset); |
duke@435 | 48 | |
jprovino@4542 | 49 | #if INCLUDE_ALL_GCS |
duke@435 | 50 | case Generation::ParNew: |
duke@435 | 51 | return new ParNewGeneration(rs, init_size(), level); |
duke@435 | 52 | |
duke@435 | 53 | case Generation::ASParNew: |
duke@435 | 54 | return new ASParNewGeneration(rs, |
duke@435 | 55 | init_size(), |
duke@435 | 56 | init_size() /* min size */, |
duke@435 | 57 | level); |
duke@435 | 58 | |
duke@435 | 59 | case Generation::ConcurrentMarkSweep: { |
duke@435 | 60 | assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); |
duke@435 | 61 | CardTableRS* ctrs = remset->as_CardTableRS(); |
duke@435 | 62 | if (ctrs == NULL) { |
duke@435 | 63 | vm_exit_during_initialization("Rem set incompatibility."); |
duke@435 | 64 | } |
duke@435 | 65 | // Otherwise |
duke@435 | 66 | // The constructor creates the CMSCollector if needed, |
duke@435 | 67 | // else registers with an existing CMSCollector |
duke@435 | 68 | |
duke@435 | 69 | ConcurrentMarkSweepGeneration* g = NULL; |
duke@435 | 70 | g = new ConcurrentMarkSweepGeneration(rs, |
duke@435 | 71 | init_size(), level, ctrs, UseCMSAdaptiveFreeLists, |
jmasa@3730 | 72 | (FreeBlockDictionary<FreeChunk>::DictionaryChoice)CMSDictionaryChoice); |
duke@435 | 73 | |
duke@435 | 74 | g->initialize_performance_counters(); |
duke@435 | 75 | |
duke@435 | 76 | return g; |
duke@435 | 77 | } |
duke@435 | 78 | |
duke@435 | 79 | case Generation::ASConcurrentMarkSweep: { |
duke@435 | 80 | assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); |
duke@435 | 81 | CardTableRS* ctrs = remset->as_CardTableRS(); |
duke@435 | 82 | if (ctrs == NULL) { |
duke@435 | 83 | vm_exit_during_initialization("Rem set incompatibility."); |
duke@435 | 84 | } |
duke@435 | 85 | // Otherwise |
duke@435 | 86 | // The constructor creates the CMSCollector if needed, |
duke@435 | 87 | // else registers with an existing CMSCollector |
duke@435 | 88 | |
duke@435 | 89 | ASConcurrentMarkSweepGeneration* g = NULL; |
duke@435 | 90 | g = new ASConcurrentMarkSweepGeneration(rs, |
duke@435 | 91 | init_size(), level, ctrs, UseCMSAdaptiveFreeLists, |
jmasa@3730 | 92 | (FreeBlockDictionary<FreeChunk>::DictionaryChoice)CMSDictionaryChoice); |
duke@435 | 93 | |
duke@435 | 94 | g->initialize_performance_counters(); |
duke@435 | 95 | |
duke@435 | 96 | return g; |
duke@435 | 97 | } |
jprovino@4542 | 98 | #endif // INCLUDE_ALL_GCS |
duke@435 | 99 | |
duke@435 | 100 | default: |
duke@435 | 101 | guarantee(false, "unrecognized GenerationName"); |
duke@435 | 102 | return NULL; |
duke@435 | 103 | } |
duke@435 | 104 | } |