src/share/vm/services/nmtCommon.hpp

Wed, 27 Aug 2014 08:19:12 -0400

author
zgu
date
Wed, 27 Aug 2014 08:19:12 -0400
changeset 7074
833b0f92429a
child 7078
c6211b707068
permissions
-rw-r--r--

8046598: Scalable Native memory tracking development
Summary: Enhance scalability of native memory tracking
Reviewed-by: coleenp, ctornqvi, gtriantafill

zgu@7074 1 /*
zgu@7074 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
zgu@7074 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
zgu@7074 4 *
zgu@7074 5 * This code is free software; you can redistribute it and/or modify it
zgu@7074 6 * under the terms of the GNU General Public License version 2 only, as
zgu@7074 7 * published by the Free Software Foundation.
zgu@7074 8 *
zgu@7074 9 * This code is distributed in the hope that it will be useful, but WITHOUT
zgu@7074 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
zgu@7074 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
zgu@7074 12 * version 2 for more details (a copy is included in the LICENSE file that
zgu@7074 13 * accompanied this code).
zgu@7074 14 *
zgu@7074 15 * You should have received a copy of the GNU General Public License version
zgu@7074 16 * 2 along with this work; if not, write to the Free Software Foundation,
zgu@7074 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
zgu@7074 18 *
zgu@7074 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
zgu@7074 20 * or visit www.oracle.com if you need additional information or have any
zgu@7074 21 * questions.
zgu@7074 22 *
zgu@7074 23 */
zgu@7074 24
zgu@7074 25 #ifndef SHARE_VM_SERVICES_NMT_COMMON_HPP
zgu@7074 26 #define SHARE_VM_SERVICES_NMT_COMMON_HPP
zgu@7074 27
zgu@7074 28 #include "memory/allocation.hpp"
zgu@7074 29 #include "utilities/globalDefinitions.hpp"
zgu@7074 30
zgu@7074 31 #define CALC_OBJ_SIZE_IN_TYPE(obj, type) (align_size_up_(sizeof(obj), sizeof(type))/sizeof(type))
zgu@7074 32
zgu@7074 33 // Data type for memory counters
zgu@7074 34 #ifdef _LP64
zgu@7074 35 typedef jlong MemoryCounterType;
zgu@7074 36 #else
zgu@7074 37 typedef jint MemoryCounterType;
zgu@7074 38 #endif
zgu@7074 39
zgu@7074 40 // Native memory tracking level
zgu@7074 41 enum NMT_TrackingLevel {
zgu@7074 42 NMT_unknown = 0xFF,
zgu@7074 43 NMT_off = 0x00,
zgu@7074 44 NMT_minimal = 0x01,
zgu@7074 45 NMT_summary = 0x02,
zgu@7074 46 NMT_detail = 0x03
zgu@7074 47 };
zgu@7074 48
zgu@7074 49 // Number of stack frames to capture. This is a
zgu@7074 50 // build time decision.
zgu@7074 51 const int NMT_TrackingStackDepth = 4;
zgu@7074 52
zgu@7074 53 class NativeCallStack;
zgu@7074 54 extern NativeCallStack emptyStack;
zgu@7074 55
zgu@7074 56 // A few common utilities for native memory tracking
zgu@7074 57 class NMTUtil : AllStatic {
zgu@7074 58 public:
zgu@7074 59 // Map memory type to index
zgu@7074 60 static inline int flag_to_index(MEMFLAGS flag) {
zgu@7074 61 return (flag & 0xff);
zgu@7074 62 }
zgu@7074 63
zgu@7074 64 // Map memory type to human readable name
zgu@7074 65 static const char* flag_to_name(MEMFLAGS flag) {
zgu@7074 66 return _memory_type_names[flag_to_index(flag)];
zgu@7074 67 }
zgu@7074 68
zgu@7074 69 // Map an index to memory type
zgu@7074 70 static MEMFLAGS index_to_flag(int index) {
zgu@7074 71 return (MEMFLAGS)index;
zgu@7074 72 }
zgu@7074 73
zgu@7074 74 // Memory size scale
zgu@7074 75 static const char* scale_name(size_t scale);
zgu@7074 76 static size_t scale_from_name(const char* scale);
zgu@7074 77
zgu@7074 78 // Translate memory size in specified scale
zgu@7074 79 static size_t amount_in_scale(size_t amount, size_t scale) {
zgu@7074 80 return (amount + scale / 2) / scale;
zgu@7074 81 }
zgu@7074 82 private:
zgu@7074 83 static const char* _memory_type_names[mt_number_of_types];
zgu@7074 84 };
zgu@7074 85
zgu@7074 86
zgu@7074 87 #endif

mercurial