src/share/vm/memory/metaspaceCounters.cpp

Tue, 16 Feb 2016 21:42:29 +0000

author
poonam
date
Tue, 16 Feb 2016 21:42:29 +0000
changeset 8308
6acf14e730dd
parent 6609
270d7cb38f40
child 6876
710a3c8b516e
permissions
-rw-r--r--

8072725: Provide more granular levels for GC verification
Summary: Add option VerifySubSet to selectively verify the memory sub-systems
Reviewed-by: kevinw, jmasa

coleenp@4037 1 /*
mikael@6198 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
coleenp@4037 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@4037 4 *
coleenp@4037 5 * This code is free software; you can redistribute it and/or modify it
coleenp@4037 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@4037 7 * published by the Free Software Foundation.
coleenp@4037 8 *
coleenp@4037 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@4037 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@4037 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@4037 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@4037 13 * accompanied this code).
coleenp@4037 14 *
coleenp@4037 15 * You should have received a copy of the GNU General Public License version
coleenp@4037 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@4037 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@4037 18 *
coleenp@4037 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@4037 20 * or visit www.oracle.com if you need additional information or have any
coleenp@4037 21 * questions.
coleenp@4037 22 *
coleenp@4037 23 */
coleenp@4037 24
coleenp@4037 25 #include "precompiled.hpp"
coleenp@4037 26 #include "memory/metaspaceCounters.hpp"
coleenp@4037 27 #include "memory/resourceArea.hpp"
ehelin@5531 28 #include "runtime/globals.hpp"
ehelin@5531 29 #include "runtime/perfData.hpp"
ehelin@4680 30 #include "utilities/exceptions.hpp"
coleenp@4037 31
ehelin@5531 32 class MetaspacePerfCounters: public CHeapObj<mtInternal> {
ehelin@5531 33 friend class VMStructs;
ehelin@5531 34 PerfVariable* _capacity;
ehelin@5531 35 PerfVariable* _used;
ehelin@5531 36 PerfVariable* _max_capacity;
coleenp@4037 37
ehelin@5531 38 PerfVariable* create_variable(const char *ns, const char *name, size_t value, TRAPS) {
ehelin@5531 39 const char *path = PerfDataManager::counter_name(ns, name);
ehelin@5531 40 return PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
ehelin@5531 41 }
ehelin@5531 42
ehelin@5531 43 void create_constant(const char *ns, const char *name, size_t value, TRAPS) {
ehelin@5531 44 const char *path = PerfDataManager::counter_name(ns, name);
ehelin@5531 45 PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
ehelin@5531 46 }
ehelin@5531 47
ehelin@5531 48 public:
ehelin@5531 49 MetaspacePerfCounters(const char* ns, size_t min_capacity, size_t curr_capacity, size_t max_capacity, size_t used) {
ehelin@5531 50 EXCEPTION_MARK;
ehelin@5531 51 ResourceMark rm;
ehelin@5531 52
ehelin@5531 53 create_constant(ns, "minCapacity", min_capacity, THREAD);
ehelin@5531 54 _capacity = create_variable(ns, "capacity", curr_capacity, THREAD);
ehelin@5531 55 _max_capacity = create_variable(ns, "maxCapacity", max_capacity, THREAD);
ehelin@5531 56 _used = create_variable(ns, "used", used, THREAD);
ehelin@5531 57 }
ehelin@5531 58
ehelin@5531 59 void update(size_t capacity, size_t max_capacity, size_t used) {
ehelin@5531 60 _capacity->set_value(capacity);
ehelin@5531 61 _max_capacity->set_value(max_capacity);
ehelin@5531 62 _used->set_value(used);
ehelin@5531 63 }
ehelin@5531 64 };
ehelin@5531 65
ehelin@5531 66 MetaspacePerfCounters* MetaspaceCounters::_perf_counters = NULL;
ehelin@5531 67
ehelin@5716 68 size_t MetaspaceCounters::used() {
ehelin@6609 69 return MetaspaceAux::used_bytes();
ehelin@5716 70 }
ehelin@5716 71
ehelin@5716 72 size_t MetaspaceCounters::capacity() {
ehelin@5716 73 return MetaspaceAux::committed_bytes();
ehelin@5716 74 }
ehelin@5716 75
ehelin@5716 76 size_t MetaspaceCounters::max_capacity() {
ehelin@5716 77 return MetaspaceAux::reserved_bytes();
jmasa@5015 78 }
jmasa@5015 79
ehelin@5531 80 void MetaspaceCounters::initialize_performance_counters() {
coleenp@4037 81 if (UsePerfData) {
ehelin@5531 82 assert(_perf_counters == NULL, "Should only be initialized once");
ehelin@5531 83
ehelin@5716 84 size_t min_capacity = 0;
ehelin@5716 85 _perf_counters = new MetaspacePerfCounters("metaspace", min_capacity,
ehelin@5716 86 capacity(), max_capacity(), used());
coleenp@4037 87 }
coleenp@4037 88 }
coleenp@4037 89
coleenp@4037 90 void MetaspaceCounters::update_performance_counters() {
coleenp@4037 91 if (UsePerfData) {
ehelin@5531 92 assert(_perf_counters != NULL, "Should be initialized");
ehelin@5531 93
ehelin@5716 94 _perf_counters->update(capacity(), max_capacity(), used());
coleenp@4037 95 }
coleenp@4037 96 }
coleenp@4037 97
ehelin@5531 98 MetaspacePerfCounters* CompressedClassSpaceCounters::_perf_counters = NULL;
ehelin@5531 99
ehelin@5716 100 size_t CompressedClassSpaceCounters::used() {
ehelin@6609 101 return MetaspaceAux::used_bytes(Metaspace::ClassType);
ehelin@5716 102 }
ehelin@5716 103
ehelin@5716 104 size_t CompressedClassSpaceCounters::capacity() {
ehelin@5716 105 return MetaspaceAux::committed_bytes(Metaspace::ClassType);
ehelin@5716 106 }
ehelin@5716 107
ehelin@5716 108 size_t CompressedClassSpaceCounters::max_capacity() {
ehelin@5716 109 return MetaspaceAux::reserved_bytes(Metaspace::ClassType);
ehelin@5531 110 }
ehelin@5531 111
ehelin@5531 112 void CompressedClassSpaceCounters::update_performance_counters() {
ehelin@5694 113 if (UsePerfData && UseCompressedClassPointers) {
ehelin@5531 114 assert(_perf_counters != NULL, "Should be initialized");
ehelin@5531 115
ehelin@5716 116 _perf_counters->update(capacity(), max_capacity(), used());
ehelin@5531 117 }
ehelin@5531 118 }
ehelin@5531 119
ehelin@5531 120 void CompressedClassSpaceCounters::initialize_performance_counters() {
ehelin@5531 121 if (UsePerfData) {
ehelin@5531 122 assert(_perf_counters == NULL, "Should only be initialized once");
ehelin@5531 123 const char* ns = "compressedclassspace";
ehelin@5531 124
ehelin@5694 125 if (UseCompressedClassPointers) {
ehelin@5716 126 size_t min_capacity = 0;
ehelin@5716 127 _perf_counters = new MetaspacePerfCounters(ns, min_capacity, capacity(),
ehelin@5716 128 max_capacity(), used());
ehelin@5531 129 } else {
ehelin@5531 130 _perf_counters = new MetaspacePerfCounters(ns, 0, 0, 0, 0);
ehelin@5531 131 }
ehelin@5531 132 }
ehelin@5531 133 }

mercurial